Frequently customers come to us asking if it's OK to use their newly purchased blank 8GB (or larger) micro SD media with the 2GB or 4GB SD images provided for their SBC.
The answer is yes. A 4GB image will fit on an 8GB media card without causing any errors.
The follow-up question is of course how do we make efficient use of this extra space?
There are a number of ways to tackle this problem. I'll provide two here for your consideration. Both of these assume your micro SD card is already imaged according to the instructions in the user manual for your product. See further: https://wiki.embeddedarm.com/.
The GNOME Partition Editor is possibly the most comprehensive, easy-to-use partition editor available. This utility makes expanding the Debian partition on your SD media a triviality. Basically, download GParted and follow the installation instructions relevant to your OS (this is a good spot to start: https://gparted.org/). Once you have GParted running, it's about as easy as clicking the disk you want to modify, dragging the partition boundary to its new size, and clicking the commit button. Once GParted is done, your micro SD is ready to use with the bigger partition!
This method is a little longer, but sometimes necessary. Basically this method works in situations where GParted might not. In a nutshell, treat the SD card like you would a normal computer's hard drive. Back up the large partition's data onto some other media, use fdisk to delete the old partition and create a new larger partition, then use mkfs.ext3 to format the new partition. Finally restore your backup to the new larger partition. This may require you to learn some rudimentary management skills in Linux. In particular:
Be able to identify the device nodes of media attached to your computer (eg. /dev/sdc).
Be able to identify the device nodes of partitions on your media (eg. /dev/sdc1).
Be able to use the sudo command if required by the security on your local system.
Be able to use the mount command to access the data on the partition you wish to remake.
Be able to use the tar command to quickly archive and restore a large number of files.
Here is an example scenario:
Insert the micro SD into a reader and connect it to your Linux PC. After a few seconds, use dmesg to find out what device nodes were assigned to the new media. On my PC it's usually /dev/sdc, but be careful, it's actually really easy to misread what device you want to point at and accidentally erase your hard drive by mistake.
Find out what nodes are what: On most systems, you'll have access to the lsblk command. This little gem can save a few moments trying to find the device's ID output in dmesg. Try running this:
If you have it, this will output a table that makes it much easier to identify what device nodes belong to which devices. If you don't, the information you need is in dmesg, you just have to read more to find it.
Mount and backup: First you'll need to get the micro SD into a position that's easy for you to work with. Inserting one into a Linux computer will generally open a bunch of windows and automatically mount the media in arcane locations with insane folder names (like /mnt/media/2af3ebc7d112c9d447b-c/). This can actually get in the way of what we're trying to accomplish in this article, so we'll unmount all that and mount it again manually with more human-workable names:
sudo umount /dev/sdc*
sudo mkdir mnt
sudo mount /dev/sdc3 mnt
Tar: Tar is a universally used archiving utility. This is an exceptionally powerful tool that's worth learning in detail. For this article, we'll give you the command line switches you need, but we recommend taking some time to really understand how this tool works. Also, take note Linux is a case-sensitive environment. The command-line switch "-cJf" for example includes a capital letter 'J'.
sudo tar -cJf ../backup.tar.xz * --numeric-owner # This will take a while. When done, your Linux PC will have a backup of the micro SD card's Debian partition.
sudo umount mnt
Fdisk: Here are the keystrokes I use. The bold text with the pound signs (#) are comments, don't type those. Also, sometimes different versions of fdisk vary a little - be sure to read what it says between keystrokes, in case your version needs something we didn't anticipate here.
sudo fdisk /dev/sdc
p # This prints the partition table for you to review.
d # Follow prompts, delete the Debian partition (usually the last one. In this example we'll use 3).
n # Create a new partition.
p # Make it a primary partition.
3 # Declare which partition number you want the new partition to be (same number as the one you just deleted).
<enter> #press enter to accept default partition start block, or edit it here if needed.
<enter> # press enter to accept default partition end size, or enter your preferred new size here.
w #this will commit your changes to the partition table and exit fdisk
Format, and remount:
sudo mkfs.ext3 /dev/sdc3
mkdir mnt # If you did all the previous instructions, this should give you an error because mnt already exists.
sudo mount /dev/sdc3 mnt
Restore the archive to the micro SD media:
sudo tar -xJf ../backup.tar.xz -C . --numeric-owner # Extract the backup back onto the micro SD media.
sudo umount mnt
sync # This tells Linux to dump all of its caches to media. Important to do before removing the media!
Your micro SD media now has a larger Debian partition and is ready for use in your Technologic Systems computing module.