How to auto mount various volumes at startup?

I currently have two file systems I kind of fail to mount at startup. One is btrfs on a RAID1 md device and the other is xfs on a plain HD partition.

I’ve worked around the former by adding mdadm --assemble --scan in /etc/rc.local and I could probably also add mount /dev/sdXX /mountpointthere but that would mean both file systems wouldn’t be available when the system init scripts run.

So what’s the canonical way to mount these as early as posible in the boot process? I have both configured in /etc/rc.d/S40fstab but that alone fails to do the trick. Any suggestions?

Hi,

you should be able to add mounts in Luci as well: http://192.168.1.1/cgi-bin/luci/admin/system/fstab

I think those would just end up in /etc/config/fstab as well. At least, all the mounts from that file show up in LuCI as well.

Nobody who can shed any light on this? Should I rather open issues for my problems?

Just at mountpoints you should have mounted what you want to mount. It will automatically mount on startup.

Majordomo as well as LXC are 2 partitions running on my internal mSATA drive. In case of the RAID, you have to use the UUID of the RAID and NOT of the parition. If i remember correctly of my own NAS (not Omnia), it was the same. Using the UUID is unique and will not change. So if you type “blkid” if i am correct you will see the UUID of your RAID.

blkid:

> root@K-Router:/etc/config# blkid
/dev/mmcblk0p1: UUID="5a0c7fd9-f1cf-48f4-9812-0d6cfa15574f" UUID_SUB="0e81e00b-3676-43fa-b1b5-19500f0f105e" TYPE="btrfs" PARTUUID="b6b3faa0-01"
/dev/sda1: UUID="e9e630b9-00de-4e19-9661-fef45c1fdd94" UUID_SUB="7b511f96-1565-4b0d-b6c5-d7a3e3963e44" TYPE="btrfs" PARTUUID="12774218-01"
/dev/sda2: UUID="b3964b7b-cd45-4137-9624-49cf6e67b220" UUID_SUB="d56b8215-4a67-4e17-a4b9-5dcb05482a17" TYPE="btrfs" PARTUUID="12774218-02"
/dev/mmcblk0: PTUUID="b6b3faa0" PTTYPE="dos"

As you can see there is the UUID and the UUID_SUB. The UUID is of the harddrive itself, but the UUID_SUB is of the partition. Post your “blkid” result here to see what you are having as a result.

Here my fstab file.

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/majordomo'
        option enabled '1'
        option uuid '7b511f96-1565-4b0d-b6c5-d7a3e3963e44'
        option fstype 'btrfs'

config mount
        option uuid 'd56b8215-4a67-4e17-a4b9-5dcb05482a17'
        option target '/mnt/LXC'
        option fstype 'btrfs'
        option enabled '1'

config swap
        option device '/dev/sda3'
        option label 'swap'
        option enabled '0'
1 Like

Thank you very much for your reply!

Here’s my blkid output:

root@router:~# blkid
/dev/mmcblk0p1: UUID="8187ebf6-b734-4ac3-9a12-5b55c3b4875e" UUID_SUB="06b8e48f-5ff7-497c-a8fd-6107582e99ba" TYPE="btrfs" PARTUUID="a2be4883-01"
/dev/sda1: UUID="723fc817-ac23-0406-de4a-79789b5c08a6" UUID_SUB="0181f37a-d1b9-dff5-14e3-adb52edc6c70" LABEL="router:0" TYPE="linux_raid_member" PARTUUID="ef39a8ff-2ed4-456a-9310-b18613836eae"
/dev/sda2: LABEL="storage0" UUID="6ba65c30-a571-47bf-b121-8f4f8c7b159c" UUID_SUB="6b964db3-5e10-40f6-afa7-0c0b922673ce" TYPE="btrfs" PARTUUID="3b4af862-34d0-427f-b737-24d680059c12"
/dev/sdb1: UUID="904375ca-41b9-47e5-ad17-5722fa9ae4b3" TYPE="ext3" PARTUUID="00012619-01"
/dev/sdb5: UUID="1ece3d7a-8972-44e1-a19b-3b0c54a253e5" TYPE="swap" PARTUUID="00012619-05"
/dev/sdb6: UUID="d835e2c0-894f-4165-ab40-4987f20d8945" TYPE="xfs" PARTUUID="00012619-06"
/dev/sdc1: LABEL="NACHTMUSIK" UUID="C34B-694D" TYPE="vfat"
/dev/mmcblk0: PTUUID="a2be4883" PTTYPE="dos"

and here’s /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 uuid 'ba70949d-1f49-4e22-8c5a-d178634abf1'
	option label 'addons'
	option device '/dev/md0'
	option target '/addons'
	option enabled '1'

config mount
	option uuid '90c75b0c-ad42-42f3-aa83-509793ee7025'
	option label 'storage0'
	option device '/dev/sda2'
	option target '/storage/0'
	option enabled '1'

config mount
	option uuid 'd835e2c0-894f-4165-ab40-4987f20d8945'
	option device '/dev/sdb6'
	option target '/storage/1'
	option enabled '1'

Neither /dev/md0 nor /dev/sdb6 mount at boot.

EDIT: Sorry, md0 only turns up in the blkid output if I do an mdadm --assemble --scan:

/dev/md0: LABEL="addons" UUID="ba70949d-1f49-4e22-8c5a-d178634abf14" UUID_SUB="76e639e2-26d7-4802-b6a0-b94aaf8fc4e4" TYPE="btrfs"

If I add this command in /etc/rc.local, the filesystem will indeed automount. However, my LXC containers (which lie on there) will not autostart, presumably because it gets mount after lxc-auto executes.

Oke, to be sure i i took some info from my NAS (Ubuntu-Server).

user@K-NAS:~$ blkid
/dev/sdb1: UUID="f0b03ecf-493f-ff86-db3c-9ce3e930d54b" UUID_SUB="e3680deb-34a2-689b-4432-01002e137355" LABEL="K-NAS:0" TYPE="linux_raid_member" PARTLABEL="disk1" PARTUUID="0c67bb24-27dc-4941-99e7-477efc6b25e0"
/dev/sdc1: UUID="f0b03ecf-493f-ff86-db3c-9ce3e930d54b" UUID_SUB="1150964f-638f-0a9e-2dad-91e4800a6cd7" LABEL="K-NAS:0" TYPE="linux_raid_member" PARTLABEL="disk2" PARTUUID="e716395c-b110-4165-83fa-0c6d7e080da2"
/dev/sdd1: UUID="f0b03ecf-493f-ff86-db3c-9ce3e930d54b" UUID_SUB="10c4513d-426f-87c1-5294-58788bb4be52" LABEL="K-NAS:0" TYPE="linux_raid_member" PARTLABEL="disk3" PARTUUID="ea25bdf0-a9e4-4426-971a-ca3c486a3f94"
/dev/sde1: UUID="f0b03ecf-493f-ff86-db3c-9ce3e930d54b" UUID_SUB="0f7d77fd-ab91-6b18-97e5-95d896c5c43d" LABEL="K-NAS:0" TYPE="linux_raid_member" PARTLABEL="disk4" PARTUUID="6a3a87ea-a4ae-469c-b1e1-6197acfa5582"
/dev/sdf1: UUID="f0b03ecf-493f-ff86-db3c-9ce3e930d54b" UUID_SUB="fad7fe0e-1e3b-e2db-7fe8-4cee98f33696" LABEL="K-NAS:0" TYPE="linux_raid_member" PARTLABEL="disk5" PARTUUID="2c4aec27-f3a2-4a53-90c1-a33a8e853b7d"
/dev/sda1: LABEL="Ubuntu-server" UUID="123d6f95-c8b3-4b28-ab57-3e9780e5b840" TYPE="ext4" PARTUUID="00077cda-01"
/dev/sda2: UUID="3e2f7711-6c5e-4ea0-afd8-5168ed041189" TYPE="swap" PARTUUID="00077cda-02"
/dev/sda3: UUID="65485f7b-62f0-4abb-9d25-5abc66d8814c" TYPE="ext4" PARTUUID="00077cda-03"
/dev/sdg1: LABEL="EXTENDED" UUID="d9ac0bb7-fdd2-45aa-b8e1-8449f2e8e1d1" TYPE="ext4" PARTUUID="a29687b6-01"
/dev/md0: UUID="9b749b58-7793-48dc-a299-49a67a5d60aa" TYPE="ext4"
/dev/sdh1: LABEL="WDS" UUID="c40f885a-80f4-45c1-b20d-ab8fc260c5d4" TYPE="ext4" PARTLABEL="WDS" PARTUUID="be5c8452-1979-4b57-881a-683b1f5f1441"
/dev/sdi1: LABEL="WEBSERVER" UUID="4d6a0dae-23c1-4706-ad1a-9d29854a4914" TYPE="ext4" PARTUUID="164784f0-01"

Here also the fstab file of my NAS.

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda1 during installation
UUID=123d6f95-c8b3-4b28-ab57-3e9780e5b840 /               ext4    noatime,errors=remount-ro 0       1
# swap was on /dev/sda2 during installation
UUID=3e2f7711-6c5e-4ea0-afd8-5168ed041189 none            swap    sw              0       0

#VirtualMachine (part of the SSD - 190 GB)
UUID=65485f7b-62f0-4abb-9d25-5abc66d8814c       /media/VirtualMachine      ext4    noatime,defaults        0       0

#Extended (Western Digital SSHD - 1TB - Sata pci controller)
UUID=d9ac0bb7-fdd2-45aa-b8e1-8449f2e8e1d1       /media/Extended               ext4    defaults                0  0

#RAID6 (5x 2 TB 3.5 HD)
/dev/md0        /media/RAID6    ext4    defaults        0       0

#Webserver (40 GB HD - Sata pci controller)
UUID=4d6a0dae-23c1-4706-ad1a-9d29854a4914       /media/Webserver      ext4    defaults        0       0

#WDS (320 GB HD - USB 3.0 intern)
UUID=c40f885a-80f4-45c1-b20d-ab8fc260c5d4       /media/WDS      ext4    defaults        0       0

#Islam-Seeding (+/- 800 GB - WD Dual Black 2 - USB 3.0 extern)
UUID=40dfa36b-ad9f-4384-b9aa-055a1004b564       /media/Islam-Seeding      ext4    noatime,defaults        0       0

#Domaincontroller (+/- 250 GB - WD Dual Black 2 - USB 3.0 extern)
UUID=54e20a52-4ab9-425b-9cae-007f9a7a7955       /media/Domaincontroller      ext4    noatime,defaults        0       0

OOh i see i’ve used /dev/md0 instead of the UUID. If i remember correctly i left it back then as it is. But you should better use UUID instead. That would be the one like in my blkid the UUID of the md0.

I would advice you to use fstab file instead of the rc.local. 1-2 years from today you will forget how you have configured it …just like how i left md0 instead of using UUID :joy:

