Update Alpine, Arch, Fedora and RHEL root on ZFS guides
Signed-off-by: Maurice Zhou <jasper@apvc.uk>
This commit is contained in:
committed by
George Melikov
parent
a0c149af5b
commit
a69befb2ce
@@ -8,7 +8,8 @@ Preparation
|
||||
|
||||
#. Disable Secure Boot. ZFS modules can not be loaded if Secure Boot is enabled.
|
||||
#. Download a variant of `AlmaLinux Minimal Live ISO
|
||||
<https://repo.almalinux.org/almalinux/9/live/x86_64/>`__ and boot from it.
|
||||
<https://repo.almalinux.org/almalinux/9.1/live/x86_64/>`__
|
||||
and boot from it.
|
||||
#. Connect to the Internet.
|
||||
#. Set root password or ``/root/.ssh/authorized_keys``.
|
||||
#. Start SSH server::
|
||||
@@ -24,9 +25,9 @@ Preparation
|
||||
|
||||
List available disks with::
|
||||
|
||||
ls /dev/disk/by-id/*
|
||||
find /dev/disk/by-id/
|
||||
|
||||
If using virtio as disk bus, use ``/dev/disk/by-path/*``.
|
||||
If using virtio as disk bus, use ``/dev/disk/by-path/``.
|
||||
|
||||
Declare disk array::
|
||||
|
||||
@@ -38,11 +39,10 @@ Preparation
|
||||
|
||||
#. Set partition size:
|
||||
|
||||
Set swap size. It's `recommended <https://chrisdown.name/2018/01/02/in-defence-of-swap.html>`__
|
||||
to setup a swap partition. If you intend to use hibernation,
|
||||
the minimum should be no less than RAM size. Skip if swap is not needed::
|
||||
Set swap size, set to 1 if you don't want swap to
|
||||
take up too much space::
|
||||
|
||||
INST_PARTSIZE_SWAP=8
|
||||
INST_PARTSIZE_SWAP=4
|
||||
|
||||
Root pool size, use all remaining disk space if not set::
|
||||
|
||||
@@ -54,24 +54,21 @@ Preparation
|
||||
|
||||
SELinux will be enabled on the installed system.
|
||||
|
||||
#. Add ZFS repo::
|
||||
#. Add ZFS repo and install ZFS inside live system::
|
||||
|
||||
dnf install -y https://zfsonlinux.org/epel/zfs-release-2-2$(rpm --eval "%{dist}").noarch.rpm
|
||||
|
||||
#. Check available repos::
|
||||
|
||||
dnf repolist --all
|
||||
|
||||
#. Install ZFS packages::
|
||||
|
||||
rpm -e --nodeps zfs-fuse || true
|
||||
source /etc/os-release
|
||||
export VERSION_ID
|
||||
dnf config-manager --disable zfs
|
||||
dnf config-manager --enable zfs-kmod
|
||||
dnf install -y zfs
|
||||
|
||||
#. Load kernel modules::
|
||||
|
||||
modprobe zfs
|
||||
|
||||
#. Install partition tool::
|
||||
#. Install partition tool and arch-install-scripts::
|
||||
|
||||
dnf install -y gdisk dosfstools
|
||||
dnf install -y epel-release
|
||||
dnf install -y gdisk dosfstools arch-install-scripts
|
||||
dnf download arch-install-scripts
|
||||
rpm -i --nodeps arch-install-scripts*.rpm
|
||||
dnf remove -y epel-release
|
||||
|
||||
@@ -10,13 +10,18 @@ System Installation
|
||||
|
||||
for i in ${DISK}; do
|
||||
|
||||
# wipe flash-based storage device to improve
|
||||
# performance.
|
||||
# ALL DATA WILL BE LOST
|
||||
# blkdiscard -f $i
|
||||
|
||||
sgdisk --zap-all $i
|
||||
|
||||
sgdisk -n1:1M:+1G -t1:EF00 $i
|
||||
|
||||
sgdisk -n2:0:+4G -t2:BE00 $i
|
||||
|
||||
test -z $INST_PARTSIZE_SWAP || sgdisk -n4:0:+${INST_PARTSIZE_SWAP}G -t4:8200 $i
|
||||
sgdisk -n4:0:+${INST_PARTSIZE_SWAP}G -t4:8200 $i
|
||||
|
||||
if test -z $INST_PARTSIZE_RPOOL; then
|
||||
sgdisk -n3:0:0 -t3:BF00 $i
|
||||
@@ -25,6 +30,12 @@ System Installation
|
||||
fi
|
||||
|
||||
sgdisk -a1 -n5:24K:+1000K -t5:EF02 $i
|
||||
|
||||
sync && udevadm settle && sleep 3
|
||||
|
||||
cryptsetup open --type plain --key-file /dev/random $i-part4 ${i##*/}-part4
|
||||
mkswap /dev/mapper/${i##*/}-part4
|
||||
swapon /dev/mapper/${i##*/}-part4
|
||||
done
|
||||
|
||||
#. Create boot pool::
|
||||
@@ -84,16 +95,14 @@ System Installation
|
||||
|
||||
If not using a multi-disk setup, remove ``mirror``.
|
||||
|
||||
#. This section implements dataset layout as described in `overview <1-preparation.html>`__.
|
||||
|
||||
Create root system container:
|
||||
#. Create root system container:
|
||||
|
||||
- Unencrypted::
|
||||
|
||||
zfs create \
|
||||
-o canmount=off \
|
||||
-o mountpoint=none \
|
||||
rpool/redhat
|
||||
rpool/alma
|
||||
|
||||
- Encrypted:
|
||||
|
||||
@@ -106,20 +115,35 @@ System Installation
|
||||
-o encryption=on \
|
||||
-o keylocation=prompt \
|
||||
-o keyformat=passphrase \
|
||||
rpool/redhat
|
||||
rpool/alma
|
||||
|
||||
Create system datasets::
|
||||
You can automate this step (insecure) with: ``echo POOLPASS | zfs create ...``.
|
||||
|
||||
zfs create -o canmount=on -o mountpoint=/ rpool/redhat/root
|
||||
zfs create -o canmount=on -o mountpoint=/home rpool/redhat/home
|
||||
zfs create -o canmount=off -o mountpoint=/var rpool/redhat/var
|
||||
zfs create -o canmount=on rpool/redhat/var/lib
|
||||
zfs create -o canmount=on rpool/redhat/var/log
|
||||
Create system datasets, let Alma declaratively
|
||||
manage mountpoints with ``mountpoint=legacy``::
|
||||
|
||||
Create boot dataset::
|
||||
zfs create -o mountpoint=legacy rpool/alma/root
|
||||
mount -t zfs rpool/alma/root /mnt/
|
||||
zfs create -o mountpoint=legacy rpool/alma/home
|
||||
mkdir /mnt/home
|
||||
mount -t zfs -o zfsutil rpool/alma/home /mnt/home
|
||||
zfs create -o mountpoint=legacy rpool/alma/var
|
||||
zfs create -o mountpoint=legacy rpool/alma/var/lib
|
||||
zfs create -o mountpoint=legacy rpool/alma/var/log
|
||||
zfs create -o mountpoint=none bpool/alma
|
||||
zfs create -o mountpoint=legacy bpool/alma/root
|
||||
mkdir /mnt/boot
|
||||
mount -t zfs bpool/alma/root /mnt/boot
|
||||
|
||||
zfs create -o canmount=off -o mountpoint=none bpool/redhat
|
||||
zfs create -o canmount=on -o mountpoint=/boot bpool/redhat/root
|
||||
#. zfs-dracut requires root dataset to have a mountpoint
|
||||
other than legacy::
|
||||
|
||||
umount -Rl /mnt
|
||||
zfs set canmount=noauto rpool/alma/root
|
||||
zfs set mountpoint=/ rpool/alma/root
|
||||
mount -t zfs rpool/alma/root /mnt
|
||||
mount -t zfs rpool/alma/home /mnt/home
|
||||
mount -t zfs bpool/alma/root /mnt/boot
|
||||
|
||||
#. Format and mount ESP::
|
||||
|
||||
|
||||
@@ -8,28 +8,39 @@ System Configuration
|
||||
|
||||
#. Generate fstab::
|
||||
|
||||
mkdir -p /mnt/var/log
|
||||
mkdir -p /mnt/var/lib
|
||||
mount -t zfs rpool/alma/var/lib /mnt/var/lib
|
||||
mount -t zfs rpool/alma/var/log /mnt/var/log
|
||||
mkdir -p /mnt/etc/
|
||||
for i in ${DISK}; do
|
||||
echo UUID=$(blkid -s UUID -o value ${i}-part1) /boot/efis/${i##*/}-part1 vfat \
|
||||
umask=0022,fmask=0022,dmask=0022 0 1 >> /mnt/etc/fstab
|
||||
done
|
||||
echo $(echo $DISK | cut -f1 -d\ )-part1 /boot/efi vfat \
|
||||
noauto,umask=0022,fmask=0022,dmask=0022 0 1 >> /mnt/etc/fstab
|
||||
genfstab -t PARTUUID /mnt | grep -v swap > /mnt/etc/fstab
|
||||
sed -i "s|vfat.*rw|vfat rw,x-systemd.idle-timeout=1min,x-systemd.automount,noauto,nofail|" /mnt/etc/fstab
|
||||
|
||||
#. Install basic system packages::
|
||||
|
||||
dnf --installroot=/mnt \
|
||||
--releasever=$VERSION_ID -y install \
|
||||
@core grub2-efi-x64 \
|
||||
grub2-pc-modules grub2-efi-x64-modules \
|
||||
shim-x64 efibootmgr \
|
||||
kernel
|
||||
dnf --installroot=/mnt \
|
||||
--releasever=$VERSION_ID -y install \
|
||||
https://zfsonlinux.org/epel/zfs-release-2-2$(rpm --eval "%{dist}").noarch.rpm
|
||||
dnf config-manager --installroot=/mnt --disable zfs
|
||||
dnf config-manager --installroot=/mnt --enable zfs-kmod
|
||||
dnf --installroot=/mnt --releasever=$VERSION_ID \
|
||||
-y install zfs zfs-dracut
|
||||
|
||||
#. Configure dracut::
|
||||
|
||||
echo 'add_dracutmodules+=" zfs "' > /mnt/etc/dracut.conf.d/zfs.conf
|
||||
|
||||
#. Force load mpt3sas module if used::
|
||||
|
||||
if grep mpt3sas /proc/modules; then
|
||||
echo 'forced_drivers+=" mpt3sas "' >> /mnt/etc/dracut.conf.d/zfs.conf
|
||||
fi
|
||||
|
||||
#. Set locale, keymap, timezone, hostname and root password::
|
||||
|
||||
rm -f /mnt/etc/localtime
|
||||
systemd-firstboot --root=/mnt --prompt --root-password=PASSWORD --force
|
||||
if grep mpt3sas /proc/modules; then
|
||||
echo 'forced_drivers+=" mpt3sas "' >> /mnt/etc/dracut.conf.d/zfs.conf
|
||||
fi
|
||||
if grep virtio_blk /proc/modules; then
|
||||
echo 'filesystems+=" virtio_blk "' >> /mnt/etc/dracut.conf.d/fs.conf
|
||||
fi
|
||||
|
||||
#. Generate host id::
|
||||
|
||||
@@ -39,10 +50,6 @@ System Configuration
|
||||
|
||||
dnf --installroot=/mnt install -y glibc-minimal-langpack glibc-langpack-en
|
||||
|
||||
#. Enable ZFS services::
|
||||
|
||||
systemctl enable zfs-import-scan.service zfs-mount zfs-import.target zfs-zed zfs.target --root=/mnt
|
||||
|
||||
#. By default SSH server is enabled, allowing root login by password,
|
||||
disable SSH server::
|
||||
|
||||
@@ -51,16 +58,25 @@ System Configuration
|
||||
|
||||
#. Chroot::
|
||||
|
||||
m='/dev /proc /sys'
|
||||
for i in $m; do mount --rbind $i /mnt/$i; done
|
||||
|
||||
history -w /mnt/home/sys-install-pre-chroot.txt
|
||||
chroot /mnt /usr/bin/env DISK="$DISK" bash --login
|
||||
history -w /mnt/home/sys-install-pre-chroot.txt
|
||||
arch-chroot /mnt /usr/bin/env DISK="$DISK" bash --login
|
||||
|
||||
#. For SELinux, relabel filesystem on reboot::
|
||||
|
||||
fixfiles -F onboot
|
||||
|
||||
#. Generate initrd::
|
||||
|
||||
for directory in /lib/modules/*; do
|
||||
kernel_version=$(basename $directory)
|
||||
dracut --force --kver $kernel_version
|
||||
done
|
||||
|
||||
#. Set locale, keymap, timezone, hostname and root password::
|
||||
|
||||
rm -f /etc/localtime
|
||||
systemd-firstboot --prompt --root-password=PASSWORD --force
|
||||
|
||||
#. Set root password, the password set earlier does not work due to SELinux::
|
||||
|
||||
passwd
|
||||
|
||||
@@ -6,27 +6,6 @@ Bootloader
|
||||
.. contents:: Table of Contents
|
||||
:local:
|
||||
|
||||
|
||||
#. If using virtio disk, add driver to initrd::
|
||||
|
||||
echo 'filesystems+=" virtio_blk "' >> /etc/dracut.conf.d/fs.conf
|
||||
|
||||
#. Create empty cache file and generate initrd::
|
||||
|
||||
rm -f /etc/zfs/zpool.cache
|
||||
touch /etc/zfs/zpool.cache
|
||||
chmod a-w /etc/zfs/zpool.cache
|
||||
chattr +i /etc/zfs/zpool.cache
|
||||
|
||||
for directory in /lib/modules/*; do
|
||||
kernel_version=$(basename $directory)
|
||||
dracut --force --kver $kernel_version
|
||||
done
|
||||
|
||||
#. Load ZFS modules and disable BLS::
|
||||
|
||||
echo 'GRUB_ENABLE_BLSCFG=false' >> /etc/default/grub
|
||||
|
||||
#. Apply GRUB workaround::
|
||||
|
||||
echo 'export ZPOOL_VDEV_NAME_PATH=YES' >> /etc/profile.d/zpool_vdev_name_path.sh
|
||||
@@ -35,41 +14,39 @@ Bootloader
|
||||
# GRUB fails to detect rpool name, hard code as "rpool"
|
||||
sed -i "s|rpool=.*|rpool=rpool|" /etc/grub.d/10_linux
|
||||
|
||||
This workaround needs to be applied for every GRUB update, as the
|
||||
update will overwrite the changes.
|
||||
This ``sed`` workaround needs to be applied for every
|
||||
GRUB update, as the update will overwrite the
|
||||
changes.
|
||||
|
||||
#. Install GRUB::
|
||||
|
||||
export ZPOOL_VDEV_NAME_PATH=YES
|
||||
echo 'GRUB_ENABLE_BLSCFG=false' >> /etc/default/grub
|
||||
mkdir -p /boot/efi/almalinux/grub-bootdir/i386-pc/
|
||||
mkdir -p /boot/efi/almalinux/grub-bootdir/x86_64-efi/
|
||||
for i in ${DISK}; do
|
||||
grub2-install --target=i386-pc --boot-directory \
|
||||
/boot/efi/almalinux/grub-bootdir/i386-pc/ $i
|
||||
done
|
||||
|
||||
cp -r /usr/lib/grub/x86_64-efi/ /boot/efi/EFI/almalinux/
|
||||
|
||||
#. Generate GRUB menu::
|
||||
|
||||
grub2-mkconfig -o /boot/efi/EFI/almalinux/grub.cfg
|
||||
grub2-mkconfig -o /boot/efi/almalinux/grub-bootdir/i386-pc/grub2/grub.cfg
|
||||
grub2-mkconfig -o /boot/efi/EFI/almalinux/grub.cfg
|
||||
grub2-mkconfig -o /boot/efi/almalinux/grub-bootdir/i386-pc/grub2/grub.cfg
|
||||
|
||||
#. For both legacy and EFI booting: mirror ESP content::
|
||||
|
||||
ESP_MIRROR=$(mktemp -d)
|
||||
unalias -a
|
||||
ESP_MIRROR=$(mktemp -d)
|
||||
cp -r /boot/efi/EFI $ESP_MIRROR
|
||||
for i in /boot/efis/*; do
|
||||
cp -r $ESP_MIRROR/EFI $i
|
||||
done
|
||||
rm -rf $ESP_MIRROR
|
||||
|
||||
#. Notes for GRUB on RHEL
|
||||
#. Note: you need to regenerate GRUB menu after kernel
|
||||
updates, otherwise computer will still boot old
|
||||
kernel on reboot::
|
||||
|
||||
As bls is disabled, you will need to regenerate GRUB menu after each kernel upgrade.
|
||||
Or else the new kernel will not be recognized and system will boot the old kernel
|
||||
on reboot.
|
||||
grub2-mkconfig -o /boot/efi/EFI/almalinux/grub.cfg
|
||||
grub2-mkconfig -o /boot/efi/almalinux/grub-bootdir/i386-pc/grub2/grub.cfg
|
||||
|
||||
Finish Installation
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
@@ -87,16 +64,15 @@ Finish Installation
|
||||
|
||||
reboot
|
||||
|
||||
#. On first reboot, the boot process will fail, with failure messages such
|
||||
as "You are in Emergency Mode...Press Ctrl-D to continue".
|
||||
|
||||
Wait for the computer to automatically reboot and the problem will be resolved.
|
||||
|
||||
Post installaion
|
||||
~~~~~~~~~~~~~~~~
|
||||
#. Install package groups::
|
||||
|
||||
dnf group list --hidden -v # query package groups
|
||||
dnf group install @gnome-desktop
|
||||
dnf group install gnome-desktop
|
||||
|
||||
#. Add new user, configure swap.
|
||||
|
||||
#. You can create a snapshot of the newly installed
|
||||
system for later rollback,
|
||||
see `this page <https://openzfs.github.io/openzfs-docs/Getting%20Started/Arch%20Linux/Root%20on%20ZFS/6-create-boot-environment.html>`__.
|
||||
|
||||
@@ -26,19 +26,16 @@ encouraged to verify the authenticity of the ZFS on Linux public key using
|
||||
the fingerprint listed here.
|
||||
|
||||
| **Location:** /etc/pki/rpm-gpg/RPM-GPG-KEY-zfsonlinux
|
||||
| **EL6-8 Packages:** `zfs-release-el-2-1.noarch.rpm`
|
||||
| **Archived Repositories:** `el6`, `el7_5`_, `el7_6`_, `el7_7`_, `el7_8`_, `el8_0`_, `el8_1`_, `el8_2`_, `el8_3`_, `el8_4`_, `el8_5`_, `el8_6`_
|
||||
| **List of Repositories** `see repo page <https://github.com/zfsonlinux/zfsonlinux.github.com/tree/master/epel>`__
|
||||
| **Archived Repositories:** `see repo page <https://github.com/zfsonlinux/zfsonlinux.github.com/tree/master/epel>`__
|
||||
|
||||
| **Signing key1 (Centos 8 and older, Fedora 36 and older)**
|
||||
`pgp.mit.edu <https://pgp.mit.edu/pks/lookup?search=0xF14AB620&op=index&fingerprint=on>`__
|
||||
`direct link <https://raw.githubusercontent.com/zfsonlinux/zfsonlinux.github.com/master/zfs-release/RPM-GPG-KEY-openzfs-key1>`__
|
||||
| **Fingerprint:** C93A FFFD 9F3F 7B03 C310 CEB6 A9D5 A1C0 F14A B620
|
||||
|
||||
| **Signing key2 (Centos 9+, Fedora 37+)**
|
||||
`pgp.mit.edu <https://pgp.mit.edu/pks/lookup?search=0xA599FD5E9DB84141&op=index&fingerprint=on>`__
|
||||
`direct link <https://raw.githubusercontent.com/zfsonlinux/zfsonlinux.github.com/master/zfs-release/RPM-GPG-KEY-openzfs-key2>`__
|
||||
| **Fingerprint:** 7DC7 299D CF7C 7FD9 CD87 701B A599 FD5E 9DB8 4141
|
||||
|
||||
|
||||
For RHEL/CentOS versions 6 and 7 run::
|
||||
|
||||
yum install https://zfsonlinux.org/epel/zfs-release-2-2$(rpm --eval "%{dist}").noarch.rpm
|
||||
@@ -161,19 +158,5 @@ Start from "Preparation".
|
||||
|
||||
.. _kABI-tracking kmod: https://elrepoproject.blogspot.com/2016/02/kabi-tracking-kmod-packages.html
|
||||
.. _DKMS: https://en.wikipedia.org/wiki/Dynamic_Kernel_Module_Support
|
||||
.. _zfs-release-el-2-1.noarch.rpm: https://zfsonlinux.org/epel/zfs-release-el-2-1.noarch.rpm
|
||||
.. _el6: https://zfsonlinux.org/epel/zfs-release.el6.noarch.rpm
|
||||
.. _el7_5: https://zfsonlinux.org/epel/zfs-release.el7_5.noarch.rpm
|
||||
.. _el7_6: https://zfsonlinux.org/epel/zfs-release.el7_6.noarch.rpm
|
||||
.. _el7_7: https://zfsonlinux.org/epel/zfs-release.el7_7.noarch.rpm
|
||||
.. _el7_8: https://zfsonlinux.org/epel/zfs-release.el7_8.noarch.rpm
|
||||
.. _el7_9: https://zfsonlinux.org/epel/zfs-release.el7_9.noarch.rpm
|
||||
.. _el8_0: https://zfsonlinux.org/epel/zfs-release.el8_0.noarch.rpm
|
||||
.. _el8_1: https://zfsonlinux.org/epel/zfs-release.el8_1.noarch.rpm
|
||||
.. _el8_2: https://zfsonlinux.org/epel/zfs-release.el8_2.noarch.rpm
|
||||
.. _el8_3: https://zfsonlinux.org/epel/zfs-release.el8_3.noarch.rpm
|
||||
.. _el8_4: https://zfsonlinux.org/epel/zfs-release.el8_4.noarch.rpm
|
||||
.. _el8_5: https://zfsonlinux.org/epel/zfs-release.el8_5.noarch.rpm
|
||||
.. _el8_6: https://zfsonlinux.org/epel/zfs-release.el8_6.noarch.rpm
|
||||
|
||||
.. _EPEL repository: https://fedoraproject.org/wiki/EPEL
|
||||
|
||||
Reference in New Issue
Block a user