aboutsummarylogtreecommitdiffstats
diff options
context:
space:
mode:
authornikp1232018-04-07 15:06:55 +0200
committernikp1232018-04-07 15:06:55 +0200
commit99573fca2ae6380a50bec32e5fe0491dbc8556b1 (patch)
tree73c66ccaebc9a81d66023165e4685b002c9c4259
downloadaur-99573fca2ae6380a50bec32e5fe0491dbc8556b1.tar.gz
Initial commit
-rw-r--r--.SRCINFO17
-rw-r--r--PKGBUILD24
-rw-r--r--README.md49
-rw-r--r--hook9
-rw-r--r--install12
5 files changed, 111 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 000000000000..08f5c52360bd
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,17 @@
+pkgbase = mkinitcpio-dir
+ pkgdesc = Initcpio hook to mount a subdirectory as the root file system
+ pkgver = 0.2.0
+ pkgrel = 0
+ url = https://bbs.archlinux.org/viewtopic.php?pid=932362#p932362
+ arch = any
+ license = custom:Public domain
+ depends = mkinitcpio
+ source = README.md
+ source = hook
+ source = install
+ md5sums = SKIP
+ md5sums = SKIP
+ md5sums = SKIP
+
+pkgname = mkinitcpio-dir
+
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 000000000000..daa996254d65
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,24 @@
+# Maintainer: Martin Panter <vadmium à gmail·com>
+_name=dir
+pkgname="mkinitcpio-$_name"
+pkgver=0.2.0
+pkgrel=0
+pkgdesc="Initcpio hook to mount a subdirectory as the root file system"
+url="https://bbs.archlinux.org/viewtopic.php?pid=932362#p932362"
+arch=(any)
+license=("custom:Public domain")
+depends=(mkinitcpio)
+source=(README.md hook install)
+md5sums=(SKIP SKIP SKIP)
+
+package() {
+ local DEST=(
+ "usr/share/doc/$pkgname/README.md"
+ "usr/lib/initcpio/hooks/$_name"
+ "usr/lib/initcpio/install/$_name"
+ )
+ for((i = 0; i < "${#source[@]}"; ++i)); do
+ mkdir -p "$pkgdir/$(dirname "${DEST[i]}")"
+ install -Dm644 "$srcdir/${source[i]}" "$pkgdir/${DEST[i]}"
+ done
+}
diff --git a/README.md b/README.md
new file mode 100644
index 000000000000..8821451fd043
--- /dev/null
+++ b/README.md
@@ -0,0 +1,49 @@
+# Filesystem-in-subdirectory hook for “mkinitcpio” #
+
+This “mkinitcpio” hook mounts the root file system from a subdirectory rather
+than the root directory of a partition. The “dir=” kernel parameter specifies
+which subdirectory. A leading slash (/) is allowed but not necessary.
+
+This allows multiple separate operating systems to be installed in a single
+partition.
+For example a single partition could contain
+multiple OS filesystems and other shared files:
+
+* /os/arch-x86-64/bin/
+* /os/arch-x86-64/etc/
+* . . .
+* /os/arch-i686/bin/
+* /os/arch-i686/etc/
+* . . .
+* /home/_user_/
+* /os/debian/ (potentially)
+* /os/win/WINDOWS/ (if a common filesystem was supported)
+
+It is achieved by using a “bind mount” of the subdirectory.
+
+## Installation ##
+
+Add “dir” to the HOOKS list in /etc/mkinitcpio.conf:
+
+ HOOKS+=" dir"
+
+Add a “dir=” parameter to the kernel command line
+(for example in /boot/grub/menu.lst).
+The path is relative to the file system of the “root” device. For example:
+
+> APPEND root=LABEL=_label_ dir=/os/arch-x86-64 ro
+
+## Issues ##
+
+It’s also useful to mount the whole partition somewhere as well
+using /etc/fstab, although this means that
+all the files under the mounted OS directory
+will be visible under both mount points.
+Although I have not seen any serious problems,
+some programs complain about a circular file system loop:
+
+> find: File system loop detected
+
+> du: WARNING: Circular directory structure.
+> This almost certainly means that you have a corrupted file system.
+> NOTIFY YOUR SYSTEM MANAGER.
diff --git a/hook b/hook
new file mode 100644
index 000000000000..2ae023927d61
--- /dev/null
+++ b/hook
@@ -0,0 +1,9 @@
+run_hook() {
+ dir_pre_mount_handler="${mount_handler:-default_mount_handler}"
+ mount_handler=dir_mount_handler
+}
+
+dir_mount_handler() {
+ $dir_pre_mount_handler "$1"
+ mount --bind -- "$1/$dir" "$1"
+}
diff --git a/install b/install
new file mode 100644
index 000000000000..6136ea524c21
--- /dev/null
+++ b/install
@@ -0,0 +1,12 @@
+build() {
+ add_runscript
+}
+
+help() {
+cat<<HELP
+ Mounts a subdirectory as the actual root file system. The "dir=" kernel
+ parameter specifies which subdirectory. A leading slash (/) is allowed but
+ not necessary. This hook should come after any hook that mounts the parent
+ file system.
+HELP
+}