Wiki

Clone wiki

YunTricks / Setup Overlay filesystem

In order to avoid damaging internal Linino EEPROM, it is advisable to use a microSD card for installing additional software. It is possible to extend the root filesystem by using the overlay technique. Proceed as follows.

  1. Partition a microSD card with at least one ext3 partition. It is advisable to have two partition on the SD, half the space formatted as vfat (for windows/mac compatibility), and half formatted as ext3. The latter is a linux filesystem, that must be created on a linux machine. A linux virtual machine would do as well. Use the gparted graphical tool for formatting and partitioning the microSD. The following assumes that the vfat partition comes before the ext3 one. At the end, connect the microSD to the Yùn and boot it.

  2. Log on the Linino via ssh and type the following, which assumes that the ext3 is the second partition on the microSD (partition /dev/sda2):

    $ tar -C /overlay -cvf - . | tar -C /mnt/sda2 -xf -
    $ mkdir /mnt/sd
    
  3. Edit the file /etc/config/fstab and add at the end the following lines (look here for how to edit a textfile on Linino):

    config mount
            option device '/dev/sda1'
            option fstype 'vfat'
            option enabled '1'
            option target '/mnt/sd'
    
    config mount
            option target        /overlay
            option device        /dev/sda2        
            option fstype        ext3                
            option options       rw,sync                        
            option enabled       1                                
            option enabled_fsck  0
    
  4. Reboot the Linino. At the end, you shall get something like that:

    root@ArduinoPB:~# df
    Filesystem           1K-blocks      Used Available Use% Mounted on
    rootfs                 3724584     18108   3513944   1% /
    /dev/root                 7168      7168         0 100% /rom
    tmpfs                    30568       144     30424   0% /tmp
    tmpfs                      512         0       512   0% /dev
    /dev/sda2              3724584     18108   3513944   1% /overlay
    overlayfs:/overlay     3724584     18108   3513944   1% /
    /dev/sda1              3896164      1016   3895148   0% /mnt/sd
    

    which shows that the root filesystem has the same size of the overlay filesystem. Any file created under root from now on, will be actually created in the microSD card.

DO NOT REMOVE THE MICROSD WHILE THE ARDUINO IS POWERED ON. It is still possible, though, to boot the arduino without the microSD attached. In this case, anything added while the overlay was active will not be visible.

Updated