Blame SOURCES/0510-Add-NTFS-support-to-90dmsquash-live-module.patch

18971c
From 015d5aee92d461ce44d8b8cf941fb45855c13c3b Mon Sep 17 00:00:00 2001
18971c
From: Robert Scheck <robert@fedoraproject.org>
18971c
Date: Tue, 22 Aug 2017 23:44:41 +0200
18971c
Subject: [PATCH] Add NTFS support to 90dmsquash-live module
18971c
18971c
Support booting from USB media with NTFS filesystem (optionally),
18971c
which removes the FAT32 related 4 GB file size limit for LiveOS/
18971c
squashfs.img (and any other file on the same USB media).
18971c
18971c
Backports 37437cac8a1f2c411ead5fca28fb743a6f36f912 from dracut 046
18971c
---
18971c
 .../90dmsquash-live-ntfs/module-setup.sh      | 22 +++++++++++++++++++
18971c
 .../90dmsquash-live/dmsquash-live-root.sh     | 15 ++++++++++++-
18971c
 2 files changed, 36 insertions(+), 1 deletion(-)
18971c
 create mode 100755 modules.d/90dmsquash-live-ntfs/module-setup.sh
18971c
18971c
diff --git a/modules.d/90dmsquash-live-ntfs/module-setup.sh b/modules.d/90dmsquash-live-ntfs/module-setup.sh
18971c
new file mode 100755
18971c
index 00000000..bc77376b
18971c
--- /dev/null
18971c
+++ b/modules.d/90dmsquash-live-ntfs/module-setup.sh
18971c
@@ -0,0 +1,22 @@
18971c
+#!/bin/bash
18971c
+
18971c
+command -v
18971c
+
18971c
+check() {
18971c
+    require_binaries ntfs-3g || return 1
18971c
+    return 255
18971c
+}
18971c
+
18971c
+depends() {
18971c
+    echo 90dmsquash-live
18971c
+    return 0
18971c
+}
18971c
+
18971c
+install() {
18971c
+    inst_multiple fusermount ulockmgr_server mount.fuse ntfs-3g
18971c
+    dracut_need_initqueue
18971c
+}
18971c
+
18971c
+installkernel() {
18971c
+    hostonly='' instmods fuse
18971c
+}
18971c
diff --git a/modules.d/90dmsquash-live/dmsquash-live-root.sh b/modules.d/90dmsquash-live/dmsquash-live-root.sh
18971c
index 6631d9a8..5fb798c7 100755
18971c
--- a/modules.d/90dmsquash-live/dmsquash-live-root.sh
18971c
+++ b/modules.d/90dmsquash-live/dmsquash-live-root.sh
18971c
@@ -79,7 +79,20 @@ if [ -f $livedev ]; then
18971c
     esac
18971c
     [ -e /sys/fs/$fstype ] || modprobe $fstype
18971c
 else
18971c
-    mount -n -t $fstype -o ${liverw:-ro} $livedev /run/initramfs/live
18971c
+    if [ "$(blkid -o value -s TYPE $livedev)" != "ntfs" ]; then
18971c
+        mount -n -t $fstype -o ${liverw:-ro} $livedev /run/initramfs/live
18971c
+    else
18971c
+        # Symlinking /usr/bin/ntfs-3g as /sbin/mount.ntfs seems to boot
18971c
+        # at the first glance, but ends with lots and lots of squashfs
18971c
+        # errors, because systemd attempts to kill the ntfs-3g process?!
18971c
+        if [ -x "$(find_binary "ntfs-3g")" ]; then
18971c
+            ( exec -a @ntfs-3g ntfs-3g -o ${liverw:-ro} $livedev /run/initramfs/live ) | vwarn
18971c
+        else
18971c
+            die "Failed to mount block device of live image: Missing NTFS support"
18971c
+            exit 1
18971c
+        fi
18971c
+    fi
18971c
+
18971c
     if [ "$?" != "0" ]; then
18971c
         die "Failed to mount block device of live image"
18971c
         exit 1