summarylogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.SRCINFO25
-rw-r--r--PKGBUILD27
-rw-r--r--auxmount_hook16
-rw-r--r--auxmount_install20
-rw-r--r--loop_hook23
-rw-r--r--loop_install24
-rw-r--r--mkinitcpio-loop-subdir.install17
-rw-r--r--subdir_hook16
-rw-r--r--subdir_install15
9 files changed, 183 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 00000000000..6c75005cd02
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,25 @@
+pkgbase = mkinitcpio-loop-subdir
+ pkgdesc = mkinitcpio hooks that allow booting from Arch installed in a file image or subdir
+ pkgver = 0.0.1
+ pkgrel = 1
+ url = https://github.com/csabahenk/mkinitcpio
+ install = mkinitcpio-loop-subdir.install
+ arch = any
+ license = GPL
+ depends = mkinitcpio>=0.9.0
+ depends = ntfs-3g
+ source = loop_hook
+ source = loop_install
+ source = subdir_hook
+ source = subdir_install
+ source = auxmount_hook
+ source = auxmount_install
+ md5sums = dd6f84a6d13caa0b5167915d2217c1a2
+ md5sums = 2cfd0525999e452b0362d1091bf99157
+ md5sums = 59b2424f231bfa3e577f55240dd92fdf
+ md5sums = 634c1bccc59f34972642eb86c615a336
+ md5sums = 6ca46ac8d394a4048c3330baddd0eccb
+ md5sums = 9c0cdb5f0600ae446ece556d5d648170
+
+pkgname = mkinitcpio-loop-subdir
+
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 00000000000..8685414b12a
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,27 @@
+# Maintainer: Csaba Henk
+# Contributor: Csaba Henk
+pkgname='mkinitcpio-loop-subdir'
+pkgver=0.0.1
+pkgrel=1
+pkgdesc='mkinitcpio hooks that allow booting from Arch installed in a file image or subdir'
+url='https://github.com/csabahenk/mkinitcpio'
+arch=('any')
+license=('GPL')
+install="${pkgname}.install"
+depends=('mkinitcpio>=0.9.0' 'ntfs-3g')
+source=('loop_hook' 'loop_install' 'subdir_hook' 'subdir_install' 'auxmount_hook' 'auxmount_install')
+md5sums=('dd6f84a6d13caa0b5167915d2217c1a2'
+ '2cfd0525999e452b0362d1091bf99157'
+ '59b2424f231bfa3e577f55240dd92fdf'
+ '634c1bccc59f34972642eb86c615a336'
+ '6ca46ac8d394a4048c3330baddd0eccb'
+ '9c0cdb5f0600ae446ece556d5d648170')
+
+package() {
+ install -Dm644 ${srcdir}/loop_install ${pkgdir}/usr/lib/initcpio/install/loop
+ install -Dm644 ${srcdir}/loop_hook ${pkgdir}/usr/lib/initcpio/hooks/loop
+ install -Dm644 ${srcdir}/subdir_install ${pkgdir}/usr/lib/initcpio/install/subdir
+ install -Dm644 ${srcdir}/subdir_hook ${pkgdir}/usr/lib/initcpio/hooks/subdir
+ install -Dm644 ${srcdir}/auxmount_install ${pkgdir}/usr/lib/initcpio/install/auxmount
+ install -Dm644 ${srcdir}/auxmount_hook ${pkgdir}/usr/lib/initcpio/hooks/auxmount
+}
diff --git a/auxmount_hook b/auxmount_hook
new file mode 100644
index 00000000000..ced0b1eff32
--- /dev/null
+++ b/auxmount_hook
@@ -0,0 +1,16 @@
+run_latehook() {
+ local _postfix _d
+
+ if [ ! -z "$auxmnt" ]; then
+ for _d in /*; do
+ case $_d in
+ /new_root*)
+ _postfix=${_d#/new_root}
+ if [ ! -z "$_postfix" ] && [ -d /new_root/"$auxmnt"/root$_postfix ]; then
+ mount --bind $_d /new_root/"$auxmnt"/root$_postfix
+ fi
+ ;;
+ esac
+ done
+ fi
+}
diff --git a/auxmount_install b/auxmount_install
new file mode 100644
index 00000000000..534b94ebaba
--- /dev/null
+++ b/auxmount_install
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+build() {
+ add_runscript
+}
+
+help() {
+ cat <<HELPEOF
+Preserve auxiliary mounts of the early userspace.
+
+If in initramfs an auxiliary mount was created
+on /new_rootfoo, and $auxmnt/rootfoo exists,
+the initramfs' /new_rootfoo mount will be
+made available at $auxmnt/rootfoo.
+
+Syntax: auxmnt=/<dir>
+HELPEOF
+}
+
+# vim: set ft=sh ts=4 sw=4 et:
diff --git a/loop_hook b/loop_hook
new file mode 100644
index 00000000000..51d93d7738b
--- /dev/null
+++ b/loop_hook
@@ -0,0 +1,23 @@
+run_hook() {
+ case $root in
+ *@*)
+ rootpart=${root%%@*}
+ rootimg=${root#*@}
+
+ mkdir /new_rootpart
+ if [ "$partfstype" = ntfs ]; then
+ # see http://www.freedesktop.org/wiki/Software/systemd/RootStorageDaemons/
+ ln -s ntfs-3g /usr/bin/@ntfs-3g
+ @ntfs-3g "$rootpart" /new_rootpart -o dmask=022,fmask=133
+ else
+ mount ${partfstype:+-t $partfstype} "$rootpart" /new_rootpart
+ fi
+ modprobe loop
+ root=`losetup -f`
+ if ! losetup ${offset:+-o $offset} "$root" /new_rootpart/"$rootimg"; then
+ err "Unable to set up root '$root' as loop of '/new_rootpart/$rootimg'"
+ launch_interactive_shell
+ fi
+ ;;
+ esac
+}
diff --git a/loop_install b/loop_install
new file mode 100644
index 00000000000..b9b8b1f1b3b
--- /dev/null
+++ b/loop_install
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+build() {
+ add_module fuse
+ add_module loop
+ add_binary ntfs-3g
+
+ add_runscript
+}
+
+help() {
+ cat <<HELPEOF
+Support for mounting Arch root from a file image.
+Make sure to add the filesystem kernel modules
+for your image type when building the initramfs
+as it won't be auto-detected.
+
+Syntax: root=<rootdev>@/<imagepath>
+ partfstype=<fstype>
+ offset=<int>
+HELPEOF
+}
+
+# vim: set ft=sh ts=4 sw=4 et:
diff --git a/mkinitcpio-loop-subdir.install b/mkinitcpio-loop-subdir.install
new file mode 100644
index 00000000000..8b9cd2066e2
--- /dev/null
+++ b/mkinitcpio-loop-subdir.install
@@ -0,0 +1,17 @@
+post_install() {
+ echo "Example usage of this hook:"
+ echo "For booting an Arch Linux system pacstrap'd to /ARCH"
+ echo "on a Wubi (https://wiki.ubuntu.com/WubiGuide) install:"
+ echo "add the loop amd subdir hooks to your initramefs, then"
+ echo "set up the kernel to boot with the following command line:"
+ echo
+ echo "root=/dev/sda2@/ubuntu/disks/root.disk partfstype=ntfs rootdir=ARCH rw"
+ echo
+ echo "If you want to access the underlying Windows and Ubuntu systems"
+ echo "from Arch, also add the auxmount hook, create /mnt/rootpart and "
+ echo "/mnt/rootimg and add 'auxmnt=mnt' to the kernel command line."
+}
+
+post_upgrade() {
+ post_install
+}
diff --git a/subdir_hook b/subdir_hook
new file mode 100644
index 00000000000..19cb8fe3635
--- /dev/null
+++ b/subdir_hook
@@ -0,0 +1,16 @@
+run_hook() {
+ if [ ! -z "$rootdir" ]; then
+ mv /new_root /new_rootimg
+ ln -s new_rootimg /new_root
+ fi
+}
+
+run_latehook() {
+ local _rootpath _postfix _d
+ if [ ! -z "$rootdir" -a -L /new_root ]; then
+ _rootpath=/`readlink /new_root`
+ rm /new_root
+ mkdir /new_root
+ mount --bind $_rootpath/"$rootdir" /new_root
+ fi
+}
diff --git a/subdir_install b/subdir_install
new file mode 100644
index 00000000000..15200882346
--- /dev/null
+++ b/subdir_install
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+build() {
+ add_runscript
+}
+
+help() {
+ cat <<HELPEOF
+Support for mounting Arch root from a subdirectory.
+
+Syntax: rootdir=<dir>
+HELPEOF
+}
+
+# vim: set ft=sh ts=4 sw=4 et: