Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overlayfs as root filesystem #62

Closed
chrisnharvey opened this issue May 14, 2015 · 4 comments
Closed

Overlayfs as root filesystem #62

chrisnharvey opened this issue May 14, 2015 · 4 comments

Comments

@chrisnharvey
Copy link

Hi,

I'm currently building a distro for my personal needs which runs on my HDD from a live Fedora ISO. But I'd like to make the filesystem writeable using overlayfs. I'm using https://github.com/probonopd/SystemImageKit which is doing exactly what I want, except persisting data on the same partition.

So what I need to do is boot from the ISO on the HDD, this is working fine using SystemImageKit. I then need to use dracut to mount the root filesystem as an overlayfs of the live ISO's root filesystem and a directory on my HDD.

Essentially what I need to do is the following in the initramfs

mount --move / /os
mount <isodevice> /system
mount -t overlayfs -o lowerdir=/os,upperdir=/system/data overlayfs /

I'm just having trouble moving the root filesystem to another mount point. Then I can mount the HDD as read/write under /system then mount the root filesystem as an overlayfs of /os (original ISO root filesystem) and /system/data (a real directory on the HDD which sits alongside /boot).

In theory this should work if I can move the root filesystem.

I've tried this from the terminal my mounting the HDD under /mnt then running:

mount -t overlayfs -o lowerdir=/,upperdir=/mnt/data overlayfs /test

Then all my files are then stored in /mnt/data, and are merged with the root filesystem under the /test mount point, which is exactly what I need, but on the root filesystem.

I just need a way to get this same functionality working but under the root mount point instead of /test.

@haraldh
Copy link
Collaborator

haraldh commented May 15, 2015

you could remount /sysroot to /run/sysroot in the dracut mount hook and mount your stuff to /sysroot

mkdir /run/sysroot; mount --move /sysroot /run/sysroot ... do stuff for /sysroot

@haraldh haraldh closed this as completed May 15, 2015
@chrisnharvey
Copy link
Author

Thanks @haraldh,

Just for the sake of clarity, I have added some other comments from our conversation on IRC.

Live system is mounted under /sysroot which can be moved to /run/sysroot

Live device is located at /run/initramfs/livedev and mounted at /run/initramfs/live
https://github.com/haraldh/dracut/blob/master/modules.d/90dmsquash-live/dmsquash-live-root.sh#L56
https://github.com/haraldh/dracut/blob/master/modules.d/90dmsquash-live/dmsquash-live-root.sh#L80

Then just run

mount -t overlayfs -o lowerdir=/run/sysroot,upperdir=/run/initramfs/live/<overlay directory> /sysroot

@probonopd
Copy link

mkdir /run/sysroot; mount --move /sysroot /run/sysroot

That does not work:

mount: bad option. Note that moving a mount residing under a shared
mount is unsupported.
In some cases useful info is found in syslog - try
dmesg | tail or so.

@haraldh
Copy link
Collaborator

haraldh commented Nov 23, 2015

Maybe
mount --make-private /sysroot
or even
mount --make-rprivate /sysroot
before the mount --move

mwilck pushed a commit to mwilck/dracut that referenced this issue Jun 16, 2021
fix(suse-initrd): remove references to INITRD_MODULES (bsc#1187115)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants