Fixes for Fedora; support Rocky Linux Live ISO
Signed-off-by: Maurice Zhou <jasper@apvc.uk>
This commit is contained in:
committed by
George Melikov
parent
9261cfb4f5
commit
ae7c5d19f4
@@ -1,4 +1,4 @@
|
||||
RHEL 8-based distro Root on ZFS
|
||||
Rocky Linux 8 Root on ZFS
|
||||
=======================================
|
||||
`Start here <RHEL%208-based%20distro%20Root%20on%20ZFS/0-overview.html>`__.
|
||||
|
||||
|
||||
@@ -6,15 +6,15 @@ Preparation
|
||||
.. contents:: Table of Contents
|
||||
:local:
|
||||
|
||||
#. Download a variant of Fedora 34 live image
|
||||
such as LXDE spin and boot from it.
|
||||
#. Download a variant of `Rocky Linux 8.4 Live
|
||||
ISO <https://dl.rockylinux.org/pub/rocky/8.4/Live/x86_64/>`__ and boot from it.
|
||||
|
||||
#. Disable Secure Boot. ZFS modules can not be loaded of Secure Boot is enabled.
|
||||
#. Set root password or ``/root/authorized_keys``.
|
||||
#. Start SSH server::
|
||||
|
||||
echo PermitRootLogin yes >> /etc/ssh/sshd_config
|
||||
systemctl start sshd
|
||||
systemctl restart sshd
|
||||
|
||||
#. Connect from another computer::
|
||||
|
||||
@@ -24,17 +24,17 @@ Preparation
|
||||
|
||||
setenforce 0
|
||||
|
||||
#. Install ``kernel-devel``::
|
||||
|
||||
source /etc/os-release
|
||||
dnf install -y https://dl.fedoraproject.org/pub/fedora/linux/releases/${VERSION_ID}/Everything/x86_64/os/Packages/k/kernel-devel-$(uname -r).rpm
|
||||
|
||||
#. Add ZFS repo::
|
||||
|
||||
dnf install -y https://zfsonlinux.org/fedora/zfs-release.fc${VERSION_ID}.noarch.rpm
|
||||
source /etc/os-release
|
||||
RHEL_ZFS_REPO=https://zfsonlinux.org/epel/zfs-release.el${VERSION_ID/./_}.noarch.rpm
|
||||
dnf install -y $RHEL_ZFS_REPO
|
||||
|
||||
#. Install ZFS packages::
|
||||
|
||||
dnf config-manager --disable zfs
|
||||
dnf config-manager --enable zfs-kmod
|
||||
dnf install -y epel-release
|
||||
dnf install -y zfs
|
||||
|
||||
#. Load kernel modules::
|
||||
@@ -43,24 +43,13 @@ Preparation
|
||||
|
||||
#. Install helper script and partition tool::
|
||||
|
||||
dnf install -y arch-install-scripts gdisk
|
||||
rpm -ivh --nodeps https://dl.fedoraproject.org/pub/fedora/linux/releases/34/Everything/x86_64/os/Packages/a/arch-install-scripts-23-3.fc34.noarch.rpm
|
||||
dnf install -y gdisk dosfstools
|
||||
|
||||
#. Set RHEL version::
|
||||
|
||||
INST_RHEL_VER=8
|
||||
|
||||
#. Remove Fedora repo and install target distro repo, zfs repo::
|
||||
|
||||
rpm -qa | grep -E ^fedora | xargs -i{} rpm -e --nodeps {}
|
||||
rpm -e zfs-release
|
||||
ROCKY_REPO=https://dl.rockylinux.org/pub/rocky/8.4/BaseOS/x86_64/os/Packages/
|
||||
rpm -ivh \
|
||||
${ROCKY_REPO}rocky-gpg-keys-8.4-26.el8.noarch.rpm \
|
||||
${ROCKY_REPO}rocky-release-8.4-26.el8.noarch.rpm \
|
||||
${ROCKY_REPO}rocky-repos-8.4-26.el8.noarch.rpm
|
||||
RHEL_ZFS_REPO=https://zfsonlinux.org/epel/zfs-release.el8_4.noarch.rpm
|
||||
dnf install -y ${RHEL_ZFS_REPO} epel-release
|
||||
|
||||
#. Unique pool suffix. ZFS expects pool names to be
|
||||
unique, therefore it's recommended to create
|
||||
pools with a unique suffix::
|
||||
@@ -89,7 +78,7 @@ Preparation
|
||||
DISK=(/dev/disk/by-id/disk1)
|
||||
|
||||
#. Choose a primary disk. This disk will be used
|
||||
for primary EFI partition and hibernation, default to
|
||||
for primary EFI partition, default to
|
||||
first disk in the array::
|
||||
|
||||
INST_PRIMARY_DISK=${DISK[0]}
|
||||
@@ -106,6 +95,24 @@ Preparation
|
||||
|
||||
INST_VDEV=
|
||||
|
||||
This will create a single vdev with the topology of your choice.
|
||||
It is also possible to manually create a pool with multiple vdevs, such as::
|
||||
|
||||
zpool create --options \
|
||||
poolName \
|
||||
mirror sda sdb \
|
||||
raidz2 sdc ... \
|
||||
raidz3 sde ... \
|
||||
spare sdf ...
|
||||
|
||||
Notice the cost of parity when using RAID-Z. See
|
||||
`here <https://www.delphix.com/blog/delphix-engineering/zfs-raidz-stripe-width-or-how-i-learned-stop-worrying-and-love-raidz>`__
|
||||
and `here <https://docs.google.com/spreadsheets/d/1tf4qx1aMJp8Lo_R6gpT689wTjHv6CGVElrPqTA0w_ZY/>`__.
|
||||
|
||||
Refer to `zpoolconcepts <https://openzfs.github.io/openzfs-docs/man/7/zpoolconcepts.7.html>`__
|
||||
and `zpool-create <https://openzfs.github.io/openzfs-docs/man/8/zpool-create.8.html>`__
|
||||
man pages for details.
|
||||
|
||||
#. Set partition size:
|
||||
|
||||
Set ESP size::
|
||||
|
||||
@@ -70,25 +70,12 @@ System Installation
|
||||
#. Create root pool::
|
||||
|
||||
zpool create \
|
||||
-d \
|
||||
-o feature@empty_bpobj=enabled \
|
||||
-o feature@lz4_compress=enabled \
|
||||
-o feature@spacemap_histogram=enabled \
|
||||
-o feature@enabled_txg=enabled \
|
||||
-o feature@hole_birth=enabled \
|
||||
-o feature@extensible_dataset=enabled \
|
||||
-o feature@embedded_data=enabled \
|
||||
-o feature@large_dnode=enabled \
|
||||
-o feature@userobj_accounting=enabled \
|
||||
-o feature@encryption=enabled \
|
||||
-o feature@project_quota=enabled \
|
||||
-o feature@spacemap_v2=enabled \
|
||||
-o ashift=12 \
|
||||
-o autotrim=on \
|
||||
-R /mnt \
|
||||
-O acltype=posixacl \
|
||||
-O canmount=off \
|
||||
-O compression=lz4 \
|
||||
-O compression=zstd \
|
||||
-O dnodesize=auto \
|
||||
-O normalization=formD \
|
||||
-O relatime=on \
|
||||
@@ -232,15 +219,16 @@ System Installation
|
||||
|
||||
#. Install base packages::
|
||||
|
||||
dnf --installroot=/mnt --releasever=${INST_RHEL_VER} -y install dnf
|
||||
dnf --installroot=/mnt --releasever=${INST_RHEL_VER} -y install \
|
||||
${RHEL_ZFS_REPO} @core epel-release grub2-efi-x64 grub2-pc-modules grub2-efi-x64-modules shim-x64 efibootmgr
|
||||
dnf config-manager --installroot=/mnt --disable zfs
|
||||
dnf config-manager --installroot=/mnt --enable zfs-kmod
|
||||
dnf install --installroot=/mnt -y zfs zfs-dracut
|
||||
|
||||
#. Install bootloader, kernel and ZFS::
|
||||
If speed is slow, you can manually pick a fixed mirror
|
||||
from `mirrorlist <https://mirrors.rockylinux.org/mirrormanager/mirrors>`__
|
||||
and apply it::
|
||||
|
||||
cp /etc/resolv.conf /mnt/etc
|
||||
arch-chroot /mnt bash --login <<EOF
|
||||
dnf --releasever=${INST_RHEL_VER} -y install ${RHEL_ZFS_REPO} \
|
||||
@core epel-release \
|
||||
grub2-efi-x64 grub2-pc-modules grub2-efi-x64-modules shim-x64 efibootmgr \
|
||||
kernel kernel-devel
|
||||
dnf --releasever=${INST_RHEL_VER} -y install zfs zfs-dracut
|
||||
EOF
|
||||
sed -i 's|^mirrorlist=|#mirrorlist=|g' /etc/yum.repos.d/*
|
||||
sed -i 's|^#baseurl=|baseurl=|g' /etc/yum.repos.d/*
|
||||
sed -i 's|dl.rockylinux.org/$contentdir|mirrors.sjtug.sjtu.edu.cn/rocky|g' /etc/yum.repos.d/*
|
||||
|
||||
@@ -46,18 +46,22 @@ System Configuration
|
||||
#. Interactively set locale, keymap, timezone, hostname and root password::
|
||||
|
||||
rm -f /mnt/etc/localtime
|
||||
systemd-firstboot --root=/mnt --force --prompt --root-password=PASSWORD
|
||||
systemd-firstboot --root=/mnt --prompt --root-password=PASSWORD
|
||||
|
||||
This can be non-interactive, see man page for details::
|
||||
|
||||
rm -f /mnt/etc/localtime
|
||||
systemd-firstboot --root=/mnt --force \
|
||||
systemd-firstboot --root=/mnt \
|
||||
--locale="en_US.UTF-8" --locale-messages="en_US.UTF-8" \
|
||||
--keymap=us --timezone="Europe/Berlin" --hostname=myHost \
|
||||
--root-password=PASSWORD --root-shell=/bin/bash
|
||||
--root-password=PASSWORD
|
||||
|
||||
``systemd-firstboot`` have bugs, root password is set below.
|
||||
|
||||
#. Generate host id::
|
||||
|
||||
zgenhostid -f -o /mnt/etc/hostid
|
||||
|
||||
#. Install locale package, example for English locale::
|
||||
|
||||
dnf --installroot=/mnt install -y glibc-minimal-langpack glibc-langpack-en
|
||||
@@ -72,6 +76,7 @@ System Configuration
|
||||
disable SSH server::
|
||||
|
||||
systemctl disable sshd --root=/mnt
|
||||
systemctl enable firewalld --root=/mnt
|
||||
|
||||
#. Chroot::
|
||||
|
||||
@@ -79,27 +84,20 @@ System Configuration
|
||||
INST_LINVAR=$INST_LINVAR
|
||||
INST_UUID=$INST_UUID
|
||||
INST_ID=$INST_ID
|
||||
unalias -a
|
||||
INST_VDEV=$INST_VDEV
|
||||
TERM=xterm" > /mnt/root/chroot
|
||||
echo DISK=\($(for i in ${DISK[@]}; do printf "$i "; done)\) >> /mnt/root/chroot
|
||||
arch-chroot /mnt bash --login
|
||||
unalias -a
|
||||
|
||||
#. Source variables::
|
||||
|
||||
source /root/chroot
|
||||
|
||||
#. Relabel filesystem on reboot::
|
||||
#. For SELinux, relabel filesystem on reboot::
|
||||
|
||||
fixfiles -F onboot
|
||||
|
||||
#. Set root password::
|
||||
|
||||
passwd
|
||||
|
||||
#. Build modules::
|
||||
|
||||
ls -1 /lib/modules \
|
||||
| while read kernel_version; do
|
||||
dkms autoinstall -k $kernel_version
|
||||
done
|
||||
|
||||
@@ -54,9 +54,6 @@ Install GRUB
|
||||
dracut --force --kver $kernel_version
|
||||
done
|
||||
|
||||
#. When in doubt, install both legacy boot
|
||||
and EFI.
|
||||
|
||||
#. Load ZFS modules and disable BLS::
|
||||
|
||||
echo 'GRUB_ENABLE_BLSCFG=false' >> /etc/default/grub
|
||||
@@ -70,6 +67,9 @@ Install GRUB
|
||||
Boot environment-specific configuration (kernel, etc)
|
||||
is stored in ``/boot/grub2/grub.cfg``, enabling rollback.
|
||||
|
||||
#. When in doubt, install both legacy boot
|
||||
and EFI.
|
||||
|
||||
#. If using legacy booting, install GRUB to every disk::
|
||||
|
||||
for i in ${DISK[@]}; do
|
||||
@@ -104,6 +104,7 @@ Install GRUB
|
||||
#. For both legacy and EFI booting: mirror ESP content::
|
||||
|
||||
ESP_MIRROR=$(mktemp -d)
|
||||
unalias -a
|
||||
cp -r /boot/efi/EFI $ESP_MIRROR
|
||||
for i in /boot/efis/*; do
|
||||
cp -r $ESP_MIRROR/EFI $i
|
||||
|
||||
@@ -21,13 +21,14 @@ This section is also applicable if you are in
|
||||
#. On another computer, generate rescue image with::
|
||||
|
||||
pacman -S --needed mtools libisoburn grub
|
||||
grub-install
|
||||
grub-mkrescue -o grub-rescue.img
|
||||
dd if=grub-rescue.img of=/dev/your-usb-stick
|
||||
|
||||
Boot computer from the rescue media.
|
||||
Both legacy and EFI mode are supported.
|
||||
|
||||
Skip this step if you are in GRUB rescue.
|
||||
Or `download generated GRUB rescue image <https://gitlab.com/m_zhou/bieaz/uploads/4a1b7cefb42723de6eb04f9dc485be3b/grub-rescue.img.7z>`__.
|
||||
|
||||
#. List available disks with ``ls`` command::
|
||||
|
||||
@@ -36,20 +37,6 @@ This section is also applicable if you are in
|
||||
|
||||
hd0 hd1 hd2 hd3
|
||||
|
||||
If you are dropped to GRUB rescue instead of
|
||||
booting from GRUB rescue image, boot disk can be found
|
||||
out with::
|
||||
|
||||
echo $root
|
||||
# cryto0
|
||||
# hd0,gpt2
|
||||
|
||||
GRUB configuration is loaded from::
|
||||
|
||||
echo $prefix
|
||||
# (crypto0)/sys/BOOT/default@/grub
|
||||
# (hd0,gpt2)/sys/BOOT/default@/grub
|
||||
|
||||
#. List partitions by pressing tab key:
|
||||
|
||||
.. code-block:: text
|
||||
@@ -94,12 +81,10 @@ This section is also applicable if you are in
|
||||
grub> ls (crypto0)/sys/BOOT
|
||||
@/ default/ be0/
|
||||
|
||||
#. Instruct GRUB to load configuration from ``be0`` boot environment
|
||||
then enter normal mode::
|
||||
#. Instruct GRUB to load configuration from ``be0`` boot environment::
|
||||
|
||||
grub> prefix=(crypto0)/sys/BOOT/be0/@/grub
|
||||
grub> insmod normal
|
||||
grub> normal
|
||||
grub> configfile $prefix/grub.cfg
|
||||
|
||||
#. GRUB menu should now appear.
|
||||
|
||||
@@ -188,7 +173,7 @@ Access system in chroot
|
||||
|
||||
#. chroot into the system::
|
||||
|
||||
rhel-chroot /mnt /bin/bash --login
|
||||
arch-chroot /mnt /bin/bash --login
|
||||
zfs mount -a
|
||||
mount -a
|
||||
|
||||
@@ -202,21 +187,21 @@ it is relatively easy to perform a system backup and migration.
|
||||
|
||||
#. Create a snapshot of root file system::
|
||||
|
||||
zfs snapshot -r rpool/rhel@backup
|
||||
zfs snapshot -r bpool/rhel@backup
|
||||
zfs snapshot -r rpool/arch@backup
|
||||
zfs snapshot -r bpool/arch@backup
|
||||
|
||||
#. Save snapshot to a file or pipe to SSH::
|
||||
|
||||
zfs send --options rpool/rhel@backup > /backup/rhel-rpool
|
||||
zfs send --options bpool/rhel@backup > /backup/rhel-bpool
|
||||
zfs send --options rpool/arch@backup > /backup/arch-rpool
|
||||
zfs send --options bpool/arch@backup > /backup/arch-bpool
|
||||
|
||||
#. Re-create partitions and root/boot
|
||||
pool on target system.
|
||||
|
||||
#. Restore backup::
|
||||
|
||||
zfs recv rpool_new/rhel < /backup/rhel-rpool
|
||||
zfs recv bpool_new/rhel < /backup/rhel-bpool
|
||||
zfs recv rpool_new/arch < /backup/arch-rpool
|
||||
zfs recv bpool_new/arch < /backup/arch-bpool
|
||||
|
||||
#. Chroot and reinstall bootloader.
|
||||
|
||||
|
||||
@@ -42,7 +42,8 @@ For RHEL/CentOS versions 6 and 7 run::
|
||||
|
||||
And for RHEL/CentOS 8 and newer::
|
||||
|
||||
dnf install https://zfsonlinux.org/epel/zfs-release$(rpm -E %distro).noarch.rpm
|
||||
source /etc/os-release
|
||||
dnf install https://zfsonlinux.org/epel/zfs-release.el${VERSION_ID/./_}.noarch.rpm
|
||||
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-zfsonlinux
|
||||
|
||||
After installing the *zfs-release* package and verifying the public key
|
||||
|
||||
Reference in New Issue
Block a user