-
-
Save rowlandwatkins/00198109a3d7cb9a36a5b6b89bfa8a9e to your computer and use it in GitHub Desktop.
installation of manjaro zfs root
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# =================================== | |
# Origianly from https://forum.manjaro.org/t/solved-manjaro-16-06-01-zfs-root-installation-problem/4469 | |
# =================================== | |
loadkeys us | |
systemctl enable --now systemd-timesyncd | |
pacman-mirrors --api --set-branch unstable --url http://ftp.cuhk.edu.hk/pub/Linux/manjaro | |
# =================================== | |
# Installed the system onto an USB drive, then | |
# =================================== | |
pacman -Sy archlinux-keyring manjaro-keyring manjarozfs zfs linux54-zfs | |
# pacman -Syy archlinux-keyring manjaro-keyring manjarozfs zfs mc rsync linux-headers manjaro-tools arch-install-scripts linux54-zfs | |
pacman-key --init | |
pacman-key --populate archlinux manjaro | |
pacman-key --refresh-keys | |
modprobe zfs | |
read -n 1 | |
# sfdisk -d /dev/nvme01 > nvme01.sfdisk | |
# sudo sfdisk /dev/sdX < sda.sfdisk | |
# =================================== | |
# Partition editing (way 1) | |
# =================================== | |
#Part Size Type | |
# ---- ---- ------------------------- | |
# 1 2M BIOS boot partition (ef02) | |
# 2 108M ext2 (bf00) | |
# 3 XXXG Solaris Root (bf00) | |
# | # to Refresh the kernel's view of the partition table. | |
# | partx -u /dev/nvme01p01 | |
# | # clear end of disk if needed | |
# | dd if=/dev/zero bs=512 seek=$((... - 1024)) of=/dev/sda | |
# | # to clear zfs labels | |
# | zpool labelclear [-f] /dev/sda | |
# clear partition table | |
# sgdisk --zap-all /dev/nvme01 | |
# create partition table | |
# parted /dev/nvme01 | |
# (parted)unit MiB | |
# (parted)mklabel gpt | |
# (parted)mkpart non-fs 1 3 | |
# (parted)mkpart primary 3 103 | |
# (parted)mkpart primary 103 100% | |
# (parted)set 1 bios_grub on | |
# (parted)set 3 boot on | |
# (parted)quit | |
# =================================== | |
# ZPOOL Create | |
# =================================== | |
zpool create -f -o ashift=12 -O acltype=posixacl -O canmount=off -O compression=lz4 -O dnodesize=auto -O normalization=formD -O relatime=on -O xattr=sa -O encryption=aes-256-gcm -O keylocation=prompt -O keyformat=passphrase pumpkin /dev/nvme0n1p2 | |
zfs create -o mountpoint=none zroot/DATA | |
zfs create -o mountpoint=none zroot/ROOT | |
zfs create -o compression=lz4 -o mountpoint=/ zroot/ROOT/manjaro | |
zfs create -o compression=lz4 -o mountpoint=/home zroot/DATA/home | |
zfs umount -a | |
zfs set mountpoint=/ zroot/ROOT/manjaro | |
zfs set mountpoint=legacy zroot/DATA/home | |
# =================================== | |
# SWAP | |
# =================================== | |
zfs create -V 3G -b $(getconf PAGESIZE) -o compression=off -o primarycache=metadata -o secondarycache=none -o sync=always -o com.sun:auto-snapshot=false zroot/swap | |
mkswap /dev/zvol/zroot/swap | |
# =================================== | |
# ZPOOL POST | |
# =================================== | |
zpool set bootfs=zroot/ROOT/manjaro zroot | |
zpool export zroot | |
zpool import -d /dev/nvmw0n1p2 -R /mnt zroot -l | |
# ! Can not import more than one mathcing names | |
# ! import by numeric ID instead | |
# ! do this | |
# ! zpool labelclear [-f] /dev/sda | |
# ! repeat previous | |
zpool set cachefile=/etc/zfs/zpool.cache zroot | |
# =================================== | |
# BOOT PARTITION | |
# =================================== | |
mkfs.fat -F 32 /dev/nvme0n1p1 | |
mkdir -p /mnt/boot | |
mkdir -p /mnt/boot/efi | |
mount /dev/nvme0n1p1 /mnt/boot | |
# =================================== | |
# INSTALL PACSTRAP | |
# =================================== | |
# pacstrap -i /mnt manjaro-system mc manjarozfs zfs manjaro-tools | |
basestrap /mnt base linux56 linux56-zfs systemd-boot-manager manjaro-zsh-config dhcpcd networkmanager grub mkinitcpio efibootmgr vi nano sudo links | |
genfstab -U /mnt >> /mnt/etc/fstab | |
# edited /mnt/etc/fstab (removed the zpool drives) | |
# add to fstab: | |
# zroot/DATA/home /home zfs rw,auto 0 0 | |
cp /etc/zfs/zpool.cache /mnt/etc/zfs/zpool.cache | |
# =================================== | |
# CHANGE ROOT | |
# =================================== | |
manjaro-chroot /mnt /bin/bash | |
export PS1="(ZFS root) $PS1" | |
# from the chroot | |
pacman -Syu | |
pacman -S file diffutils rxvt-unicode | |
pacman -S emacs | |
pacman -S manjarozfs zfs mc rsync linux-headers manjaro-tools arch-install-scripts grub linux56-zfs | |
# edited the mkinitcpio hooks: "…block keyboard zfs filesystems," | |
# | IF FINISH THIS DOC THEN | |
# | AFTER REBOOT GRUB ZFS IMPORT SHOWS ERROR | |
# | "libgcc_s.so.1 must be installed for pthread_cancel to work" | |
# | TO SOLVE PUT | |
# | FILES=("/usr/lib/libgcc_s.so.1") | |
# | into /etc/mkinitcpio.conf | |
# | then running mkinicpio -p linux | |
# | to test result | |
# | lsinitcpio /boot/initramfs-linux.img | grep gcc | |
# | usr/lib/libgcc_s.so.1 | |
echo pumpkin > /etc/hostname | |
chsh -s /bin/zsh | |
ln -sf /usr/share/zoneinfo/Asia/Hong_kong /etc/localtime | |
hwclock --systohc | |
systemctl enable NetworkManager | |
systemctl enable systemd-timesyncd | |
echo LANG=en_US.UTF-8 > /etc/locale.conf | |
emacs -nw /etc/mkinitcpio.conf | |
systemctl enable zfs.target | |
modprobe zfs | |
echo options zfs zfs_arc_min=268435456 >> /etc/modprobe.d/zfs.conf | |
echo options zfs zfs_arc_max=1073741824 >> /etc/modprobe.d/zfs.conf | |
passwd | |
# build kernel | |
mkinitcpio -P linux56 | |
# went without any error: | |
# =================================== | |
# SD Boot INSTALL | |
# =================================== | |
bootctl --path=/boot install | |
sdboot-manage gen | |
## grub-install --target=i386-pc --boot-directory=/boot --recheck --debug --force /dev/sda | |
# failed to find the caninical drive: | |
# BE SURE YOU ARE IN CHANGE ROOT!!!!! | |
## update-grub | |
# after the link, it was created the config without any problem: | |
## ln -s /dev/sda3 /dev/ata-Maxtor_6B300S0_B60TP9WH-part3 | |
# changing the grub.cfg | |
# 'root=ZFS=Zroo’t\ was changed to ‘zfs=zrooz’ | |
## sed -i -e 's/root=ZFS=zroot\//zfs=zroot/g' /boot/grub/grub.cfg | |
# needed a link because of the grub | |
## ln -s /dev/sda3 /dev/ata-Maxtor_6B300S0_B60TP9WH-part3 | |
## update-grub | |
# edit /etc/defaults/grub | |
## emacs -nw /etc/defaults/grub | |
## GRUB_GFXPAYLOAD_LINUX=keep | |
# Boot with systemd instead of sysvinit (openrc) | |
## GRUB_CMDLINE_LINUX="init=/lib/systemd/systemd dozfs=force zfsforce=yes" | |
#GRUB_CMDLINE_LINUX="init=/sbin/init dozfs=force dozfs=force zfsforce=yes" | |
# =================================== | |
# TO REBOOT | |
# =================================== | |
exit | |
sudo umount /mnt/boot | |
sudo zfs umount -a | |
sudo zpool export zroot | |
sudo reboot | |
# =================================== | |
# POSTINSTALL | |
# =================================== | |
# initialy pacman compile in /tmp | |
# which is in emory, and there will not be enought space | |
sudo emacs -nw /etc/makepkg.conf | |
# edit text | |
BUILDDIR=/var/tmp/makepkg | |
# swap | |
sudo mkswap /dev/zvol/zroot/swap | |
> Setting up swapspace version 1, size = 3 GiB (3221221376 bytes) | |
> no label, UUID=0d9a89c0-7434-4414-9f3a-a10006998ea5 | |
# enable it | |
swapon /dev/zvol/zroot/swap | |
# edit fstab | |
# swap | |
##UUID=0d9a89c0-7434-4414-9f3a-a10006998ea5 none swap sw 0 0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment