在通过 /etc/fstab 绑定之前创建目录

sfu*_*ger 6 ubuntu mount fstab amazon-ec2

我的 /etc/fstab 中有这一行:

/mnt/tmp    /tmp    none    bind,nobootwait
Run Code Online (Sandbox Code Playgroud)

然而,在 EC2 上,/mnt 可能会在重新启动期间丢失,导致由于不存在的 /mnt/tmp 而导致挂载失败。那么有没有办法显式创建这个目录?

Raz*_*que 3

您可以将以下几行放入 /etc/rc.local 文件中:

mkdir -p /mnt/tmp && mount --bind -o nobootwait /mnt/tmp /tmp 
Run Code Online (Sandbox Code Playgroud)

  • rc.local 真的在安装文件系统之前运行吗? (2认同)