Romulo Ceccon建议使用Upstart脚本的想法很棒。但是,您可能不想将魔术隐藏在晦涩的脚本中。可以在fstab中添加安装,例如
LABEL=cloudimg-rootfs / ext4 defaults 0 0
# auto mount ephemeral storage (if any)
# init contents in /etc/init/mounted-local*.conf
/dev/xvdb /mnt/local1 auto defaults,nofail,nobootwait,comment=cloudconfig 0 2
/dev/xvdc /mnt/local2 auto defaults,nofail,nobootwait,comment=cloudconfig 0 2
/dev/xvdd /mnt/local3 auto defaults,nofail,nobootwait,comment=cloudconfig 0 2
/dev/xvde /mnt/local4 auto defaults,nofail,nobootwait,comment=cloudconfig 0 2
# bind /tmp to /mnt/local1, might still be on / if no ephemeral storage
/mnt/local1 /tmp none bind
这是Upstart脚本:
# File /etc/init/mounted-local1.conf
# mounted-local1 - init ephemeral storage in /mnt/local1
description "Initializes ephemeral storage in /mnt/local1"
start on mounted MOUNTPOINT=/mnt/local1
# provide defult, see /etc/init/mounted-tmp.conf for details
env MOUNTPOINT=/mnt/local1
task
script
# fix permissions if needed
test -d $MOUNTPOINT && chmod 1777 $MOUNTPOINT
# log to /var/log/upstart/mounted-local1.log
#echo "initialized $MOUNTPOINT"
end script
这样,您可以创建任何目录结构,而不创建临时存储。
剩下的就是mkdir -p /mnt/local{1..4}
重新启动(如果没有,我不会挂载/ tmp,因为您会将当前文件隐藏在那里)。
touch
和提供一个预期输出的示例ls -l
吗?