Ubuntu – Create directory before binding via /etc/fstab

amazon ec2fstabmountUbuntu

I have this line in my /etc/fstab:

/mnt/tmp    /tmp    none    bind,nobootwait

On EC2 however, /mnt may be lost during restarts causing the mount to fail due to non existent /mnt/tmp. So is there a way to explicitly create this directory?

Best Answer

you can make put the following lines in your /etc/rc.local file :

mkdir -p /mnt/tmp && mount --bind -o nobootwait /mnt/tmp /tmp