Create directory before binding via /etc/fstab

7,965

Solution 1

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

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

Solution 2

The script responsible for mounting directories from fstab is /etc/init.d/mountall.sh. You can add mkdir -p /mnt/tmp just before the mount -a line. It is located in mount_all_local() function.

This is my mountall.sh script after adding the mkdir command:

mount_all_local() {
    mkdir -p /mnt/tmp;
    mount -a -t nonfs,nfs4,smbfs,cifs,ncp,ncpfs,coda,ocfs2,gfs,gfs2,ceph \
        -O no_netdev
}
Share:
7,965

Related videos on Youtube

sfussenegger
Author by

sfussenegger

Updated on September 18, 2022

Comments

  • sfussenegger
    sfussenegger over 1 year

    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?

  • wfaulk
    wfaulk about 12 years
    Does rc.local really get run before filesystems are mounted?
  • Razique
    Razique almost 12 years
    No you are right, but he can remove the fstab entries, no ?