skeleton: Have a portable remount RW/RO
PATCH v2 1/1 skeleton: Have a portable remount RW/RO
With systemd, inittab is useless, but it's also where we stored a 'mount -o remount ...' to toggle the rootfs ro/rw at the demand of the user.
Instead, doing a simple 'mount -a -o remount' should change the flag of every mountpoint by reading /etc/fstab.
Therefore, we now modify /etc/fstab, which happens to be read by systemd also and so, everyone benefits.
---
v1 -> v2:
- Rebase on current master ('null' was removed from inittab)
- 'Rework' sed expression (add quote, remove curly braces, remove useless escape of comma)
--- package/busybox/inittab | 3 +-- package/skeleton/skeleton.mk | 8 ++++---- package/sysvinit/inittab | 3 +-- 3 files changed, 6 insertions(+), 8 deletions(-)
package/busybox/inittab +1 -2
@@ -15,10 +15,9 @@ # Startup the system ::sysinit:/bin/mount -t proc proc /proc -::sysinit:/bin/mount -o remount,rw / ::sysinit:/bin/mkdir -p /dev/pts ::sysinit:/bin/mkdir -p /dev/shm -::sysinit:/bin/mount -a +::sysinit:/bin/mount -a -o remount ::sysinit:/bin/hostname -F /etc/hostname # now run any rc scripts ::sysinit:/etc/init.d/rcS
package/skeleton/skeleton.mk +4 -4
@@ -142,14 +142,14 @@ endif ifeq ($(BR2_INIT_BUSYBOX)$(BR2_INIT_SYSV),y) ifeq ($(BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW),y) -# Find commented line, if any, and remove leading '#'s +# Find 'ro,' (avoid 'root') in the first line and change it to 'rw,' define SKELETON_SYSTEM_REMOUNT_RW - $(SED) '/^#.*-o remount,rw \/$$/s~^#\+~~' $(TARGET_DIR)/etc/inittab + $(SED) '0,/ro,/s/ro,/rw,/' $(TARGET_DIR)/etc/fstab endef else -# Find uncommented line, if any, and add a leading '#' +# Find rw on the first line and change it to ro define SKELETON_SYSTEM_REMOUNT_RW - $(SED) '/^[^#].*-o remount,rw \/$$/s~^~#~' $(TARGET_DIR)/etc/inittab + $(SED) '0,/rw/s/rw/ro/' $(TARGET_DIR)/etc/fstab endef endif TARGET_FINALIZE_HOOKS += SKELETON_SYSTEM_REMOUNT_RW
package/sysvinit/inittab +1 -2
@@ -5,10 +5,9 @@ id:3:initdefault: si0::sysinit:/bin/mount -t proc proc /proc -si1::sysinit:/bin/mount -o remount,rw / si2::sysinit:/bin/mkdir -p /dev/pts si3::sysinit:/bin/mkdir -p /dev/shm -si4::sysinit:/bin/mount -a +si4::sysinit:/bin/mount -a -o remount si5::sysinit:/bin/hostname -F /etc/hostname si6::sysinit:/etc/init.d/rcS
Signature · 1 line
2.5.3
PATCH v2 1/1 skeleton: Have a portable remount RW/RO
Dear Maxime,
sorry for having kind of endorsed this patch in its v1, but now I tested it and it seems flawed in its very core (unless I'm still drunk).
Quoted 5 lines · Maxime Hadjinlian
With systemd, inittab is useless, but it's also where we stored a 'mount -o remount ...' to toggle the rootfs ro/rw at the demand of the user.
Instead, doing a simple 'mount -a -o remount' should change the flag of every mountpoint by reading
/etc/fstab.
Maybe it should, but it doesn't:
# cat /etc/fstab # <file system> <mount pt> <type> <options> <dump> <pass> /dev/root / ext2 rw,noauto 0 1 proc /proc proc defaults 0 0 devpts /dev/pts devpts defaults,gid=5,mode=620 0 0 tmpfs /dev/shm tmpfs mode=0777 0 0 tmpfs /tmp tmpfs mode=1777 0 0 tmpfs /run tmpfs mode=0755,nosuid,nodev 0 0 sysfs /sys sysfs defaults 0 0 # mount /dev/root on / type ext2 (ro,relatime,errors=remount-ro) devtmpfs on /dev type devtmpfs (rw,relatime,size=62812k,nr_inodes=15703,mode=755) proc on /proc type proc (rw,relatime) # /bin/mount -a -o remount # mount /dev/root on / type ext2 (ro,relatime,errors=remount-ro) devtmpfs on /dev type devtmpfs (rw,relatime,size=62812k,nr_inodes=15703,mode=755) proc on /proc type proc (rw,relatime) #
It's still mounted ro. Removing the noauto for /dev/root/ does not change the result.
This is using the default mount from busybox on qemu_arm_versatile_defconfig with an external toolchain. Wild guess: are you using the full-featured mount command from util-linux? Or maybe systemd ships it own mount command with this feature?
Signature · 1 line
Luca
PATCH v2 1/1 skeleton: Have a portable remount RW/RO
Hi Luca,
Quoted 38 lines · Luca Ceresoli
Dear Maxime,
sorry for having kind of endorsed this patch in its v1, but now I tested it and it seems flawed in its very core (unless I'm still drunk).
Quoted 6 lines · Maxime Hadjinlian
With systemd, inittab is useless, but it's also where we stored a 'mount -o remount ...' to toggle the rootfs ro/rw at the demand of the user.
Instead, doing a simple 'mount -a -o remount' should change the flag of every mountpoint by reading
/etc/fstab.Maybe it should, but it doesn't:
# cat /etc/fstab # <file system> <mount pt> <type> <options> <dump> <pass> /dev/root / ext2 rw,noauto 0 1 proc /proc proc defaults 0 0 devpts /dev/pts devpts defaults,gid=5,mode=620 0 0 tmpfs /dev/shm tmpfs mode=0777 0 0 tmpfs /tmp tmpfs mode=1777 0 0 tmpfs /run tmpfs mode=0755,nosuid,nodev 0 0 sysfs /sys sysfs defaults 0 0 # mount /dev/root on / type ext2 (ro,relatime,errors=remount-ro) devtmpfs on /dev type devtmpfs (rw,relatime,size=62812k,nr_inodes=15703,mode=755) proc on /proc type proc (rw,relatime) # /bin/mount -a -o remount # mount /dev/root on / type ext2 (ro,relatime,errors=remount-ro) devtmpfs on /dev type devtmpfs (rw,relatime,size=62812k,nr_inodes=15703,mode=755) proc on /proc type proc (rw,relatime) #
Quoted 8 lines
It's still mounted ro. Removing the noauto for
/dev/root/does not change the result.This is using the default mount from busybox on
qemu_arm_versatile_defconfigwith an external toolchain. Wild guess: are you using the full-featured mount command from util-linux? Or maybe systemd ships it own mount command with this feature?
I'll test this on my side, I remember it worked (I created this patch during the Buildroot Summer Camp and had not sent it yet, but I clearly remember having testing it), as you said, maybe I was util the full blown mount, I'll test and respin. I'll mark this as "Changes Requested" for the moment.
Quoted 5 lines
--
Luca
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20151008/9b9602b6/attachment.html>