99fs-lib/module-setup.sh: only include fsck helper needed for hostonly
authorHarald Hoyer <harald@redhat.com>
Wed, 9 Nov 2011 08:04:59 +0000 (09:04 +0100)
committerHarald Hoyer <harald@redhat.com>
Tue, 15 Nov 2011 08:47:18 +0000 (09:47 +0100)
for the host-only initramfs, check all relevant disks for the
filesystem type and only include those fsck tools, which are needed.

modules.d/99fs-lib/module-setup.sh

index 8e14a4e..04b63f1 100755 (executable)
@@ -24,6 +24,35 @@ install() {
             xfs_db xfs_check xfs_repair
             e2fsck jfs_fsck reiserfsck btrfsck
         "
+        if [[ $hostonly ]]; then
+            print_fs_type() { get_fs_type /dev/block/$1; }
+            _rootdev=$(find_root_block_device)
+            if [[ $_rootdev ]]; then
+                _helpers="umount mount "
+                for fs in $(check_block_and_slaves print_fs_type  "$_rootdev"); do
+                    case "$fs" in
+                        xfs)
+                            _helpers+=" xfs_db xfs_repair xfs_check "
+                            ;;
+                        ext?)
+                            _helpers+=" e2fsck "
+                            ;;
+                        jfs)
+                            _helpers+=" jfs_fsck "
+                            ;;
+                        reiserfs)
+                            _helpers+=" reiserfsck "
+                            ;;
+                        btrfs)
+                            _helpers+=" btrfsck "
+                            ;;
+                        *)
+                            [[ -x fsck.$fs ]] && _helpers+= " fsck.$fs "
+                            ;;
+                    esac
+                done
+            fi
+        fi
     else
         _helpers="$fscks"
     fi