Friday, 31 October 2014

fstab mount bind error - SOLVED and EXPLAINED!

In case that you are using mount --bind option for something(in my case this was a must for sftp user action logs), you want this mount --bind survive reboot. So you will put this mount point in /etc/fstab.
First I mount it "by hand"

server:#mount --binb /dev/log /opt/sftp_test/boris/dev/log

This worked so I need it put make it mount automaticly after reboot.  
My fstab options was like this

/dev/log  /opt/sftp_test/boris/dev/log    none    bind

So, I test it if this works!
"False" test pass. Why I called it false test? I umount /opt/sftp_test/boris/dev/log and automaticly mounted it.

server:#umount /opt/sftp_test/boris/dev/log
server:#mount -a
server:#mount
/dev/mapper/ubuntu-root on / type ext4 (rw,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
none on /sys/fs/fuse/connections type fusectl (rw)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
udev on /dev type devtmpfs (rw,mode=0755)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
tmpfs on /run type tmpfs (rw,noexec,nosuid,size=10%,mode=0755)
none on /run/lock type tmpfs (rw,noexec,nosuid,nodev,size=5242880)
none on /run/shm type tmpfs (rw,nosuid,nodev)
/dev/sda1 on /boot type ext2 (rw)
rpc_pipefs on /run/rpc_pipefs type rpc_pipefs (rw)
/dev/log on /opt/sftp_test/boris/dev/log type none (rw,bind) 

 

Fstab mount bind error

Ok, now only true and real test! Reboot! As I was waiting for ping to start again so that I can ssh log to my test server, think that nothing can go wrong... Ping started to pass but I could not ssh connect. Ok,ssh service did not started yet.10 seconds, 20 seconds, 30 seconds... Ok, now I know that something is wrong! I looked at my VirtualBox server and there is was black stale screen.
fstab mount bind error solved explained
Error was:
The disk drive for /opt/sftp_test/boris/dev/log is not ready yet or not present.
So I just pressed S and boot process continued. This is why reboot is real test! :)
What can be reason for this? I suspect that reason is that mounting partitions from fstab is one of the first thing that OS during boot process do. There is still no /dev/log location at this point. Error message The disk drive for...  is pretty clear.
How to resolve this? In /etc/rc.local insert following line

mount --bind /dev/log /opt/sftp_test/boris/dev/log

Reboot!!!
root@ubuntu:/opt/sftp_test/boris/dev# reboot
root@ubuntu:/opt/sftp_test/boris/dev#
Broadcast message from root@ubuntu
        (/dev/pts/0) at 12:53 ...

The system is going down for reboot NOW!
login as: root
root@x.x.x.x's password:
Welcome to Ubuntu 12.04.4 LTS (GNU/Linux 3.5.0-23-generic i686)
Last login: Fri Oct 31 12:47:43 2014 from .x.x.x.x
root@ubuntu:~# mount
/dev/mapper/ubuntu-root on / type ext4 (rw,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
none on /sys/fs/fuse/connections type fusectl (rw)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
udev on /dev type devtmpfs (rw,mode=0755)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
tmpfs on /run type tmpfs (rw,noexec,nosuid,size=10%,mode=0755)
none on /run/lock type tmpfs (rw,noexec,nosuid,nodev,size=5242880)
none on /run/shm type tmpfs (rw,nosuid,nodev)
/dev/sda1 on /boot type ext2 (rw)
rpc_pipefs on /run/rpc_pipefs type rpc_pipefs (rw)
/dev/log on /opt/sftp_test/boris/dev/log type none (rw,bind)

Problem solved!

No comments: