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

live-iso: add erofs support #3342

Open
wants to merge 1 commit into
base: testing-devel
Choose a base branch
from

Conversation

nikita-dubrovskii
Copy link
Contributor

No description provided.

@nikita-dubrovskii nikita-dubrovskii changed the title DRAFT: live-iso: add erofs support live-iso: add erofs support Feb 5, 2025
@nikita-dubrovskii nikita-dubrovskii removed the WIP PR still being worked on label Feb 10, 2025
Where=/sysroot
Type=squashfs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if there are any consequences for removing Type= but it sounds good to me if there aren't any. I'm sure the kernel just autodetects here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, there is no need for that

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's the kernel doing the auto-detection here, but util-linux. I think in general it's better to specify the type you expect to not rely on it getting it right and just be more strict. One way that I think should work here is to make this an env var and then add an EnvironmentFile that we populate from coreos-livepxe-rootfs.sh.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While we can write out an override from coreos-livepxe-rootfs.sh for this particular mount where we can set the Type that won't be so easy for the sysroot.mount from ~line 150 because we don't know whether the file inside the rootfs.img is erofs or squashfs at that point in time.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For setting the What= and Type= here this seems to work:

diff --git a/overlay.d/05core/usr/lib/dracut/modules.d/35coreos-live/coreos-livepxe-rootfs.sh b/overlay.d/05core/usr/lib/dracut/modules.d/35coreos-live/coreos-livepxe-rootfs.sh
index 61b4661f..d62443ab 100755
--- a/overlay.d/05core/usr/lib/dracut/modules.d/35coreos-live/coreos-livepxe-rootfs.sh
+++ b/overlay.d/05core/usr/lib/dracut/modules.d/35coreos-live/coreos-livepxe-rootfs.sh
@@ -88,6 +88,20 @@ else
 fi
 
 # we support both squashfs and erofs, let's create the symlink for sysroot.mount
-sysroot=$(ls /root.*fs)
-echo "Creating symlink '/sysrootfs.img -> ${sysroot}'"
-ln -s "${sysroot}" /sysrootfs.img
+if [ -f /root.squashfs ]; then
+    fs='/root.squashfs'
+    fstype='squashfs'
+elif [ -f /root.erofs ]; then
+    fs='/root.erofs'
+    fstype='erofs'
+else
+    echo "No root.squashfs or root.erofs exists" >&2
+    exit 1
+fi
+
+# Let sysroot.mount know what path and type to use for mounting
+echo "Updating /rootfs.env with WHAT=${fs} TYPE=${fstype}"
+cat >/rootfs.env <<EOF
+WHAT=${fs}
+TYPE=${fstype}
+EOF
diff --git a/overlay.d/05core/usr/lib/dracut/modules.d/35coreos-live/live-generator b/overlay.d/05core/usr/lib/dracut/modules.d/35coreos-live/live-generator
index 9c052e5a..013a8d23 100755
--- a/overlay.d/05core/usr/lib/dracut/modules.d/35coreos-live/live-generator
+++ b/overlay.d/05core/usr/lib/dracut/modules.d/35coreos-live/live-generator
@@ -58,18 +58,19 @@ isoroot=$(getarg coreos.liveiso= ||:)
 if [ -z "${isoroot}" ]; then
     # In this case, the rootfs is already unpacked into the initrd, or we need
     # to retrieve it
-    cat >"${UNIT_DIR}/sysroot.mount" <<EOF
+    cat >"${UNIT_DIR}/sysroot.mount" <<'EOF'
 # Automatically generated by live-generator
 
 [Unit]
 DefaultDependencies=false
-# Verifies that we have the right sysrootfs.img, or downloads it if needed
+# Verifies that we have the right rootfs image, or downloads it if needed
 After=coreos-livepxe-rootfs.service
 Before=initrd-root-fs.target
-
 [Mount]
-What=/sysrootfs.img
+EnvironmentFile=/rootfs.env
+What=${WHAT}
 Where=/sysroot
+Type=${TYPE}
 Options=loop
 EOF
 else

but I'm not opposed to leaving it the way it is either.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For setting the What= and Type= here this seems to work:

Ahh yes, I do like the explicitness of just templating the What also actually.

Copy link
Contributor Author

@nikita-dubrovskii nikita-dubrovskii Feb 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, should i add Dusty's patch on top ? Does it make sense to have this explicity just in 1 place, while omitting the else case?

@dustymabe
Copy link
Member

the code LGTM - I'll test it out today.

@nikita-dubrovskii
Copy link
Contributor Author

PXE installation doesn't work:

[    1.631722] ls:                                                                                                                                             
[    1.631725] cannot access '/root.*fs'  

Fixing ...

@nikita-dubrovskii
Copy link
Contributor Author

Now PXE works, here are logs

root.squashfs

[  OK  ] Mounted run-ephemeral.mount - /run/ephemeral.                                                                                                         
[    4.833554] coreos-livepxe-rootfs[806]: Creating symlink to /root.squashfs                                                                                  
[  OK  ] Finished coreos-livepxe-rootfs.ser…ce - Acquire Live PXE rootfs Image.                                                                                
[    4.835793] systemd[1]: Mounting sysroot.mount - /sysroot...                                                                                                
[  OK  ] Mounted sysroot.mount - /sysroot.                                                                                                                     

root.erofs:

[  OK  ] Mounted run-ephemeral.mount - /run/ephemeral.                                                                                                         
[    9.394641] coreos-livepxe-rootfs[780]: Creating symlink to /root.erofs                                                                                     
[  OK  ] Finished coreos-livepxe-rootfs.ser…ce - Acquire Live PXE rootfs Image.
[    9.398447] systemd[1]: Mounting sysroot.mount - /sysroot...                                                                                                                                    
[    9.480587] erofs: (device loop1): mounted with root inode @ nid 208.                                                                                       
[  OK  ] Mounted sysroot.mount - /sysroot.                                                                                                                     

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

Successfully merging this pull request may close these issues.

3 participants