Fstab block mount : wrong order processing?

Hello,

I configured different mount point using fstab configuration and block-mount
Here is my /etc/config/fstab


config global
        option anon_swap '0'
        option anon_mount '0'
        option auto_swap '1'
        option auto_mount '1'
        option delay_root '5'
        option check_fs '0'

config mount
        option target '/mnt/sda1'
        option uuid '57f8f4bc-abf4-655f-bf67-946fc0f9f25b'
        option enabled '0'

config mount
        option target '/mnt/sda2'
        option uuid '57f8f4bc-abf4-655f-bf67-946fc0f9f25b'
        option enabled '0'

config swap
        option uuid '76a17421-4317-40d4-b62e-d6510627334e'
        option label 'swap'
        option enabled '1'
        option device '/dev/sda4'

config mount
        option uuid '84eefd86-9cd3-463a-aa70-6ac876fd4432'
        option label 'home'
        option device '/dev/sda5'
        option fstype 'ext4'
        option target '/home'
        option enabled '1'
        option enabled_fsck '1'
        option options 'rw,sync,delalloc,block_validity'

config mount
        option uuid '439af06e-a586-4ded-9ab6-7703aff9853f'
        option label 'srv'
        option device '/dev/sda6'
        option fstype 'ext4'
        option target '/srv'
        option enabled '1'
        option enabled_fsck '1'
        option options 'rw,sync,delalloc,block_validity'

config mount
        option uuid '041c1481-07b9-48ac-b89c-46da429872b9'
        option label 'setup'
        option device '/dev/sda7'
        option fstype 'ext4'
        option target '/etc/setup'
        option enabled '1'
        option enabled_fsck '1'
        option options 'rw,sync,delalloc,block_validity'

config mount
        option uuid '8c9aea45-352f-4428-8805-a69445d4b1a4'
        option label 'ext'
        option device '/dev/sda8'
        option fstype 'ext4'
        option options 'rw,sync'
        option target '/srv/ext'
        option enabled_fsck '1'
        option enabled '0'

Here is the result of uci show fstab

fstab.@global[0]=global
fstab.@global[0].anon_swap='0'
fstab.@global[0].anon_mount='0'
fstab.@global[0].auto_swap='1'
fstab.@global[0].auto_mount='1'
fstab.@global[0].delay_root='5'
fstab.@global[0].check_fs='0'
fstab.@mount[0]=mount
fstab.@mount[0].target='/mnt/sda1'
fstab.@mount[0].uuid='57f8f4bc-abf4-655f-bf67-946fc0f9f25b'
fstab.@mount[0].enabled='0'
fstab.@mount[1]=mount
fstab.@mount[1].target='/mnt/sda2'
fstab.@mount[1].uuid='57f8f4bc-abf4-655f-bf67-946fc0f9f25b'
fstab.@mount[1].enabled='0'
fstab.@swap[0]=swap
fstab.@swap[0].uuid='76a17421-4317-40d4-b62e-d6510627334e'
fstab.@swap[0].label='swap'
fstab.@swap[0].enabled='1'
fstab.@swap[0].device='/dev/sda4'
fstab.@mount[2]=mount
fstab.@mount[2].uuid='84eefd86-9cd3-463a-aa70-6ac876fd4432'
fstab.@mount[2].label='home'
fstab.@mount[2].device='/dev/sda5'
fstab.@mount[2].fstype='ext4'
fstab.@mount[2].target='/home'
fstab.@mount[2].enabled='1'
fstab.@mount[2].enabled_fsck='1'
fstab.@mount[2].options='rw,sync,delalloc,block_validity'
fstab.@mount[3]=mount
fstab.@mount[3].uuid='439af06e-a586-4ded-9ab6-7703aff9853f'
fstab.@mount[3].label='srv'
fstab.@mount[3].device='/dev/sda6'
fstab.@mount[3].fstype='ext4'
fstab.@mount[3].target='/srv'
fstab.@mount[3].enabled='1'
fstab.@mount[3].enabled_fsck='1'
fstab.@mount[3].options='rw,sync,delalloc,block_validity'
fstab.@mount[4]=mount
fstab.@mount[4].uuid='041c1481-07b9-48ac-b89c-46da429872b9'
fstab.@mount[4].label='setup'
fstab.@mount[4].device='/dev/sda7'
fstab.@mount[4].fstype='ext4'
fstab.@mount[4].target='/etc/setup'
fstab.@mount[4].enabled='1'
fstab.@mount[4].enabled_fsck='1'
fstab.@mount[4].options='rw,sync,delalloc,block_validity'
fstab.@mount[5]=mount
fstab.@mount[5].uuid='8c9aea45-352f-4428-8805-a69445d4b1a4'
fstab.@mount[5].label='ext'
fstab.@mount[5].device='/dev/sda8'
fstab.@mount[5].fstype='ext4'
fstab.@mount[5].options='rw,sync'
fstab.@mount[5].target='/srv/ext'
fstab.@mount[5].enabled_fsck='1'
fstab.@mount[5].enabled='1'

All is working fine ... except the order in which the devices are mounted.
My problem is that /dev/sda8 => /srv/ext is mounted before /dev/sda6 => /srv each time.

# block info

/dev/sda1: UUID="57f8f4bc-abf4-655f-bf67-946fc0f9f25b" VERSION="1.0" MOUNT="/boot" TYPE="ext4"
/dev/sda2: UUID="57f8f4bc-abf4-655f-bf67-946fc0f9f25b" VERSION="1.0" MOUNT="/" TYPE="ext4"
/dev/sda4: UUID="76a17421-4317-40d4-b62e-d6510627334e" LABEL="swap" VERSION="1" TYPE="swap"
/dev/sda5: UUID="84eefd86-9cd3-463a-aa70-6ac876fd4432" LABEL="home" VERSION="1.0" MOUNT="/home" TYPE="ext4"
/dev/sda6: UUID="439af06e-a586-4ded-9ab6-7703aff9853f" LABEL="srv" VERSION="1.0" MOUNT="/srv" TYPE="ext4"
/dev/sda7: UUID="041c1481-07b9-48ac-b89c-46da429872b9" LABEL="setup" VERSION="1.0" MOUNT="/etc/setup" TYPE="ext4"
/dev/sda8: UUID="8c9aea45-352f-4428-8805-a69445d4b1a4" LABEL="ext" VERSION="1.0" MOUNT="/srv/ext" TYPE="ext4"

# mount

/dev/root on / type ext4 (rw,noatime,block_validity,delalloc,barrier,user_xattr)
proc on /proc type proc (rw,nosuid,nodev,noexec,noatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,noatime)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime)
/dev/sda1 on /boot type ext4 (rw,noatime,block_validity,delalloc,barrier,user_xattr)
/dev/sda1 on /boot type ext4 (rw,noatime,block_validity,delalloc,barrier,user_xattr)
tmpfs on /dev type tmpfs (rw,nosuid,relatime,size=512k,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,mode=600,ptmxmode=000)
/dev/sda7 on /etc/setup type ext4 (rw,sync,relatime,data=ordered)
/dev/sda5 on /home type ext4 (rw,sync,relatime,data=ordered)
debugfs on /sys/kernel/debug type debugfs (rw,noatime)
/dev/sda8 on /srv/ext type ext4 (rw,sync,relatime,data=ordered)
/dev/sda6 on /srv type ext4 (rw,sync,relatime,data=ordered)

# df -h

Filesystem                Size      Used Available Use% Mounted on
/dev/root                 7.9G     11.1M      7.8G   0% /
tmpfs                   121.8M     60.0K    121.7M   0% /tmp
/dev/sda1               256.0M      3.6M    247.3M   1% /boot
/dev/sda1               256.0M      3.6M    247.3M   1% /boot
tmpfs                   512.0K         0    512.0K   0% /dev
/dev/sda7               975.9M      1.3M    907.4M   0% /etc/setup
/dev/sda5                 1.9G      1.5M      1.8G   0% /home
/dev/sda8                 2.6G      4.1M      2.5G   0% /srv/ext
/dev/sda6                 2.6G      4.1M      2.5G   0% /srv

