我在/ etc / fstab中有这一行:
/mnt/tmp /tmp none bind,nobootwait
然而,在EC2上,/ mnt在重新启动时可能会丢失,导致挂载由于不存在/ mnt / tmp而失败。 那么有没有办法显式创build这个目录?
你可以在你的/etc/rc.local文件中放入以下行:
mkdir -p /mnt/tmp && mount --bind -o nobootwait /mnt/tmp /tmp
负责从fstab挂载目录的脚本是/etc/init.d/mountall.sh 。 您可以在mount -a行之前添加mkdir -p /mnt/tmp 。 它位于mount_all_local()函数中。
在添加mkdir命令后,这是我的mountall.sh脚本:
mount_all_local() { mkdir -p /mnt/tmp; mount -a -t nonfs,nfs4,smbfs,cifs,ncp,ncpfs,coda,ocfs2,gfs,gfs2,ceph \ -O no_netdev }