summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlain Kalker2015-07-01 17:02:25 +0200
committerAlain Kalker2015-07-01 17:02:25 +0200
commit5591a83973ae19eef9310c713e222020ec773b1d (patch)
treef0ef7e83b8b5bcdda9b104f7164b66ff46815aa9
downloadaur-mkinitcpio-aoe.tar.gz
Initial import
-rw-r--r--.SRCINFO16
-rw-r--r--PKGBUILD20
-rw-r--r--initcpio-hook-aoe83
-rw-r--r--initcpio-install-aoe56
4 files changed, 175 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 000000000000..2599fe630f82
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,16 @@
+pkgbase = mkinitcpio-aoe
+ pkgdesc = mkinitcpio hook to boot from an ATA over Ethernet (AoE) target
+ pkgver = 0.4
+ pkgrel = 1
+ url = http://www.archlinux.org/
+ arch = i686
+ arch = x86_64
+ license = GPL2
+ depends = aoetools
+ source = initcpio-install-aoe
+ source = initcpio-hook-aoe
+ sha256sums = 126d70a1c6e6685d1a0b65ac003851ce5a5612812ae99aceea54a646448ca644
+ sha256sums = 7cb71358243feeaaffd0e11d9fa5ee2042d86f26aa26c9a081921a9e0472c942
+
+pkgname = mkinitcpio-aoe
+
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 000000000000..ab4da2b4b0f2
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,20 @@
+# Maintainer: Alain Kalker <a.c.kalker@gmail.com>
+# Based on mkinitcpio-nfs-utils
+
+pkgname=mkinitcpio-aoe
+pkgver=0.4
+pkgrel=1
+pkgdesc="mkinitcpio hook to boot from an ATA over Ethernet (AoE) target"
+arch=('i686' 'x86_64')
+url="http://www.archlinux.org/"
+license=('GPL2')
+depends=('aoetools')
+source=('initcpio-install-aoe'
+ 'initcpio-hook-aoe')
+sha256sums=('126d70a1c6e6685d1a0b65ac003851ce5a5612812ae99aceea54a646448ca644'
+ '7cb71358243feeaaffd0e11d9fa5ee2042d86f26aa26c9a081921a9e0472c942')
+
+package() {
+ install -Dm644 "$srcdir/initcpio-install-aoe" "$pkgdir/usr/lib/initcpio/install/aoe"
+ install -Dm644 "$srcdir/initcpio-hook-aoe" "$pkgdir/usr/lib/initcpio/hooks/aoe"
+}
diff --git a/initcpio-hook-aoe b/initcpio-hook-aoe
new file mode 100644
index 000000000000..5de927f60929
--- /dev/null
+++ b/initcpio-hook-aoe
@@ -0,0 +1,83 @@
+# vim: set ft=sh:
+run_hook() {
+ local i net_mac bootif_mac bootif_dev
+ local net_iflist iface root_dev shelf slot dev root_found
+
+ # calculate bootif_dev from boot MAC address
+ if [ -n "${BOOTIF}" ]; then
+ bootif_mac=${BOOTIF#01-}
+ bootif_mac=${bootif_mac//-/:}
+ for i in /sys/class/net/*/address; do
+ read net_mac < ${i}
+ if [ "${bootif_mac}" == "${net_mac}" ]; then
+ bootif_dev=${i#/sys/class/net/}
+ bootif_dev=${bootif_dev%/address}
+ break
+ fi
+ done
+ fi
+
+ # calculate aoe_iflist for module load
+ if [ -z "${aoe_iflist}" ]; then
+ aoe_iflist=${bootif_dev}
+ fi
+
+ # calculate net_iflist with interfaces to bring up
+ net_iflist=${aoe_iflist//,/ }
+ if [ -z "${net_iflist}" ]; then
+ net_iflist=`ls /sys/class/net`
+ fi
+
+ # set discover timeout
+ aoe_discover_timeout=${aoe_discover_timeout:-10}
+
+ # setup network
+ msg ":: Bringing up network interfaces: ${net_iflist}"
+ for iface in ${net_iflist}; do
+ ifconfig "${iface}" up
+ done
+
+ # calculate shelf and slot of AoE device
+ root_dev=${root#/dev/etherd/}
+ shelf=${root_dev%.*}
+ shelf=${shelf#e}
+ slot=${root_dev#e*.}
+ slot=${slot%p*}
+
+ # load module
+ modprobe aoe ${aoe_iflist:+aoe_iflist=${aoe_iflist}}
+
+ # search for root device
+ echo -n "Searching for AoE root device."
+ root_found=false
+ for i in `seq ${aoe_discover_timeout}`; do
+ for dev in /dev/etherd/e[0-9]*; do
+ if [ "${dev}" == "${root}" ]; then
+ root_found=true
+ break
+ fi
+ done
+
+ if $root_found; then
+ break
+ else
+ echo -n "."
+ sleep 1
+ aoe-discover
+ fi
+ done
+ echo
+
+ if ! $root_found; then
+ err "Unable to mount root filesystem over AoE."
+ echo "You are being dropped to a recovery shell"
+ echo " Type 'exit' to try and continue booting"
+ launch_interactive_shell
+ msg "Trying to continue (this will most likely fail) ..."
+ else
+ msg ":: Found AoE device: e${shelf}.${slot}"
+ fi
+ set +x
+}
+
+# vim: set ft=sh ts=4 sw=4 et:
diff --git a/initcpio-install-aoe b/initcpio-install-aoe
new file mode 100644
index 000000000000..8ceeefd9283f
--- /dev/null
+++ b/initcpio-install-aoe
@@ -0,0 +1,56 @@
+#!/bin/bash
+
+build() {
+ add_checked_modules '/drivers/net/'
+ add_module aoe
+
+ add_binary "/usr/sbin/aoe-interfaces" "/bin/aoe-interfaces"
+ add_binary "/usr/sbin/aoe-discover" "/bin/aoe-discover"
+ add_binary "/usr/sbin/aoeping" "/bin/aoeping"
+
+ add_runscript
+}
+
+help() {
+ cat <<HELPEOF
+This hook loads the necessary modules for a network device.
+Detection will take place at runtime. To minimize the modules
+in the image, add the autodetect hook too.
+For pcmcia net devices please use pcmcia hook too.
+
+Kernel Parameters:
+
+BOOTIF=01-<bootif-mac>
+aoe_iflist=<iface>[,<iface>...]
+aoe_discover_timeout=<discover-timeout>
+root=/dev/etherd/e<shelf>.<slot>[p<part>
+
+If neither BOOTIF=... nor aoe_iflist=... are specified, all available
+network interfaces will be brought up and made available for AoE.
+Depending on network infrastructure, this may pose a security risk,
+but it is useful for testing.
+
+If only BOOTIF=... is specified, the associated network interface will
+be made available for AoE.
+
+When using PXELINUX as bootloader, the line 'IPAPPEND 2' can be added
+to its configuration file to have the BOOTIF parameter added to the
+kernel commandline automatically, based on information from DHCP.
+
+If aoe_iflist=... is specified, it will override any network interface
+determined by the BOOTIF=... parameter.
+
+<bootif-mac> MAC address of the network interface used for
+ booting.
+<iface> Name of a network interface to bring up and make
+ available for AoE device discovery.
+<discover-timeout> Time (in seconds) to wait for discovery of the
+ AoE root device. Defaults to 10 seconds.
+<shelf> As specified in the AoE device configuration.
+<slot> As specified in the AoE device configuration.
+<part> Partition on an AoE device. Use this only if
+ the device containins a partition table.
+HELPEOF
+}
+
+# vim: set ft=sh ts=4 sw=4 et: