Mounting the root FS on an SD card

The on-board flash on the LinkIt Smart 7688 development board is a raw flash. It offers limited write cycles (about 100,000) and doesn't provide a wear leveling mechanism and atomic write operation. Therefore, writing user data to the on-board flash frequently isn't recommended.

In addition, the flash storage is 32MB, this space might not be sufficient for storing user data and software packages. As a result, mounting the root FS on an SD card is recommended. Not only does this provide more storage, it's more reliable too.

The procedure provided here assumes there is only one partition on the SD card. If there are multiple partitions on the SD card, you can use Partitioning with fdisk to manage the partition settings.

All data on the SD card will be erased as a result of the following steps.

Steps

The steps to mounting the root FS are provided below. For more details, please refer to Rootfs on External Storage (extroot) in OpenWrt.

  1. Insert a micro-SD card into the LinkIt Smart 7688 device. 
  2. Make sure the device is in Station mode and can access the internet.
  3. Open the LinkIt Smart 7688 board's system console.
  4. Enter the following commands to install the required packages:

    # opkg update
    # opkg install block-mount kmod-fs-ext4 kmod-usb-storage-extras e2fsprogs fdisk
  5. Format the SD card. ext4 file system is used in this example:

    # mkfs.ext4 /dev/mmcblk0p1

    During the formatting, you'll be prompted to confirm: Proceed anyway? (y,n). Press "y" to continue.

  6. Duplicate the current root FS and move it to the SD card by typing the following commands:

    # mount /dev/mmcblk0p1 /mnt
    # tar -C /overlay -cvf - . | tar -C /mnt -xf -
    # umount /mnt
  7. Create a fstab template, for example:

    # block detect > /etc/config/fstab
  8. Open the fstab configuration (vi is used as an editor in this example):

    # vi /etc/config/fstab
  9. In the 'mount' config section, change the following: (In vi, press the "i" key to start editing)
    • the target option to '/overlay'.
    • the enabled option to '1'.

      Then, the configuration file will look like this:

      config 'mount'
        option  target  '/overlay'
        ...
        option  enabled '1'
  10. Save and exit the configuration file (press Esc key and type :x. Then press Enter in vi to save the file).
  11. Reboot the platform to complete the setup.

Verify the setup

Use "df -h" command to check if the root FS is mounted successfully.

When the root FS is on the on-board flash, you'll see rootfs only has 11MB storage space left: 

root@mylinkit:/# df -h
Filesystem                Size      Used Available Use% Mounted on
rootfs                   11.0M      1.2M      9.8M  11% /
/dev/root                19.8M     19.8M         0 100% /rom

After mounting the root FS on the SD card, you'll see the spare space in rootfs has increased: 

root@mylinkit:~# df -h
Filesystem                Size      Used Available Use% Mounted on
rootfs                    7.2G     24.6M      6.7G   0% /
/dev/root                19.8M     19.8M         0 100% /rom

In this example, an 8GB SD card is used and the rootfs size is 7.2GB.