One of hard drives are not visible from /etc/rc.local

My assumption is that all drives from /etc/fstab are mounted before /etc/rc.local is executed ony my RPI2.

My /etc/fstab looks like the following:

UUID=70BCEC34BCEBF310   /mnt/wde4tb     ntfs    rw,nosuid,nodev,relatime,uid=1000,gid=113,permissions,umask=007,nofail        0       0
UUID=74A6-7F41          /mnt/sd64gb     vfat    defaults,nofail                                                               0       0
UUID=2efde1bd-42b1-428e-a76d-5910d62a0e9a /mnt/ks32gb ext4 defaults,nofail 0 0

If I run this command from the shell I get proper response:

osmc@osmc:~$ sudo hdparm -S 241 $(mount | grep wde4tb | awk 
'{print $1}')

/dev/sda1:
 setting standby to 241 (30 minutes)

I have put the same command in /etc/rc.local (without sudo) but looks like it is not executing upon reboot.

In order to check what is going on I have put some diagnostic in the /etc/rc.local file:

sleep 10

echo "start" > /home/osmc/rc.local.output
echo '-----mount-----' >> /home/osmc/rc.local.output
mount >> /home/osmc/rc.local.output
echo '-----mount grep-----' >> /home/osmc/rc.local.output
mount | grep wde4tb >> /home/osmc/rc.local.output
echo '-----mount grep awk-----' >> /home/osmc/rc.local.output
mount | grep wde4tb | awk '{print $1}' >> /home/osmc/rc.local.output
echo '-----hdparm-----' >> /home/osmc/rc.local.output
hdparm -S 241 $(mount | grep wde4tb | awk '{print $1}') >> /home/osmc/rc.local.output
echo "end" >> /home/osmc/rc.local.output

After rebooting the /home/osmc/rc.local.output looks like the following:

start
-----mount-----
devtmpfs on /dev type devtmpfs (rw,relatime,size=370540k,nr_inodes=92635,mode=755)
proc on /proc type proc (rw,relatime)
sysfs on /sys type sysfs (rw,relatime)
tmpfs on /run type tmpfs (rw,relatime)
/dev/mmcblk0p2 on / type ext4 (rw,noatime,stripe=1024,data=ordered)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpu,cpuacct)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
cgroup on /sys/fs/cgroup/net_cls type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=23,pgrp=1,timeout=300,minproto=5,maxproto=5,direct)
mqueue on /dev/mqueue type mqueue (rw,relatime)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
configfs on /sys/kernel/config type configfs (rw,relatime)
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
/dev/mmcblk0p1 on /boot type vfat (rw,noatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,errors=remount-ro)
/dev/sdb1 on /mnt/ks32gb type ext4 (rw,relatime,data=ordered)
/dev/sdc1 on /mnt/sd64gb type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,errors=remount-ro)
sysfs on /sys/devices/system/cpu/cpufreq/policy0/scaling_cur_freq type sysfs (rw,relatime)
-----mount grep-----

As you can see there is ks32gb and sd64gb from fstab, but there is no wde4tb (sda1) drive.

After boot process is completed, mount shows the wde4tb drive:

osmc@osmc:~$ mount
devtmpfs on /dev type devtmpfs (rw,relatime,size=370540k,nr_inodes=92635,mode=755)
proc on /proc type proc (rw,relatime)
sysfs on /sys type sysfs (rw,relatime)
tmpfs on /run type tmpfs (rw,relatime)
/dev/mmcblk0p2 on / type ext4 (rw,noatime,stripe=1024,data=ordered)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpu,cpuacct)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
cgroup on /sys/fs/cgroup/net_cls type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=23,pgrp=1,timeout=300,minproto=5,maxproto=5,direct)
mqueue on /dev/mqueue type mqueue (rw,relatime)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
configfs on /sys/kernel/config type configfs (rw,relatime)
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
/dev/mmcblk0p1 on /boot type vfat (rw,noatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,errors=remount-ro)
/dev/sdb1 on /mnt/ks32gb type ext4 (rw,relatime,data=ordered)
/dev/sdc1 on /mnt/sd64gb type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,errors=remount-ro)
sysfs on /sys/devices/system/cpu/cpufreq/policy0/scaling_cur_freq type sysfs (rw,relatime)
/dev/sda1 on /mnt/wde4tb type fuseblk (rw,nosuid,nodev,relatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096)
tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,size=75108k,mode=700,uid=1000,gid=1000)

