A couple of install scripts/commands used while installing Manjaro linux with a ZFS root.
For Manjaro specific options:
But mostly following:
We'll need to be root for all this:
sudo -i
Initialize the live environment:
pamac install --no-upgrade linux610-zfs zfs-utils
modprobe zfs
Start by setting up the environment.
Important
Make sure the BOOT_DISK
and POOL_DISK
are set appropriately. The POOL
paths are just preference.
zgenhostid -f 0x00bab10c
source /etc/os-release
export ID
export BOOT_DEVID="nvme-Samsung_SSD_980_PRO_1TB_S5P2NG0R902580J"
export POOL_DEVID="${BOOT_DEVID}"
export BOOT_DISK="/dev/disk/by-id/${BOOT_DEVID}"
export POOL_DISK="/dev/disk/by-id/${POOL_DEVID}"
export BOOT_PART="1"
export POOL_PART="2"
export BOOT_DEVICE="${BOOT_DISK}-part${BOOT_PART}"
export POOL_DEVICE="${POOL_DISK}-part${POOL_PART}"
export POOL=system
export POOL_ROOT="${POOL}/root"
export POOL_OS="${POOL_ROOT}/${ID}"
export POOL_HOME="${POOL}/home"
Warning
This will clear the provided partitions.
If the disk is not yet partitioned for ZFS, run the following:
zpool labelclear -f "$POOL_DISK"
wipefs -a "$POOL_DISK"
wipefs -a "$BOOT_DISK"
sgdisk --zap-all "$POOL_DISK"
sgdisk --zap-all "$BOOT_DISK"
sgdisk -n "${BOOT_PART}:1m:+512m" -t "${BOOT_PART}:ef00" "$BOOT_DISK"
sgdisk -n "${POOL_PART}:0:-10m" -t "${POOL_PART}:bf00" "$POOL_DISK"
Update device symlinks
udevadm trigger
Create the zpool:
zpool create -f -o ashift=12 \
-O compression=lz4 \
-O acltype=posixacl \
-O xattr=sa \
-O relatime=on \
-o autotrim=on \
-m none $POOL "${POOL_DEVICE}"
zfs create -o mountpoint=none ${POOL_ROOT}
zfs create -o mountpoint=/ -o canmount=noauto ${POOL_OS}
zfs create -o mountpoint=/home ${POOL_HOME}
zpool set bootfs=${POOL_OS} ${POOL}
Set the linux kernel command-line arguments. This applies to all datasets under POOL_ROOT
. Adjust as necessary.
zfs set org.zfsbootmenu:commandline="quiet rhgb systemd.show_status=1 splash driver=nonfree nouveau.modeset=0 i915.modeset=1" ${POOL_ROOT}
Move pool to temporary mount point:
zpool export "${POOL}"
zpool import -N -R /mnt "${POOL}"
zfs mount "${POOL_OS}"
zfs mount "${POOL_HOME}"
Verify that everyting is mounted correctly:
mount | grep /mnt
This should should show the two datasets mounted in /mnt
.
Update device symlinks
udevadm trigger
Install Manjaro using Gnome, Nvidia drivers, and a few extra tools:
basestrap /mnt \
acpi \
acpid \
adw-gtk-theme \
amd-ucode \
archlinux-appstream-data \
archlinux-keyring \
b43-fwcutter \
base \
bibata-cursor-theme \
btrfs-progs \
cpupower \
cronie \
cryptsetup \
device-mapper \
diffutils \
dmidecode \
dmraid \
dnsmasq \
dosfstools \
e2fsprogs \
ecryptfs-utils \
efibootmgr \
evince \
exfatprogs \
f2fs-tools \
file-roller \
firefox \
fprintd \
gdm \
glibc-locales \
gnome-backgrounds \
gnome-browser-connector \
gnome-calculator \
gnome-calendar \
gnome-clocks \
gnome-control-center \
gnome-disk-utility \
gnome-firmware \
gnome-logs \
gnome-shell \
gnome-shell-extensions \
gnome-system-monitor \
gnome-terminal \
gnome-text-editor \
gnome-themes-extra \
gnome-tour \
gnome-tweaks \
gnome-user-docs \
gnome-weather \
grub \
grub-theme-manjaro \
gvfs \
htop \
ibus \
inetutils \
install-grub \
intel-ucode \
inxi \
jfsutils \
kvantum-manjaro \
less \
lib32-nvidia-utils \
linux610 \
linux610-nvidia \
linux610-zfs \
linux-api-headers \
linux-firmware \
linux-firmware-whence \
linux-meta-zfs \
logrotate \
lollypop \
lvm2 \
man-db \
manjaro-application-utility \
manjaro-base-skel \
manjaro-browser-settings \
manjaro-gnome-backgrounds \
manjaro-gnome-settings \
manjaro-hello \
manjaro-release \
manjaro-settings-manager \
manjaro-settings-manager-notifier \
manjaro-system \
manjaro-zsh-config \
man-pages \
mdadm \
memtest86+ \
memtest86+-efi \
mesa-utils \
mhwd \
mhwd-db \
mhwd-nvidia \
mhwd-nvidia-390xx \
mhwd-nvidia-470xx \
mkinitcpio-openswap \
nano \
nano-syntax-highlighting \
nautilus \
nautilus-empty-file \
networkmanager \
nfs-utils \
noto-fonts \
ntfs-3g \
nvidia-settings \
nvidia-utils \
openresolv \
os-prober \
pamac-gnome-integration \
pamac-gtk \
papirus-maia-icon-theme \
perl \
plymouth-theme-manjaro \
qt5ct \
qt6ct \
reiserfsprogs \
rsync \
s-nail \
sof-firmware \
sudo \
sushi \
sysfsutils \
texinfo \
tmux \
totem \
tracker3-miners \
tree \
ttf-dejavu \
ttf-droid \
ttf-hack \
ttf-liberation \
update-grub \
usbutils \
util-linux \
util-linux-libs \
vi \
vim \
wget \
which \
wireless-regdb \
wpa_supplicant \
xdg-user-dirs-gtk \
xfsprogs \
xorg-server \
zfs-utils \
Apply the desktop-overlay
to the install.
git clone https://gitlab.manjaro.org/profiles-and-settings/iso-profiles.git
rsync -av iso-profiles/manjaro/gnome/desktop-overlay/ /mnt
Copy a few local files:
cp -L /etc/resolv.conf /mnt/etc
cp /etc/hostid /mnt/etc
Chroot into the system:
manjaro-chroot /mnt /bin/bash
Reload environment:
source /etc/os-release
export ID
export BOOT_DEVID="nvme-Samsung_SSD_980_PRO_1TB_S5P2NG0R902580J"
export POOL_DEVID="${BOOT_DEVID}"
export BOOT_DISK="/dev/disk/by-id/${BOOT_DEVID}"
export POOL_DISK="/dev/disk/by-id/${POOL_DEVID}"
export BOOT_PART="1"
export POOL_PART="2"
export BOOT_DEVICE="${BOOT_DISK}-part${BOOT_PART}"
export POOL_DEVICE="${POOL_DISK}-part${POOL_PART}"
export POOL=system
export POOL_ROOT="${POOL}/root"
export POOL_OS="${POOL_ROOT}/${ID}"
export POOL_HOME="${POOL}/home"
Modify the /etc/mkinitcpio.conf
file. First add zfs
to MODULES
:
MODULES=(zfs)
Add zfs
after keyboard
and before filesystem
in HOOKS
. You can remove fsck
if you don’t have non-zfs filesystems. Also can remove keymap
and consolefont
. The HOOKS
line should look like this:
HOOKS=(base udev autodetect microcode modconf kms keyboard block zfs filesystems)
Then regenerate the initramfs:
mkinitcpio -P
Set a root password if you want to allow root login:
passwd
Add a user:
useradd -m -G lp,network,power,sys,wheel -s /bin/bash jeremy
passwd jeremy
Note
You'll probably need to enable the wheel
group by editing with visudo
.
Format the partition:
mkfs.vfat -F32 "$BOOT_DEVICE"
Create an fstab entry and mount:
cat << EOF >> /etc/fstab
$( blkid | grep $(readlink -f "$BOOT_DEVICE") | cut -d ' ' -f 2 ) /boot/efi vfat defaults 0 0
EOF
mkdir -p /boot/efi
mount /boot/efi
mkdir -p /boot/efi/EFI/ZBM
curl -o /boot/efi/EFI/ZBM/VMLINUZ.EFI -L https://get.zfsbootmenu.org/efi
cp /boot/efi/EFI/ZBM/VMLINUZ.EFI /boot/efi/EFI/ZBM/VMLINUZ-BACKUP.EFI
Configure EFI boot entries:
mount -t efivarfs efivarfs /sys/firmware/efi/efivars
Check for any existing boot entries:
efibootmgr | grep ZFSBootMenu
Note
Remove any existing entries with efibootmgr -B -b 000X
Add new boot entries:
efibootmgr -c -d "$BOOT_DISK" -p "$BOOT_PART" \
-L "ZFSBootMenu (Backup)" \
-l '\EFI\ZBM\VMLINUZ-BACKUP.EFI'
efibootmgr -c -d "$BOOT_DISK" -p "$BOOT_PART" \
-L "ZFSBootMenu" \
-l '\EFI\ZBM\VMLINUZ.EFI'
Exit chroot
exit
Unmount
umount -n -R /mnt
zfs unmount -a # may not be necessary
Export the zpool and reboot:
zpool export "${POOL}"
reboot