-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsd-zfs.initcpio.install
100 lines (87 loc) · 2.66 KB
/
sd-zfs.initcpio.install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/bash
build() {
local applet
# add parts of base hook:
# - busybox with applet symlinks
# - kmod with applet symlinks
# - blkid
add_binary /usr/lib/initcpio/busybox /usr/bin/busybox
for applet in $(/usr/lib/initcpio/busybox --list); do
# do not add busybox symlinks over potentially real binaries
# (e.g. setfont added by sd-vconsole)
[[ -e "$BUILDROOT/usr/bin/$applet" ]] || \
add_symlink "/usr/bin/$applet" busybox
done
add_binary kmod
for applet in {dep,ins,rm,ls}mod mod{probe,info}; do
# these are the "real" things, no check is needed
add_symlink "/usr/bin/$applet" kmod
done
add_binary blkid
# Kernel modules
map add_module \
zfs \
spl \
# udev rules
map add_file \
/usr/lib/udev/rules.d/60-zvol.rules \
/usr/lib/udev/rules.d/69-vdev.rules \
/usr/lib/udev/rules.d/90-zfs.rules \
# systemd units
map add_systemd_unit \
systemd-udev-settle.service \
# ZFS binaries
map add_binary \
zpool \
zfs \
mount.zfs \
/usr/lib/udev/vdev_id \
/usr/lib/udev/zvol_id \
# Generator and support scripts
add_file /usr/lib/zfs/initcpio/zfs-root-generator /usr/lib/systemd/system-generators/
map add_file \
/usr/lib/zfs/initcpio/zfs-functions \
/usr/lib/zfs/initcpio/zfs-parse-cmdline \
/usr/lib/zfs/initcpio/zfs-prepare-rootfs \
# support binaries (tools) not part of busybox
# XXX: get rid of xargs (ask mkinitcpio-busybox to build xargs)
# XXX: get rid of stdbuf (debugging hack)
map add_binary \
systemd-escape \
xargs \
stdbuf \
/usr/lib/coreutils/libstdbuf.so \
# ZFS-relevant configuration files
local copied_files=(
# /etc/zfs/zpool.cache
# /etc/modprobe.d/{spl,zfs}.conf
/etc/hostid
)
for f in "${copied_files[@]}"; do
if [[ -e "$f" ]]; then
add_file "$f"
fi
done
# Synthesize hostid if necessary
if [[ ! -e /etc/hostid ]]; then
zgenhostid -o "${BUILDROOT}/etc/hostid" "$(hostid)"
fi
}
help() {
cat << EOF
This hook adds ZFS support for systemd-based initrd.
It has a hard dependency on the systemd hook. Since it's implemented
using shell scripts, it still requires busybox and will copy it to
the initrd if you don't have the base hook.
To use this hook, simply add it to your HOOKS array in mkinitcpio.conf.
You'll also need to change the kernel command line. The supported cmdline
formats are:
1. root=zfs, which imports all pools in initrd, searches for the
first pool with the bootfs property set, and then mounts bootfs as root.
2. root=zfs:poolname, which imports only the specified pool and then mounts
the pool's bootfs as root.
3. root=zfs:poolname/dataset, which imports only the specified pool and then
mounts the specified dataset as root.
EOF
}
# vim: ft=bash ts=8 noet: