@@ -10,13 +10,18 @@ System Installation
10
10
11
11
for i in ${DISK}; do
12
12
13
+ # wipe flash-based storage device to improve
14
+ # performance.
15
+ # ALL DATA WILL BE LOST
16
+ # blkdiscard -f $i
17
+
13
18
sgdisk --zap-all $i
14
19
15
20
sgdisk -n1:1M:+1G -t1:EF00 $i
16
21
17
22
sgdisk -n2:0:+4G -t2:BE00 $i
18
23
19
- test -z $INST_PARTSIZE_SWAP || sgdisk -n4:0:+${INST_PARTSIZE_SWAP}G -t4:8200 $i
24
+ sgdisk -n4:0:+${INST_PARTSIZE_SWAP}G -t4:8200 $i
20
25
21
26
if test -z $INST_PARTSIZE_RPOOL; then
22
27
sgdisk -n3:0:0 -t3:BF00 $i
@@ -25,17 +30,15 @@ System Installation
25
30
fi
26
31
27
32
sgdisk -a1 -n5:24K:+1000K -t5:EF02 $i
28
- done
29
33
30
- #. Probe new partitions::
34
+ sync && udevadm settle && sleep 3
31
35
32
- for i in ${DISK}; do
33
- partprobe $i
34
- done
35
- udevadm settle
36
- sync
36
+ cryptsetup open --type plain --key-file /dev/random $i-part4 ${i##*/}-part4
37
+ mkswap /dev/mapper/${i##*/}-part4
38
+ swapon /dev/mapper/${i##*/}-part4
39
+ done
37
40
38
- #. Create boot partition ::
41
+ #. Create boot pool ::
39
42
40
43
tee -a /root/grub2 <<EOF
41
44
# Features which are supported by GRUB2
@@ -52,27 +55,39 @@ System Installation
52
55
spacemap_histogram
53
56
EOF
54
57
55
- zpool create \
56
- -o compatibility=/root/grub2 \
57
- -o ashift=12 \
58
- -o autotrim=on \
59
- -O acltype=posixacl \
60
- -O canmount=off \
61
- -O compression=lz4 \
62
- -O devices=off \
63
- -O normalization=formD \
64
- -O relatime=on \
65
- -O xattr=sa \
66
- -O mountpoint=/boot \
67
- -R /mnt \
68
- bpool \
69
- mirror \
70
- $(for i in ${DISK}; do
71
- printf "$i-part2 ";
72
- done)
73
-
58
+ zpool create \
59
+ -o compatibility=/root/grub2 \
60
+ -o ashift=12 \
61
+ -o autotrim=on \
62
+ -O acltype=posixacl \
63
+ -O canmount=off \
64
+ -O compression=lz4 \
65
+ -O devices=off \
66
+ -O normalization=formD \
67
+ -O relatime=on \
68
+ -O xattr=sa \
69
+ -O mountpoint=/boot \
70
+ -R /mnt \
71
+ bpool \
72
+ mirror \
73
+ $(for i in ${DISK}; do
74
+ printf "$i-part2 ";
75
+ done)
76
+
74
77
If not using a multi-disk setup, remove ``mirror``.
75
78
79
+ You should not need to customize any of the options for the boot pool.
80
+
81
+ GRUB does not support all of the zpool features. See ``spa_feature_names``
82
+ in `grub-core/fs/zfs/zfs.c
83
+ <http://git.savannah.gnu.org/cgit/grub.git/tree/grub-core/fs/zfs/zfs.c#n276>`__.
84
+ This step creates a separate boot pool for ``/boot`` with the features
85
+ limited to only those that GRUB supports, allowing the root pool to use
86
+ any/all features.
87
+
88
+ Features enabled with ``-o compatibility=grub2`` can be seen
89
+ `here <https://github.com/openzfs/zfs/blob/master/cmd/zpool/compatibility.d/grub2>`__.
90
+
76
91
#. Create root pool::
77
92
78
93
zpool create \
@@ -95,36 +110,59 @@ System Installation
95
110
96
111
If not using a multi-disk setup, remove ``mirror``.
97
112
98
- #. This section implements dataset layout as described in `overview <1-preparation.html >`__.
99
-
100
- Create root system container:
113
+ #. Create root system container:
101
114
102
115
- Unencrypted::
103
116
104
117
zfs create \
105
118
-o canmount=off \
106
119
-o mountpoint=none \
107
- rpool/alpine
120
+ rpool/alpinelinux
121
+
122
+ - Encrypted:
108
123
109
- - Encrypted::
124
+ Pick a strong password. Once compromised, changing password will not keep your
125
+ data safe. See ``zfs-change-key(8) `` for more info::
110
126
111
127
zfs create \
112
128
-o canmount=off \
113
129
-o mountpoint=none \
114
130
-o encryption=on \
115
131
-o keylocation=prompt \
116
132
-o keyformat=passphrase \
117
- rpool/alpine
118
-
119
- #. Create datasets::
120
-
121
- zfs create -o canmount=on -o mountpoint=/ rpool/alpine/root
122
- zfs create -o canmount=on -o mountpoint=/home rpool/alpine/home
123
- zfs create -o canmount=off -o mountpoint=/var rpool/alpine/var
124
- zfs create -o canmount=on rpool/alpine/var/lib
125
- zfs create -o canmount=on rpool/alpine/var/log
126
- zfs create -o canmount=off -o mountpoint=none bpool/alpine
127
- zfs create -o canmount=on -o mountpoint=/boot bpool/alpine/root
133
+ rpool/alpinelinux
134
+
135
+ You can automate this step (insecure) with: ``echo POOLPASS | zfs create ... ``.
136
+
137
+ Create system datasets, let Alpinelinux declaratively
138
+ manage mountpoints with ``mountpoint=legacy ``::
139
+
140
+ zfs create -o mountpoint=legacy rpool/alpinelinux/root
141
+ mount -t zfs rpool/alpinelinux/root /mnt/
142
+ zfs create -o mountpoint=legacy rpool/alpinelinux/home
143
+ mkdir /mnt/home
144
+ mount -t zfs rpool/alpinelinux/home /mnt/home
145
+ mkdir -p /mnt/var/lib
146
+ mkdir -p /mnt/var/log
147
+ zfs create -o mountpoint=legacy rpool/alpinelinux/var
148
+ zfs create -o mountpoint=legacy rpool/alpinelinux/var/lib
149
+ zfs create -o mountpoint=legacy rpool/alpinelinux/var/log
150
+ zfs create -o mountpoint=none bpool/alpinelinux
151
+ zfs create -o mountpoint=legacy bpool/alpinelinux/root
152
+ mkdir /mnt/boot
153
+ mount -t zfs bpool/alpinelinux/root /mnt/boot
154
+
155
+ #. mkinitfs requires root dataset to have a mountpoint
156
+ other than legacy::
157
+
158
+ umount -Rl /mnt
159
+ zfs set canmount=noauto rpool/alpinelinux/root
160
+ zfs set mountpoint=/ rpool/alpinelinux/root
161
+ mount -t zfs -o zfsutil rpool/alpinelinux/root /mnt
162
+ mount -t zfs rpool/alpinelinux/home /mnt/home
163
+ mount -t zfs bpool/alpinelinux/root /mnt/boot
164
+ mount -t zfs rpool/alpinelinux/var/lib /mnt/var/lib
165
+ mount -t zfs rpool/alpinelinux/var/log /mnt/var/log
128
166
129
167
#. Format and mount ESP::
130
168
@@ -152,6 +190,10 @@ System Installation
152
190
153
191
GRUB installation will fail and will be reinstalled later.
154
192
193
+ #. Allow EFI system partition to fail at boot::
194
+
195
+ sed -i "s|vfat.*rw|vfat rw,nofail|" /mnt/etc/fstab
196
+
155
197
#. Chroot::
156
198
157
199
m='/dev /proc /sys'
@@ -161,36 +203,12 @@ System Installation
161
203
162
204
#. Rebuild initrd::
163
205
164
- mkdir -p /etc/zfs
165
- rm -f /etc/zfs/zpool.cache
166
- touch /etc/zfs/zpool.cache
167
- chmod a-w /etc/zfs/zpool.cache
168
- chattr +i /etc/zfs/zpool.cache
169
-
170
206
sed -i 's|zfs|nvme zfs|' /etc/mkinitfs/mkinitfs.conf
171
207
for directory in /lib/modules/*; do
172
208
kernel_version=$(basename $directory)
173
209
mkinitfs $kernel_version
174
210
done
175
211
176
- #. Enable dataset mounting at boot::
177
-
178
- rc-update add zfs-mount sysinit
179
-
180
- #. Replace predictable disk path with traditional disk path:
181
-
182
- For SATA drives::
183
-
184
- sed -i 's|/dev/disk/by-id/ata-.*-part|/dev/sda|' /etc/fstab
185
-
186
- For NVMe drives::
187
-
188
- sed -i 's|/dev/disk/by-id/nvme-.*-part|/dev/nvme0n1p|' /etc/fstab
189
-
190
- #. Mount datasets with zfsutil option::
191
-
192
- sed -i 's|,posixacl|,zfsutil,posixacl|' /etc/fstab
193
-
194
212
#. Apply GRUB workaround::
195
213
196
214
echo 'export ZPOOL_VDEV_NAME_PATH=YES' >> /etc/profile.d/zpool_vdev_name_path.sh
@@ -210,7 +228,6 @@ System Installation
210
228
211
229
#. Install GRUB::
212
230
213
- export ZPOOL_VDEV_NAME_PATH=YES
214
231
mkdir -p /boot/efi/alpine/grub-bootdir/i386-pc/
215
232
mkdir -p /boot/efi/alpine/grub-bootdir/x86_64-efi/
216
233
for i in ${DISK}; do
@@ -243,15 +260,15 @@ System Installation
243
260
244
261
#. Reboot::
245
262
246
- poweroff
263
+ reboot
247
264
248
- Disconnect the live media and other non-boot storage devices.
249
- Due to missing support of predictable device names in initrd,
250
- Alpine Linux will mount whichever disk appears to be /dev/sda or /dev/nvme0
251
- at /boot/efi at boot.
265
+ Post installaion
266
+ ~~~~~~~~~~~~~~~~
252
267
253
- Root filesystem at / and /boot are ZFS and imported via pool name thus not affected by the above restriction.
268
+ #. Setup graphical desktop::
254
269
255
- #. Post-install:
270
+ setup-desktop
256
271
257
- #. Setup swap.
272
+ #. You can create a snapshot of the newly installed
273
+ system for later rollback,
274
+ see `this page <https://openzfs.github.io/openzfs-docs/Getting%20Started/Arch%20Linux/Root%20on%20ZFS/6-create-boot-environment.html >`__.
0 commit comments