2

I am trying to set up a read-only filesystem at /root directory on my embedded device. I have following in code in my boot init command file /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"

This is my boot command:

console=ttyS0,115200 earlyprintk root=/dev/mmcblk0p2 rootfstype=ext4 rootwait fsck.repair=${fsck.repair} panic=10 ${extra} fbcon=${fbcon} rw init=/sbin/init-overlay

But while booting, I am getting the following error:

mount: mounting /root on /root.ro failed: Invalid argument

Can anyone point-out what's wrong here?

1 Answer 1

0

The most likely explanation for a mount --move failing with "Invalid argument" is that the source isn't a mount point itself. If ${rootmnt} isn't a mount point, you have two choices: either properly make it one, or fake it with mount --bind "${rootmnt}" "${rootmnt}".

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .