1 |
commit: 6968584a58a7825adb9f13b45961f190ea4ca7e0 |
2 |
Author: Richard Yao <ryao <AT> cs <DOT> stonybrook <DOT> edu> |
3 |
AuthorDate: Mon Apr 30 17:34:01 2012 +0000 |
4 |
Commit: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Apr 30 20:39:13 2012 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commit;h=6968584a |
7 |
|
8 |
Improve ZFS diagnostics, import and mounting |
9 |
|
10 |
Make ZFS only import the specified pool |
11 |
Set zfsutil when mounting non-legacy rootfs |
12 |
Check for /sbin/zpool in addition to /sbin/zfs |
13 |
Print information messages when ZFS pools are imported |
14 |
Prompt user when mounting a ZFS filesystem without ZFS support |
15 |
Verify that <dataset> in real_root=ZFS=<dataset> is a filesystem |
16 |
|
17 |
--- |
18 |
defaults/initrd.scripts | 24 +++++++++++++++++++++--- |
19 |
defaults/linuxrc | 33 +++++++++++++++++++++++++++------ |
20 |
2 files changed, 48 insertions(+), 9 deletions(-) |
21 |
|
22 |
diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts |
23 |
index 02843c5..a7d88e4 100755 |
24 |
--- a/defaults/initrd.scripts |
25 |
+++ b/defaults/initrd.scripts |
26 |
@@ -654,11 +654,29 @@ startVolumes() { |
27 |
|
28 |
if [ "${USE_ZFS}" = '1' ] |
29 |
then |
30 |
- if [ -e '/sbin/zpool' ] |
31 |
+ if [ -z "${ZFS_POOL}" ]; |
32 |
then |
33 |
- /sbin/zpool import -N -a ${ZPOOL_FORCE} |
34 |
+ good_msg "Importing ZFS pools" |
35 |
+ |
36 |
+ /sbin/zpool import -N -a "${ZPOOL_FORCE}" |
37 |
+ |
38 |
+ if [ "$?" = '0' ] |
39 |
+ then |
40 |
+ good_msg "Importing ZFS pools succeeded" |
41 |
+ else |
42 |
+ bad_msg "Imported ZFS pools failed" |
43 |
+ fi |
44 |
else |
45 |
- bad_msg "zpool not found: skipping ZFS pool import!" |
46 |
+ good_msg "Importing ZFS pool ${ZFS_POOL}" |
47 |
+ |
48 |
+ /sbin/zpool import -N "${ZPOOL_FORCE}" "${ZFS_POOL}" |
49 |
+ |
50 |
+ if [ "$?" = '0' ] |
51 |
+ then |
52 |
+ good_msg "Importing ${ZFS_POOL} succeeded" |
53 |
+ else |
54 |
+ bad_msg "Importing ${ZFS_POOL} failed" |
55 |
+ fi |
56 |
fi |
57 |
fi |
58 |
} |
59 |
|
60 |
diff --git a/defaults/linuxrc b/defaults/linuxrc |
61 |
index f6c0de5..6103e23 100755 |
62 |
--- a/defaults/linuxrc |
63 |
+++ b/defaults/linuxrc |
64 |
@@ -251,6 +251,11 @@ fi |
65 |
# Set variables based on the value of REAL_ROOT |
66 |
case "${REAL_ROOT}" in |
67 |
ZFS*) |
68 |
+ ZFS_POOL=${REAL_ROOT#*=} |
69 |
+ ZFS_POOL=${ZFS_POOL%%/*} |
70 |
+ USE_ZFS=1 |
71 |
+ ;; |
72 |
+ ZFS) |
73 |
USE_ZFS=1 |
74 |
;; |
75 |
esac |
76 |
@@ -258,12 +263,15 @@ esac |
77 |
# Verify that it is safe to use ZFS |
78 |
if [ "USE_ZFS" = "1" ] |
79 |
then |
80 |
- if [ -x /sbin/zfs ] |
81 |
+ if [ -x /sbin/zfs -a -x /sbin/zpool ] |
82 |
then |
83 |
MY_HWOPTS="${MY_HWOPTS} zfs" |
84 |
else |
85 |
- bad_msg 'zfs binary not found: aborting use of zfs!' |
86 |
USE_ZFS=0 |
87 |
+ |
88 |
+ [ -x /sbin/zfs ] || bad_msg '/sbin/zfs not found!' |
89 |
+ [ -x /sbin/zpool ] || bad_msg '/sbin/zpool not found!' |
90 |
+ bad_msg 'Aborting use of zfs!' |
91 |
fi |
92 |
fi |
93 |
|
94 |
@@ -486,16 +494,24 @@ do |
95 |
fi |
96 |
;; |
97 |
ZFS*) |
98 |
+ if [ "${USE_ZFS}" = '0' ]; then |
99 |
+ prompt_user "REAL_ROOT" "root block device" |
100 |
+ continue |
101 |
+ fi |
102 |
+ |
103 |
ROOT_DEV="${REAL_ROOT#*=}" |
104 |
if [ "${ROOT_DEV}" != 'ZFS' ] |
105 |
then |
106 |
- zfs get type ${ROOT_DEV} > /dev/null |
107 |
- |
108 |
- if [ "$?" = '0' ] |
109 |
+ if [ "$(zfs get type -o value -H ${ROOT_DEV})" = 'filesystem' ] |
110 |
then |
111 |
got_good_root=1; |
112 |
REAL_ROOT=${ROOT_DEV} |
113 |
ROOTFSTYPE=zfs |
114 |
+ else |
115 |
+ bad_msg "${ROOT_DEV} is not a filesystem" |
116 |
+ prompt_user "REAL_ROOT" "root block device" |
117 |
+ got_good_root=0 |
118 |
+ continue |
119 |
fi |
120 |
else |
121 |
BOOTFS=$(/sbin/zpool list -H -o bootfs) |
122 |
@@ -563,7 +579,12 @@ do |
123 |
|
124 |
if [ "${ROOTFSTYPE}" = 'zfs' ] |
125 |
then |
126 |
- MOUNT_STATE=rw |
127 |
+ if [ "zfs get -H -o value mountpoint ${REAL_ROOT}" = 'legacy' ] |
128 |
+ then |
129 |
+ MOUNT_STATE=rw |
130 |
+ else |
131 |
+ MOUNT_STATE=rw,zfsutil |
132 |
+ fi |
133 |
else |
134 |
MOUNT_STATE=ro |
135 |
fi |