The lxc-containers must be configured somewhere else where you also give a certain time to wait until booting. Give in the lxc-auto (/etc/config/lxc-auto) a longer timeout. Maybe that would give it enough time to boot. In my case i use a mSata drive which is kind of fast but your case with RAID, (being 3.5 inch drives 7200RPM, will take considerably longer time to boot. Try to test different timeouts.

BTW, could you post the df -h output. In this output you can definnaly see which is the RAID itself and not the individual members. Your sda1 for example is a RAID member (individual drive).

As you did the mdam scan, there you see the md0. I THINK the UUID you have there you should use. ba70949d-1f49-4e22-8c5a-d178634abf14

As you can see in my case with my NAS.

user@K-NAS:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            7,8G     0  7,8G   0% /dev
tmpfs           1,6G  9,6M  1,6G   1% /run
/dev/sda1        22G  8,7G   13G  42% /
tmpfs           7,8G   12K  7,8G   1% /dev/shm
tmpfs           5,0M     0  5,0M   0% /run/lock
tmpfs           7,8G     0  7,8G   0% /sys/fs/cgroup
/dev/sda3       184G  171G  3,9G  98% /media/VirtualMachine
/dev/sdg1       917G  421G  450G  49% /media/Extended
/dev/sdi1        37G  667M   35G   2% /media/Webserver
/dev/sdh1       294G  279G  314M 100% /media/WDS
/dev/md0        5,5T  1,6T  3,6T  31% /media/RAID6
/dev/sdj1       246G   60M  234G   1% /media/Domaincontroller
/dev/sdj2       781G   54G  688G   8% /media/Islam-Seeding
tmpfs           1,6G     0  1,6G   0% /run/user/116
tmpfs           1,6G     0  1,6G   0% /run/user/1000

That’s what I would advise myself as well. The rc.local is just a workaround for now as long as I can’t get it to mount via fstab.

I have the one lxc-container I want to autostart configured in /etc/config/lxc-auto with a timeout of 60 seconds. IMHO that should be more than enough since I don’t think the whole boot process takes as long, but I’ll give it a try with a longer timeout. However, as long as /addons fails to mount at all, no amount of waiting will be of any help.

Here’s my df -h output:

Filesystem                Size      Used Available Use% Mounted on
/dev/mmcblk0p1            7.3G    315.5M      7.0G   4% /
tmpfs                  1011.1M      3.5M   1007.6M   0% /tmp
tmpfs                   512.0K         0    512.0K   0% /dev
/dev/sda2                 1.7T     43.3G      1.7T   2% /storage/0
/dev/sdc1               119.2G     14.3G    105.0G  12% /tmp/run/mountd/sdc1
/dev/sdb1                10.9G      8.0G      2.3G  78% /tmp/run/mountd/sdb1
/dev/md0                 99.9G     13.9G     85.0G  14% /addons
/dev/sdb6               919.3G    913.6G      5.7G  99% /storage/1

Well, that’s the UUID I have used in the fstab file posted above, isn’t it. So far, with limited success. Any thoughts on the XFS volume?

Take a look at your own fstab file again :joy: the 4 at the end of the line is still sleeping in his bed. If i were you i would fire him for not showing up for work.

Well all the same for mounting, but to mount xfs file…i BELIEVE kmod-fs-xfs should have been installed to be able to use xfs. (Not sure myself, just googled it quickly).

If you have replaced the 4 with a more reliable 4 and the RAID is working let me know. Also let me know about the xfs.

1 Like

Thanks for pointing that out! That’s what you get for believing too much in copy&paste and only eyeballing the results for correctness.

The 4 is now back at work:

config mount
	option uuid 'ba70949d-1f49-4e22-8c5a-d178634abf14'
	option label 'addons'
	option device '/dev/md0'
	option target '/addons'
	option enabled '1'

Unfortunately, the FS still fails to mount at boot and doesn’t show up in blkid output unless I do the mdadm scan first.

kmod-fs-xfs is installed:

root@router:~# opkg list-installed|grep xfs
kmod-fs-xfs - 4.4.113+1-1-1e4a549d177ab3da12b2052fba6a4dd5-1
xfs-fsck - 3.1.7-1
xfs-growfs - 3.1.7-1
xfs-mkfs - 3.1.7-1

I guess, otherwise I wouldn’t be able to mount the XFS FS at all.

Could you give a proper target. ie /mnt/addons. Look at my fstab file for example, you see a /mnt/LXC and /mnt/majordomo.

Root directory of Turris-OS does NOT contain any “addons” folder. So that could also be the problem for not mounting. In the mount folder create a directory if you haven’t called “addons”. So you now would have a proper directory structure called /mnt/addons to mount the RAID to. If it still does not work, try to leave the UUID out. Only use device being (/dev/md0)

In case of your xfs, do the same. Give a proper directory structure and let me know how things now have turned out.

Btw, i am not sure but it could be that you have no write permissions. I am not sure if the same command could be applied to Turris-OS/openwrt command being.

If it is being mounted, do FIRST check if you have READ/WRITE permissions. If you do, then do not execute the command.

chown -R root:root /mnt/addons

Why should I? /addons exists as a directory (created by me) and as such is as valid as a mountpoint as any other directory. Linux doesn’t make any distinctions there. Also, /storage/0 and /storage/1 are equally valid mount points, shown also by the fact that sda2 automounts to /storage/0 without any issues.

I also don’t have any permission issues.

I’ll give your suggestion of just giving the device names in fstab a try though and report back.

Here’s how the entries look now in my fstab:

config mount
	option device '/dev/md0'
	option target '/addons'
	option enabled '1'

config mount
	option device '/dev/sdb6'
	option target '/storage/1'
	option enabled '1'

Still no automount.

Bro, there are two approaches. One is not working, you either try the second/different approach or stick to what you are doing…which is not working (your current situation).

I have a working situation and i am offering you that, which MIGHT give the solution. You can either try it, or don’t. The other reason i also advice what i advice in this case of giving proper directory structure in your fstab file…is this

https://wiki.openwrt.org/doc/howto/storage

There at “Mounting”, you can clearly see the same approach as i am advising you to do.

So the choice is yours. openwrt is way different than other Linux distro’s, from many directory structures to even basic things like the fstab. Since when is there a “option this” or “option that” in normal fstab file you use in a Linux distro’s? It for example is very possible that mounting in openwrt does not support any directory OUTSIDE /mnt/.

Your sdb6(xfs mount if i am correct), also is having the SAME problem of not mounting.

One is showing in blkid one is not. sdb6 at least is showing in your blkid, but has something in common with md0…which is the directory structure given in the fstab. Try use /mnt/storage or at least a NAME not a number.

Troubleshooting is all about trying things out, if one thing does not work…you try something else and the things that i point out are not without valid argumentation.

So put UUID back and give the proper directory structure as i was advising you and openwrt wiki pointing it also.

Diretory /dev is tmpfs mounted also in starting router, so it is clear and only in RAM.

I do sincereley appreciate your help and I will give your suggestion a try – although I’m still convinced that neither the name of the mount point nor its place in the file system hierarchy will make any difference.

So here’s my 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 uuid 'ba70949d-1f49-4e22-8c5a-d178634abf14'
	option label 'addons'
	option device '/dev/md0'
	option target '/mnt/addons'
	option enabled '1'

config mount
	option uuid '90c75b0c-ad42-42f3-aa83-509793ee7025'
	option label 'storage0'
	option device '/dev/sda2'
	option target '/storage/0'
	option enabled '1'

config mount
	option uuid 'd835e2c0-894f-4165-ab40-4987f20d8945'
	option device '/dev/sdb6'
	option target '/mnt/storage1'
	option enabled '1'

and here are the mount points:

root@router:~# ls -l /mnt/
drwxr-xr-x    1 root     root             0 Mar  5 16:48 addons
drwxr-xr-x    1 root     root             0 Mar  5 16:48 storage1

I’ll be offline shortly for reboot and report back afterwards.

Here’s what the situation looks like after reboot:

root@router:~# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/mmcblk0p1         7633920    330880   7306116   4% /
tmpfs                  1035372      1064   1034308   0% /tmp
tmpfs                      512         0       512   0% /dev
/dev/sda2            1848655940  45383008 1801311104   2% /storage/0
/dev/sdc1            125012128  14960096 110052032  12% /tmp/run/mountd/sdc1
/dev/sdb1             11404272   8390836   2427468  78% /tmp/run/mountd/sdb1

So, still, sda2 automounts fine while neither sdb6 nor md0 do.

I’m open to other suggestions.

Btw you have tried to mount manually already? And that does work fine?

Also could you leave out device and only use UUID. I know logically I would agree that there is a high possibility nothing would change but in the 15 years that I am In IT nothing catches me off guard anymore. Everything and anything is possible.

Manual mounting has always worked without problems. Sorry if I didn’t make that sufficiently clear.

I’ll experiment a little tomorrow with using only UUID although I don’t have high hopes for that.

Oke, so manually mounting works for both. /etc/rc.local works as well, which leaves out that the problem lies with fstab file or automounting. . I would then say it leaves nothing but to report it as a bug and for the time being for yourself make a comment in the fstab file as a reminder how you are auto-mounting the raid and the xfs.

Then start using the workaround (/etc/rc.local) until something is done to this bug.

1 Like