![初始化引导挂载:在 /root.ro 上安装 /root 失败:参数无效,aufs](https://linux22.com/image/140086/%E5%88%9D%E5%A7%8B%E5%8C%96%E5%BC%95%E5%AF%BC%E6%8C%82%E8%BD%BD%EF%BC%9A%E5%9C%A8%20%2Froot.ro%20%E4%B8%8A%E5%AE%89%E8%A3%85%20%2Froot%20%E5%A4%B1%E8%B4%A5%EF%BC%9A%E5%8F%82%E6%95%B0%E6%97%A0%E6%95%88%EF%BC%8Caufs.png)
/root
我正在尝试在嵌入式设备上的目录中设置只读文件系统。我的 boot init 命令文件中有以下代码/sbin/init-overlay
:
rootmnt=/root
ro_mount_point="${rootmnt%/}.ro"
rw_mount_point="${rootmnt%/}.rw"
# For local system rearranged from init
/bin/mkdir -p "${ro_mount_point}" "${rw_mount_point}"
# Move the already-mounted root filesystem to the ro mount point:
/bin/mount --move ${rootmnt} ${ro_mount_point}
# Mount the read/write filesystem:
/bin/mount -t tmpfs root.rw "${rw_mount_point}"
# Mount the union:
/bin/mount -t aufs -o dirs=${rw_mount_point}=rw:${ro_mount_point}=ro aufs ${rootmnt}
# Correct the permissions of /:
/bin/chmod 755 "${rootmnt}"
# Make sure the individual ro and rw mounts are accessible from within the root
# once the union is assumed as /. This makes it possible to access the
# component filesystems individually.
/bin/mkdir "${rootmnt}/ro" "${rootmnt}/rw"
/bin/mount --bind "${ro_mount_point}" "${rootmnt}/ro"
/bin/mount --bind "${rw_mount_point}" "${rootmnt}/rw"
这是我的启动命令:
console=ttyS0,115200 earlyprintk root=/dev/mmcblk0p2 rootfstype=ext4 rootwait fsck.repair=${fsck.repair} panic=10 ${extra} fbcon=${fbcon} rw init=/sbin/init-overlay
但是在启动时,我收到以下错误:
mount: mounting /root on /root.ro failed: Invalid argument
谁能指出这里出了什么问题吗?
答案1
对于“无效参数”失败的最可能的解释mount --move
是源本身不是安装点。如果${rootmnt}
不是挂载点,您有两种选择:要么正确地将其设置为挂载点,要么使用mount --bind "${rootmnt}" "${rootmnt}"
.