0

I would like to have a root file system composed of several aufs branches mounted on /.

My Linux is a custom one created using buildroot and deployed on a board with a SAMA5D2 processor.

The mmc of my board is partionned as follow:

<device>              <size>   <type>                <flag>
/dev/mmcblk0p1        20M      FAT32                 boot1
/dev/mmcblk0p2        20M      FAT32                 boot2
/dev/mmcblk0p3        500M     ext2                  rootfs
/dev/mmcblk0p4        13.2G    Extended partition    -
/dev/mmcblk0p5        100M     ext2                  factory_application
/dev/mmcblk0p6        500M     ext2                  update_overlays1
/dev/mmcblk0p7        500M     ext2                  update_overlays2
/dev/mmcblk0p8        12.1G    ext2                  persistant_data

There are two boot partition and two update overlays to be mounted as read/write when an update will be applied, then partitions are switched.

I want the root file system to be layered as follow

upper layer  |  persistant_data              read-write
             |  update_overlays              read-only
             |  factory_application          read-only
             |  rootfs                       read-only
lower layer  V  boot                         read-only

What I have done so far


So far I have been able to mount partitions at boot and to create a aufs mount point as follow:

Here are kernel parameters

console=ttyS0,115200n8 root=/dev/mmcblk0p3 ro rootwait quiet g_ether.host_addr=00:b0:ce:00:00:02 g_ether.dev_addr=00:b0:ce:00:00:01

Here is fstab

# cat /etc/fstab 
# <file system> <mount pt>      <type>  <options>       <dump>  <pass>
/dev/root       /               ext2    ro,noauto       0       1
proc            /proc           proc    defaults        0       0
devpts          /dev/pts        devpts  defaults,gid=5,mode=620,ptmxmode=0666   0       0
tmpfs           /dev/shm        tmpfs   mode=0777       0       0
tmpfs           /tmp            tmpfs   mode=1777       0       0
tmpfs           /run            tmpfs   mode=0755,nosuid,nodev  0       0
sysfs           /sys            sysfs   defaults        0       0
/dev/mmcblk0p1  /mnt/boot       vfat    ro              0       0
/dev/mmcblk0p5  /mnt/factory    ext2    ro              0       0
/dev/mmcblk0p6  /mnt/update     ext2    ro              0       0
/dev/mmcblk0p8  /mnt/pd         ext2    defaults        0       0

And here is inittab

# cat /etc/inittab
# /etc/inittab
#
# Copyright (C) 2001 Erik Andersen <andersen@codepoet.org>
#
# Note: BusyBox init doesn't support runlevels.  The runlevels field is
# completely ignored by BusyBox init. If you want runlevels, use
# sysvinit.
#
# Format for each entry: <id>:<runlevels>:<action>:<process>
#
# id        == tty to run on, or empty for /dev/console
# runlevels == ignored
# action    == one of sysinit, respawn, askfirst, wait, and once
# process   == program to run

# Startup the system
::sysinit:/bin/mount -t proc proc /proc
::sysinit:/bin/mkdir -p /dev/pts
::sysinit:/bin/mkdir -p /dev/shm
::sysinit:/bin/mount -a
::sysinit:/bin/mount -t aufs -o br=/mnt/pd=rw:/mnt/update=ro:/mnt/factory=ro:/mnt/boot=ro,udba=reval none /mnt/aufs
::sysinit:/bin/hostname -F /etc/hostname
# now run any rc scripts
::sysinit:/etc/init.d/rcS

# Put a getty on the serial port
console::respawn:/sbin/getty -L  console 0 vt100 # GENERIC_SERIAL

# Stuff to do for the 3-finger salute
#::ctrlaltdel:/sbin/reboot

# Stuff to do before rebooting
::shutdown:/etc/init.d/rcK
::shutdown:/sbin/swapoff -a
::shutdown:/bin/umount -a -r

As you can see, the aufs mount is working quite well

# mount
/dev/root on / type ext2 (ro,relatime,block_validity,barrier,user_xattr)
devtmpfs on /dev type devtmpfs (rw,relatime,size=222416k,nr_inodes=55604,mode=755)
proc on /proc type proc (rw,relatime)
devpts on /dev/pts type devpts (rw,relatime,gid=5,mode=620,ptmxmode=666)
tmpfs on /dev/shm type tmpfs (rw,relatime,mode=777)
tmpfs on /tmp type tmpfs (rw,relatime)
tmpfs on /run type tmpfs (rw,nosuid,nodev,relatime,mode=755)
sysfs on /sys type sysfs (rw,relatime)
/dev/mmcblk0p1 on /mnt/boot type vfat (ro,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)
/dev/mmcblk0p5 on /mnt/factory type ext2 (ro,relatime,block_validity,barrier,user_xattr)
/dev/mmcblk0p6 on /mnt/update type ext2 (ro,relatime,block_validity,barrier,user_xattr)
/dev/mmcblk0p8 on /mnt/pd type ext2 (rw,relatime,block_validity,barrier,user_xattr)
none on /mnt/aufs type aufs (rw,relatime,si=a9f95e05)

And the partitions are united in the folder /mnt/aufs

# ls /mnt/aufs/
boot_file     lost+found  sama5d2.dtb  zImage
factory_file  pd_file     update_file

The problem I'm facing


What I would like to do is to have the aufs mount into / instead of /mnt/aufs

- First try

However when I'm trying to use / as the mountpoint, the mount command seems to work but I can't see any file from others partitions into / folder

# mount -t aufs -o br=/mnt/pd=rw:/mnt/update=ro:/mnt/factory=ro:/mnt/boot=ro,udba=reval none /

# mount
[...]
none on / type aufs (rw,relatime,si=9ef5aaee)

Files from the different partitions aren't present into /

# ls /
bin  etc   lib    linuxrc  mnt  proc  run   sys  usr
dev  home  lib32  media    opt  root  sbin  tmp  var

- Second try

I have also tried to mount / as a layer into /mnt/aufs which worked well.

# mount -t aufs -o br=/mnt/pd=rw:/mnt/update=ro:/mnt/factory=ro:/=ro:/mnt/boot=ro,udba=reval none /mnt/aufs

# mount
[...]
none on /mnt/aufs type aufs (rw,relatime,si=73ed3d1d)

Now files from the different partitions are present into /mnt/aufs

# ls /mnt/aufs/
bin           home        media    root              tmp
boot_file     lib         mnt      run               update_file
dev           lib32       opt      sama5d2.dtb       usr
etc           linuxrc     pd_file  sbin              var
factory_file  lost+found  proc     sys               zImage

- Third try

The last try I have done was to try to mount / as a layer into /.

# mount -t aufs -o br=/mnt/pd=rw:/mnt/update=ro:/mnt/factory=ro:/=ro:/mnt/boot=ro,udba=reval none /

# mount
[...]
none on / type aufs (rw,relatime,si=73ed391d)

Once again the mount command seems to work but files aren't present into /

# ls /
bin  etc   lib    linuxrc  mnt  proc  run   sys  usr
dev  home  lib32  media    opt  root  sbin  tmp  var

How could I achieve my goal of having my different partitions mounted into / as aufs layered root filesystem ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.