3

I'm trying to do the same of this question (multiple linux installation on same filesystem) but I get this result (root filesystem mounted as read-only) . I'm using debian/sid, have successfully modified the initrd /init script and patched the busybox switch_root to chroot into a subdirectory, the filesystem is ext4. The kernel boot but the filesystem is mounted read-only and any variant of mount -o rw,remount fail.

I just guess (not investigated yet) the mount command is unable to resolve the new root / with the old /mountpoint.

Mounting the filesystem as read-write before chrooting (as the second link suggest) is just a ugly workaround, I would like to know if there's a better way do remount rw properly from within the chroot.

Alex
  • 2,546
  • 3
  • 20
  • 30
  • AFAIK it is impossible to change a mount without access to the mountpoint location, hence the definition of chroot "jail". If the chroot installation was on it's own filesystem you might have more success. – Didi Kohen Mar 19 '13 at 07:04
  • Thank you David, the installation on it's own fs isn't the way installation are done by default? Shouldn't always work? Currently my major change is to chroot into a subdirectory instead of the "root" mountpoint. – Alex Mar 19 '13 at 12:40
  • If you chroot to a non mountpoint directory, you will not be able to modify the mount option since the chrooted environment needs access to the mountpoint (which is above it's root, hence it's inaccessible). The directory you chroot to needs to be a mountpoint... – Didi Kohen Mar 23 '13 at 11:10
  • I hoped there was some bind solution but on read-only seem there's not. I'm evaluating 2 solutions: 1. forking a script with a fifo in the initrd /init and wrapping the dist mount to intercept remount of / (but is a lot of overhead); 2. using loop volumes supported out of the box – Alex Mar 25 '13 at 12:27
  • Why not just move the data to a new partition? – Didi Kohen Mar 25 '13 at 13:09
  • I just would like to try different installation without need a partition for every one – Alex Mar 25 '13 at 13:52
  • Loop volumes should be simplest to use in this case, you can also use LVM if it's the hassle of partitioning you are looking to avoid. – Didi Kohen Mar 27 '13 at 05:59
  • Got the loop working already, been not `out of the box` as expected but still faster and easier than other solutions. I never been a fan of LVM and for my few knowledge about it does the reverse of my need, merge multiple volumes into one file system, maybe I'm wrong :) – Alex Mar 27 '13 at 11:53
  • [here how I've done](http://unix.stackexchange.com/a/69321/34446) – Alex Mar 27 '13 at 13:11
  • About the original question here, about remounting from within chroot, given that chroot isn't secure and its purpose isn't security, given also that root user should be able to do almost anything, I hope mount/remount behavior will change in future allowing things like booting subdirectories an easy task. – Alex Mar 27 '13 at 13:47
  • 1
    LVM is usually used to merge large disks, but it's purpose is both to merge large disks and to split disks to smaller volumes than what the traditional partitioning enables. – Didi Kohen Mar 28 '13 at 07:41
  • Thank you David I didn't know about this feature (took a look), probably lvm is supported out of the box by all major distro, would add some setup but no customizations. – Alex Mar 28 '13 at 11:46

0 Answers0