初始化引导挂载:在 /root.ro 上安装 /root 失败:参数无效,aufs

初始化引导挂载:在 /root.ro 上安装 /root 失败:参数无效,aufs

/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}".

相关内容