summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Gilbert <floppym@gentoo.org>2012-04-22 06:07:32 +0000
committerMike Gilbert <floppym@gentoo.org>2012-04-22 06:07:32 +0000
commit4ea91c642a0e0afcff9dfbbe3af0436ed76a6cda (patch)
tree4b8376cc55f4f7ccdcffa832fbc2198abe7f1892 /sys-fs/zfs/files
parent[dev-util/catalyst] Bump catalyst to the 2.0.8 revision. (diff)
downloadhistorical-4ea91c642a0e0afcff9dfbbe3af0436ed76a6cda.tar.gz
historical-4ea91c642a0e0afcff9dfbbe3af0436ed76a6cda.tar.bz2
historical-4ea91c642a0e0afcff9dfbbe3af0436ed76a6cda.zip
Add zfs-shutdown init script and linuxrc helper script; Introduce rootfs USE flag; Fix issue with sys-libs/zlib[static-libs] on Gentoo stable. Patch by Richard Yao.
Package-Manager: portage-2.2.0_alpha100/cvs/Linux x86_64
Diffstat (limited to 'sys-fs/zfs/files')
-rw-r--r--sys-fs/zfs/files/linuxrc18
-rw-r--r--sys-fs/zfs/files/zfs-shutdown57
2 files changed, 75 insertions, 0 deletions
diff --git a/sys-fs/zfs/files/linuxrc b/sys-fs/zfs/files/linuxrc
new file mode 100644
index 000000000000..1e63837fad04
--- /dev/null
+++ b/sys-fs/zfs/files/linuxrc
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+PATH="/usr/sbin:/usr/bin:/sbin:/bin"
+
+j=0
+for i in $(cat /movefs)
+do
+ mkdir "/${j}"
+ mount --move "${i}" "/${j}"
+ j=$(expr $j + 1)
+done
+
+zfs umount -a
+
+for i in $(zpool list -H -o name)
+do
+ zpool export "$i"
+done;
diff --git a/sys-fs/zfs/files/zfs-shutdown b/sys-fs/zfs/files/zfs-shutdown
new file mode 100644
index 000000000000..17791b67cfb1
--- /dev/null
+++ b/sys-fs/zfs/files/zfs-shutdown
@@ -0,0 +1,57 @@
+#!/sbin/runscript
+
+description="Export ZFS Root Filesystem"
+
+copy_binaries() {
+ local destdir=$1
+ shift
+ lddtree "$@" \
+ | tr ')(' '\n' \
+ | awk '/=>/{ if($3 ~ /^\//){print $3}}' \
+ | sort \
+ | uniq \
+ | cpio -p --make-directories --dereference --quiet $destdir
+
+}
+
+depend()
+{
+ need mount-ro
+ keyword -prefix -openvz -vserver -lxc
+}
+
+start()
+{
+
+ ROOTFSTYPE=$(df -TP / | awk 'NR>1{print $2}')
+ TMPDIR='/dev/pivot_root'
+ MOVEFS=$(df -TP -x zfs | awk 'NR>2{print $7}')
+
+ # Make sure that we are dealing with zfs
+ test "${ROOTFSTYPE}" = "zfs" || eerror "rootfs is not zfs" && exit
+
+ # Construct new rootfs
+ mkdir -p "${TMPDIR}"
+ mount -t tmpfs none ${TMPDIR}
+ mkdir "${TMPDIR}/oldroot" "${TMPDIR}/dev"
+ mknod -m 660 "${TMPDIR}/dev/null" c 1 3
+ mknod -m 660 "${TMPDIR}/dev/zfs" c 10 59
+
+ # Make tmpfs root filesystem
+ copy_binaries ${TMPDIR} $(which chroot sh cat mount mkdir zfs zpool)
+
+ # Make directories for temporary mounts
+ for i in $(seq $(echo "$MOVEFS" | wc -w)); do mkdir "${TMPDIR}/${i}"; done;
+
+ # Pass temporary mount information to chroot
+ echo "$MOVEFS" > "${TMPDIR}/movefs"
+
+ # Copy shutdown script
+ cp /usr/share/zfs/linuxrc "${TMPDIR}/linuxrc"
+
+ # Pivot into new root
+ cd "${TMPDIR}"
+ pivot_root . oldroot
+ exec chroot . /linuxrc
+
+}