[arch-projects] [mkinitcpio] [PATCH 15/18] merge most storage hooks into a single 'block' hook

Dave Reisner dreisner at archlinux.org
Fri Nov 23 18:49:00 EST 2012


As the autodetect hook gets better with every kernel release, we can
"afford" to remove the needless segregation of block device driver hooks
and simply merge all the "vanilla" or "unstacked" block device drivers.
This should make a lot of setups, like usb or virtio, easier as you
won't need to remember to add the hook.

Signed-off-by: Dave Reisner <dreisner at archlinux.org>
---
 install/block   | 45 +++++++++++++++++++++++++++++++++++++++++++++
 install/fw      | 22 +---------------------
 install/mmc     | 19 +------------------
 install/pata    | 22 +---------------------
 install/sata    | 23 +----------------------
 install/scsi    | 22 +---------------------
 install/usb     | 21 +--------------------
 install/virtio  | 16 +---------------
 mkinitcpio.conf | 14 +++++---------
 9 files changed, 57 insertions(+), 147 deletions(-)
 create mode 100644 install/block
 mode change 100644 => 120000 install/fw
 mode change 100644 => 120000 install/mmc
 mode change 100644 => 120000 install/pata
 mode change 100644 => 120000 install/sata
 mode change 100644 => 120000 install/scsi
 mode change 100644 => 120000 install/usb
 mode change 100644 => 120000 install/virtio

diff --git a/install/block b/install/block
new file mode 100644
index 0000000..44f2c27
--- /dev/null
+++ b/install/block
@@ -0,0 +1,45 @@
+#!/bin/bash
+
+build() {
+    local filter
+    local -A blockdevs
+
+    # pata, sata, scsi
+    for filter in 'scsi/.*ata' '/(block|scsi|fusion)/' 'ata/[ps]ata_' \
+            'ata/(ahci|pdc_adma|ata_piix|ata_generic)'; do
+        add_checked_modules "$filter" && blockdevs['sd_mod']=1
+    done
+
+    # usb
+    if add_checked_modules -f '(_cs|sl811_hcd|isp116x_hcd)' '/usb/host'; then
+        blockdevs+=(['usb_storage']=1 ['sd_mod']=1 ['sr_mod']=1)
+        add_checked_modules 'drivers/usb/storage/ums-*'
+    fi
+
+    # firewire
+    if add_checked_modules '/drivers/firewire/'; then
+        blockdevs+=(['firewire-sbp2']=1 ['sd_mod']=1 ['sr_mod']=1)
+    fi
+
+    # mmc
+    if add_checked_modules '/mmc'; then
+        blockdevs+=(['tifm_7xx1']=1 ['mmc_block']=1)
+    fi
+
+    # virtio
+    if add_checked_modules 'virtio'; then
+        blockdevs['virtio_blk']=1
+    fi
+
+    map add_module "${!blockdevs[@]}"
+}
+
+help() {
+    cat <<HELPEOF
+This hook loads the necessary modules for most block devices using pata, sata,
+scsi, firewire, usb, or mmc. Detection will take place at runtime. To minimize
+the modules in the image, add the autodetect hook too.
+HELPEOF
+}
+
+# vim: set ft=sh ts=4 sw=4 et:
diff --git a/install/fw b/install/fw
deleted file mode 100644
index 98c05ab..0000000
--- a/install/fw
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/bin/bash
-
-build() {
-    local mod
-
-    if add_checked_modules '/drivers/firewire/'; then
-        for mod in firewire-sbp2 sd_mod sr_mod; do
-            add_module "$mod?"
-        done
-    fi
-}
-
-help() {
-    cat <<HELPEOF
-This hook loads the necessary modules for a firewire root device.  Detection
-will take place at runtime. To minimize the modules in the image, add the
-autodetect hook too.
-HELPEOF
-}
-
-# vim: set ft=sh ts=4 sw=4 et:
diff --git a/install/fw b/install/fw
new file mode 120000
index 0000000..ad926c8
--- /dev/null
+++ b/install/fw
@@ -0,0 +1 @@
+block
\ No newline at end of file
diff --git a/install/mmc b/install/mmc
deleted file mode 100644
index 60068df..0000000
--- a/install/mmc
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/bin/bash
-
-build() {
-    if add_checked_modules '/mmc'; then
-        add_module 'tifm_7xx1'
-        add_module 'mmc_block'
-    fi
-}
-
-help() {
-    cat <<HELPEOF
-This hook loads the necessary modules for a mmc root device. Detection will
-take place at runtime. To minimize the modules in the image, add the autodetect
-hook too.
-HELPEOF
-}
-
-# vim: set ft=sh ts=4 sw=4 et:
diff --git a/install/mmc b/install/mmc
new file mode 120000
index 0000000..ad926c8
--- /dev/null
+++ b/install/mmc
@@ -0,0 +1 @@
+block
\ No newline at end of file
diff --git a/install/pata b/install/pata
deleted file mode 100644
index bcf3809..0000000
--- a/install/pata
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/bin/bash
-
-build() {
-    local filter added
-
-    for filter in 'ata/pata_*' 'ata/ata_generic' 'ata/ata_piix'; do
-        add_checked_modules "$filter" && (( ++added ))
-    done
-
-    (( added )) && add_module "sd_mod?"
-}
-
-help() {
-    cat <<HELPEOF
-This hook loads the necessary modules for a pata (ide) root device, using the
-new libata subsystem. Detection will take place at runtime. To minimize the
-modules in the image, add the autodetect hook too.
-HELPEOF
-}
-
-# vim: set ft=sh ts=4 sw=4 et:
diff --git a/install/pata b/install/pata
new file mode 120000
index 0000000..ad926c8
--- /dev/null
+++ b/install/pata
@@ -0,0 +1 @@
+block
\ No newline at end of file
diff --git a/install/sata b/install/sata
deleted file mode 100644
index c6a2ade..0000000
--- a/install/sata
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/bin/bash
-
-build() {
-    local filter added
-
-    for filter in 'scsi/.*ata' 'block/sx8' 'ata/sata_*' \
-                  'ata/ahci' 'ata/pdc_adma' 'ata/ata_piix'; do
-        add_checked_modules "$filter" && (( ++added ))
-    done
-
-    (( added )) && add_module "sd_mod?"
-}
-
-help() {
-    cat <<HELPEOF
-This hook loads the necessary modules for an sata root device. Detection will
-take place at runtime. To minimize the modules in the image, add the autodetect
-hook too.
-HELPEOF
-}
-
-# vim: set ft=sh ts=4 sw=4 et:
diff --git a/install/sata b/install/sata
new file mode 120000
index 0000000..ad926c8
--- /dev/null
+++ b/install/sata
@@ -0,0 +1 @@
+block
\ No newline at end of file
diff --git a/install/scsi b/install/scsi
deleted file mode 100644
index 7c5a771..0000000
--- a/install/scsi
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/bin/bash
-
-build(){
-    local filter added
-
-    add_checked_modules -f '(imm|ata|pcmcia)' '/scsi/' && (( ++added ))
-    add_checked_modules -f '(cciss|cpqarray|DAC960)' '/block/' && (( ++added ))
-    add_checked_modules '/fusion/' && (( ++added ))
-
-    (( added )) && add_module 'sd_mod?'
-}
-
-help() {
-    cat <<HELPEOF
-This hook loads the necessary modules for an scsi root device. Detection will
-take place at runtime. To minimize the modules in the image, add the autodetect
-hook too.
-HELPEOF
-}
-
-# vim: set ft=sh ts=4 sw=4 et:
diff --git a/install/scsi b/install/scsi
new file mode 120000
index 0000000..ad926c8
--- /dev/null
+++ b/install/scsi
@@ -0,0 +1 @@
+block
\ No newline at end of file
diff --git a/install/usb b/install/usb
deleted file mode 100644
index 2b36c35..0000000
--- a/install/usb
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/bin/bash
-
-build() {
-    if add_checked_modules -f '(_cs|sl811_hcd|isp116x_hcd)' '/usb/host'; then
-        add_module 'usb_storage?'
-        add_module 'sd_mod?'
-        add_module 'sr_mod?'
-        add_checked_modules 'drivers/usb/storage/ums-*'
-    fi
-}
-
-help() {
-    cat <<HELPEOF
-This hook loads the necessary modules for an usb root device.  Detection will
-take place at runtime. To minimize the modules in the image, add the autodetect
-hook too.
-HELPEOF
-}
-
-# vim: set ft=sh ts=4 sw=4 et:
diff --git a/install/usb b/install/usb
new file mode 120000
index 0000000..ad926c8
--- /dev/null
+++ b/install/usb
@@ -0,0 +1 @@
+block
\ No newline at end of file
diff --git a/install/virtio b/install/virtio
deleted file mode 100644
index 10037ab..0000000
--- a/install/virtio
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/bash
-
-build() {
-    add_checked_modules 'virtio_(blk|pci)'
-}
-
-help() {
-    cat <<HELPEOF
-This hook loads the necessary modules for a virtio root device.  Detection will
-take place at runtime. To minimize the modules in the image, add the autodetect
-hook too.
-HELPEOF
-}
-
-# vim: set ft=sh ts=4 sw=4 et:
diff --git a/install/virtio b/install/virtio
new file mode 120000
index 0000000..ad926c8
--- /dev/null
+++ b/install/virtio
@@ -0,0 +1 @@
+block
\ No newline at end of file
diff --git a/mkinitcpio.conf b/mkinitcpio.conf
index 229fa05..c4380af 100644
--- a/mkinitcpio.conf
+++ b/mkinitcpio.conf
@@ -37,26 +37,22 @@ FILES=""
 #
 ##   This setup will autodetect all modules for your system and should
 ##   work as a sane default