If i unmount after startup the /srv/ext and then /srv to remount them as

# mount /dev/sda6 /srv
# mount /dev/sda8 /srv/ext

here is the good order:

/dev/root on / type ext4 (rw,noatime,block_validity,delalloc,barrier,user_xattr)
proc on /proc type proc (rw,nosuid,nodev,noexec,noatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,noatime)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime)
/dev/sda1 on /boot type ext4 (rw,noatime,block_validity,delalloc,barrier,user_xattr)
/dev/sda1 on /boot type ext4 (rw,noatime,block_validity,delalloc,barrier,user_xattr)
tmpfs on /dev type tmpfs (rw,nosuid,relatime,size=512k,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,mode=600,ptmxmode=000)
/dev/sda7 on /etc/eynola type ext4 (rw,sync,relatime,data=ordered)
/dev/sda5 on /home type ext4 (rw,sync,relatime,data=ordered)
debugfs on /sys/kernel/debug type debugfs (rw,noatime)
/dev/sda6 on /srv type ext4 (rw,relatime,data=ordered)
/dev/sda8 on /srv/ext type ext4 (rw,relatime,data=ordered)

Filesystem                Size      Used Available Use% Mounted on
/dev/root                 7.9G     11.1M      7.8G   0% /
tmpfs                   121.8M     64.0K    121.7M   0% /tmp
/dev/sda1               256.0M      3.6M    247.3M   1% /boot
/dev/sda1               256.0M      3.6M    247.3M   1% /boot
tmpfs                   512.0K         0    512.0K   0% /dev
/dev/sda7               975.9M      1.3M    907.4M   0% /etc/eynola
/dev/sda5                 1.9G      1.5M      1.8G   0% /home
/dev/sda6                 2.6G      4.1M      2.5G   0% /srv
/dev/sda8               975.9M      1.3M    907.4M   0% /srv/ext

and then /dev/sda6 is available through /srv and /dev/sda8 through /srv/ext

I tried the following things in /etc/config/fstab for sda6 and sda8

  • only specify mount[x].uuid=
  • only specify mount[x].device=
  • only specify mount[x].label=
  • inverse config mount section order between sda6 and sda8

but sda8 is always mounted before sda6

In which order are processed the mount order from the /etc/config/fstab ?
It does not seems to follow the mount[$idx] order.

Is there any way to force the order of mounted device at startup ?

Many thanks in advance.

Kind Regards

1 Like

I have the same problem. Have you found a proper solution meantime?
I checked the source, it should follow the mount[$ idx] sequence, but somehow it doesn't.

As a workaround, I set the enabled parameter in /etc/config/fstab to 0 and mount them manually (in the correct order) in /etc/rc.local.

1 Like

I've also faced with this problem.

From what I found in the source (and confirmed with strace and experiments), the order of mount matches order of how devices were discovered. The same order is used for block info command.

In my case I've renamed the logical volume from bar to zbar so it is mounted after foo.
That workaround works for items under /dev/mapper/. But it's not that easy to rename /dev/sdXY items. And it's not possible to mount /dev/sd* after /dev/mapper/* or so via block mount.

My observations don't match @moocan 's experience, sda6 should be mounted before sda8. But maybe block tool had been changed since than.

@sandor.balazsi where did you find mount[$idx]? I don't see that in the code.

1 Like

@AntonR: It is iterating through the UCI sections of /etc/config/fstab sequentially:
https://git.openwrt.org/?p=project/fstools.git;a=blob;f=block.c;hb=HEAD#l469

1 Like

Ah, I see. That's how it fills mounts configuration list, but for real mounting it iterates over devices.

1 Like