Booting from an SD Card
Omega Tip of the Week: Booting from an SD Card
Extra storage space on the filesystem allows you to make more complex projects with lots of moving parts and storage space for media. So this week we’ll cover how to boot your Omega2+ filesystem from an SD Card.
We will be using the pivot-overlay procedure to move the writeable portion of the Omega’s filesystem to an SD card.
A few warnings before we proceed:
- Performing a firmware update will undo this process
- Booting your Omega without the SD card connected will force it to boot from the on-board flash storage, meaning the files, installed packages, and configuration from your SD card will not be available
- Don’t worry though, just reboot your Omega with the SD card plugged in to get your data back!
First we will be mounting the SD card to the Omega’s filesystem, then we’ll copy over the writeable portion of the filesystem over to the SD card, and finally configure the system so that it uses the filesystem from the SD card when the Omega boots up!
The SD card will need to be formatted to an ext4 filesystem for everything to work properly, you can use our ext4 formatting guide.
Once you connect your SD card, the device will be mapped to the filesystem as /dev/mmcblk0 (or something very similar) and the filesystem will automatically be mounted at /tmp/mounts/SD-P (again, or something very similar).
Let’s unmount it: umount /tmp/mounts/SD-P and then duplicate the /overlay directory, the writeable portion of the Omega’s filesystem over to the SD card:
mount /dev/mmcblk0 /mnt tar -C /overlay -cvf - . | tar -C /mnt -xf - umount /mnt
Almost done, we just need to configure the Omega so that it uses the /overlay directory from the SD card whenever it boots up. We’ll install block-mount and use it to generate the filesystem table (fstab) configuration entry for the SD card:
opkg update opkg install block-mount block detect > /etc/config/fstab
Let’s edit the configuration file: vi /etc/config/fstab
Find the line option target ‘/mnt/mmcblk0’ and change it to option target ‘/overlay’.
Then find the line option enabled ‘0’ and change it to option enabled ‘1’
Save and close the file by hitting the escape key and typing :wq and you’re done!
Reboot your Omega and check out all the room for activities:
root@Omega-665D:/# df -h Filesystem Size Used Available Use% Mounted on /dev/root 5.5M 5.5M 0 100% /rom tmpfs 61.4M 100.0K 61.3M 0% /tmp /dev/mmcblk0 7.0G 33.4M 6.6G 0% /overlay overlayfs:/overlay 7.0G 33.4M 6.6G 0% / tmpfs 512.0K 0 512.0K 0% /dev
Let us know what kind of stuff you would like to see featured on 2-Bullet Tuesday! Send a tweet to @OnionIoT with your suggestions!
Thanks for reading! Have a great week!