Can someone explain to me why I can’t see wde4tb mounted from rc.local but I can see other drives?

My wildest guess would be because of the fact that your sda is a mechanical drive it takes longer to spin up and therefore the partitions are not ready mounted at that moment.

I thought that 10 seconds (sleep) will be enough, but I will try with 60 seconds and than report back.

I tried with sleep 60 seconds and… it worked. :slightly_smiling:
Thank you very very much Fzinken.
Best regards.

I suspect your real problem is that you do not have the correct mount options to automatically mount your drives from fstab - I don’t see x-systemd.automount in your mount options…

What this means is that systemd will not automatically mount your drive, and much later during boot udisks-glue - which is the automounter we use that automatically mounts removable drives on the fly, will discover the disk and mount it for you.

Normally udisks-glue will mount removable drives dynamically under /media, however if it finds a matching entry in /etc/fstab (whether or not that entry is configured properly to auto mount) it will mount it in the location you specified there.

The easiest way to tell would be to search for udisks-glue in the system journal - if you see entries saying that is mounting your drive it means you have got your fstab mount options wrong.

rc.local will not wait for udisks-glue to mount drives, hence why they are not mounted at the time it runs.

In /etc/fstab I have replaced:

UUID=70BCEC34BCEBF310 /mnt/wde4tb ntfs rw,nosuid,nodev,relatime,uid=1000,gid=113,permissions,umask=007,nofail 0 0

with

UUID=70BCEC34BCEBF310   /mnt/wde4tb     ntfs    rw,nosuid,nodev,relatime,uid=1000,gid=113,permissions,umask=007,nofail,x-systemd.automount        0       0

Aftewards, I have removed sleep from /etc/rc.local

Now /home/osmc/rc.local.output looks like the following

osmc@osmc:~$ cat rc.local.output
start
-----mount-----
devtmpfs on /dev type devtmpfs (rw,relatime,size=370540k,nr_inodes=92635,mode=755)
proc on /proc type proc (rw,relatime)
sysfs on /sys type sysfs (rw,relatime)
tmpfs on /run type tmpfs (rw,relatime)
/dev/mmcblk0p2 on / type ext4 (rw,noatime,stripe=1024,data=ordered)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpu,cpuacct)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
cgroup on /sys/fs/cgroup/net_cls type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=23,pgrp=1,timeout=300,minproto=5,maxproto=5,direct)
systemd-1 on /mnt/wde4tb type autofs (rw,relatime,fd=24,pgrp=1,timeout=300,minproto=5,maxproto=5,direct)
mqueue on /dev/mqueue type mqueue (rw,relatime)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
configfs on /sys/kernel/config type configfs (rw,relatime)
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
/dev/mmcblk0p1 on /boot type vfat (rw,noatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,errors=remount-ro)
/dev/sdc1 on /mnt/sd64gb type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,errors=remount-ro)
/dev/sdb1 on /mnt/ks32gb type ext4 (rw,relatime,data=ordered)
sysfs on /sys/devices/system/cpu/cpufreq/policy0/scaling_cur_freq type sysfs (rw,relatime)
-----mount grep-----
systemd-1 on /mnt/wde4tb type autofs (rw,relatime,fd=24,pgrp=1,timeout=300,minproto=5,maxproto=5,direct)
-----mount grep awk-----
systemd-1
-----hdparm-----
osmc@osmc:~$

As I can see from rc.local device is systemd-1 instead of /dev/sda1

After boot process is completed mount shows the drive as:

/dev/sda1 on /mnt/wde4tb type fuseblk (rw,nosuid,nodev,relatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096)

Looks like it is better to have sleep 60 in rc.local and no x-systemd.automount in fstab.

Without a log file we can only speculate about the true cause of your problem.

Which log you are aiming at?

The system journal.

@kriticar you can easily produce that with
grab-logs -J