]> git.ipfire.org Git - thirdparty/dracut-ng.git/commitdiff
feat(dmdquash-live): add support for using erofs
authorBrian C. Lane <bcl@redhat.com>
Wed, 10 Jul 2024 23:30:09 +0000 (16:30 -0700)
committerLaszlo Gombos <laszlo.gombos@gmail.com>
Fri, 12 Jul 2024 15:21:11 +0000 (11:21 -0400)
This adds support for rootfs compressed with erofs. Either as a plain
erofs image or a LiveOS/rootfs.img ext4 filesystem compressed with
erofs.

This patch does not make any attempt to change the squashfs directory
naming (or variable names) in order to make these changes as small as
possible and easy to review. It also does not make any attempt to
support the multitude of available options other than what is needed by
anaconda-dracut calling this script to setup the boot.iso root
filesystem.

(which isn't to say it doesn't work, it just hasn't been tested and is
outside the scope of this change).

modules.d/90dmsquash-live/dmsquash-live-root.sh

index 3553e9414017f310a476ffd45d511885ab4760c0..e4a3f0094a56cf5d432ce9197823e4f77b32e02a 100755 (executable)
@@ -97,7 +97,6 @@ det_img_fs() {
     blkid -s TYPE -u noraid -o value "$1"
 }
 
-load_fstype squashfs
 CMDLINE=$(getcmdline)
 for arg in $CMDLINE; do
     case $arg in
@@ -112,14 +111,15 @@ if [ -f "$livedev" ]; then
     # check filesystem type and handle accordingly
     fstype=$(det_img_fs "$livedev")
     case $fstype in
-        squashfs) SQUASHED=$livedev ;;
-        auto) die "cannot mount live image (unknown filesystem type)" ;;
+        squashfs | erofs) SQUASHED=$livedev ;;
+        auto) die "cannot mount live image (unknown filesystem type $fstype)" ;;
         *) FSIMG=$livedev ;;
     esac
     load_fstype "$fstype"
 else
     livedev_fstype=$(det_fs "$livedev")
-    if [ "$livedev_fstype" = "squashfs" ]; then
+    load_fstype "$livedev_fstype"
+    if [ "$livedev_fstype" = "squashfs" ] || [ "$livedev_fstype" = "erofs" ]; then
         # no mount needed - we've already got the LiveOS image in $livedev
         SQUASHED=$livedev
     elif [ "$livedev_fstype" != "ntfs" ]; then
@@ -336,7 +336,7 @@ if [ -e "$SQUASHED" ]; then
     SQUASHED_LOOPDEV=$(losetup -f)
     losetup -r "$SQUASHED_LOOPDEV" "$SQUASHED"
     mkdir -m 0755 -p /run/initramfs/squashfs
-    mount -n -t squashfs -o ro "$SQUASHED_LOOPDEV" /run/initramfs/squashfs
+    mount -n -o ro "$SQUASHED_LOOPDEV" /run/initramfs/squashfs
 
     if [ -d /run/initramfs/squashfs/LiveOS ]; then
         if [ -f /run/initramfs/squashfs/LiveOS/rootfs.img ]; then