1 |
commit: 69d703093a5a6560988d077e57ddf69303d08906 |
2 |
Author: Richard Yao <ryao <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Sep 20 13:41:35 2015 +0000 |
4 |
Commit: Richard Yao <ryao <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Sep 20 14:09:37 2015 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=69d70309 |
7 |
|
8 |
Improve upon patch to read zpool.cache from the root pool at boot |
9 |
|
10 |
Signed-off-by: Richard Yao <ryao <AT> gentoo.org> |
11 |
|
12 |
defaults/initrd.scripts | 30 +++++++++++++++++++++--------- |
13 |
gen_initramfs.sh | 12 +----------- |
14 |
2 files changed, 22 insertions(+), 20 deletions(-) |
15 |
|
16 |
diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts |
17 |
index 55b7f57..9c0c290 100644 |
18 |
--- a/defaults/initrd.scripts |
19 |
+++ b/defaults/initrd.scripts |
20 |
@@ -1034,21 +1034,33 @@ startVolumes() { |
21 |
elif [ -z "${ZFS_POOL}" ] |
22 |
then |
23 |
bad_msg "Please boot with root=ZFS=\$DATASET" |
24 |
- else |
25 |
+ elif /sbin/zpool import -f -N -o readonly=on "${ZFS_POOL}" 2>&1 >/dev/null |
26 |
+ then |
27 |
mkdir -p /tmp/zfs |
28 |
- /sbin/zpool import -f -N -o readonly=on "${ZFS_POOL}" |
29 |
mount -o ro,zfsutil -t zfs "${REAL_ROOT#*=}" /tmp/zfs |
30 |
- if [ -e /tmp/zfs/etc/zfs/zpool.cache ] |
31 |
+ |
32 |
+ # Copy important files to /etc/zfs |
33 |
+ for i in zpool.cache zdev.conf |
34 |
+ do |
35 |
+ if [ -f /tmp/zfs/etc/zfs/${i} ] |
36 |
+ then |
37 |
+ good_msg "Reading ${i} from ${REAL_ROOT#*=}." |
38 |
+ cp "/tmp/zfs/etc/zfs/${i}" "/etc/zfs/${i}" |
39 |
+ fi |
40 |
+ done |
41 |
+ |
42 |
+ umount /tmp/zfs |
43 |
+ /sbin/zpool export -F "${ZFS_POOL}" |
44 |
+ |
45 |
+ if [ -f /etc/zfs/zpool.cache ] |
46 |
then |
47 |
- cp /tmp/zfs/etc/zfs/zpool.cache /tmp/zpool.cache |
48 |
- umount /tmp/zfs |
49 |
- /sbin/zpool export "${ZFS_POOL}" |
50 |
- /sbin/zpool import -c /tmp/zpool.cache -aN |
51 |
+ /sbin/zpool import -c /etc/zfs/zpool.cache -aN |
52 |
else |
53 |
- umount /tmp/zfs |
54 |
- /sbin/zpool export "${ZFS_POOL}" |
55 |
bad_msg "No /etc/zfs/zpool.cache in ${REAL_ROOT#*=}" |
56 |
+ |
57 |
fi |
58 |
+ else |
59 |
+ bad_msg "Failed to import ${ZFS_POOL}." |
60 |
fi |
61 |
fi |
62 |
} |
63 |
|
64 |
diff --git a/gen_initramfs.sh b/gen_initramfs.sh |
65 |
index 1b4afe6..bf1b495 100755 |
66 |
--- a/gen_initramfs.sh |
67 |
+++ b/gen_initramfs.sh |
68 |
@@ -442,19 +442,9 @@ append_zfs(){ |
69 |
rm -r "${TEMP}/initramfs-zfs-temp" |
70 |
fi |
71 |
|
72 |
+ # Populated during boot |
73 |
mkdir -p "${TEMP}/initramfs-zfs-temp/etc/zfs" |
74 |
|
75 |
- # Copy files to /etc/zfs |
76 |
- for i in zdev.conf |
77 |
- do |
78 |
- if [ -f /etc/zfs/${i} ] |
79 |
- then |
80 |
- print_info 1 " >> Including ${i}" |
81 |
- cp -a "/etc/zfs/${i}" "${TEMP}/initramfs-zfs-temp/etc/zfs" 2> /dev/null \ |
82 |
- || gen_die "Could not copy file ${i} for ZFS" |
83 |
- fi |
84 |
- done |
85 |
- |
86 |
# Copy binaries |
87 |
copy_binaries "${TEMP}/initramfs-zfs-temp" /sbin/{mount.zfs,zdb,zfs,zpool} |