-#    HOOKS="base udev autodetect pata scsi sata filesystems"
-#
-##   This is identical to the above, except the old ide subsystem is
-##   used for IDE devices instead of the new pata subsystem.
-#    HOOKS="base udev autodetect ide scsi sata filesystems"
+#    HOOKS="base udev autodetect block filesystems"
 #
 ##   This setup will generate a 'full' image which supports most systems.
 ##   No autodetection is done.
-#    HOOKS="base udev pata scsi sata usb filesystems"
+#    HOOKS="base udev block filesystems"
 #
 ##   This setup assembles a pata mdadm array with an encrypted root FS.
 ##   Note: See 'mkinitcpio -H mdadm' for more information on raid devices.
-#    HOOKS="base udev pata mdadm encrypt filesystems"
+#    HOOKS="base udev block mdadm encrypt filesystems"
 #
 ##   This setup loads an lvm2 volume group on a usb device.
-#    HOOKS="base udev usb lvm2 filesystems"
+#    HOOKS="base udev block lvm2 filesystems"
 #
 ##   NOTE: If you have /usr on a separate partition, you MUST include the
 #    usr, fsck and shutdown hooks.
-HOOKS="base udev autodetect pata scsi sata filesystems usbinput fsck"
+HOOKS="base udev autodetect block filesystems usbinput fsck"
 
 # COMPRESSION
 # Use this to compress the initramfs image. By default, gzip compression
-- 
1.8.0



More information about the arch-projects mailing list