Last active
May 29, 2023 19:52
-
-
Save hww/e28bf311fe241074a2343f50e2052d01 to your computer and use it in GitHub Desktop.
nstalation of manjaro zfs root
This file contains 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
# =================================== | |
# Origianly from https://forum.manjaro.org/t/solved-manjaro-16-06-01-zfs-root-installation-problem/4469 | |
# =================================== | |
sudo -i | |
# =================================== | |
# Installed the system onto an USB drive, then | |
# =================================== | |
pacman-mirrors -G | |
pacman -Syu | |
pacman -S manjarozfs zfs mc rsync linux-headers manjaro-tools arch-install-scripts | |
modprobe zfs | |
# If error: modprobe: FATAL: Module zfs not found in directory /lib/modules/4.14.14-1-MANJARO | |
pacman -S linux414-zfs | |
# =================================== | |
# 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/sda | |
| # 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/disk/by-id/scsi-SATA_disk1 | |
# create partition table | |
parted /dev/sda | |
(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 | |
# =================================== | |
ls -lh /dev/disk/by-id/ | |
sudo zpool create -f -o ashift=12 zroot /dev/disk/by-id/SATA_disk1-part3 | |
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 | |
# =================================== | |
sudo 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 | |
sudo mkswap /dev/zvol/zroot/swap | |
# =================================== | |
# ZPOOL POST | |
# =================================== | |
sudo zpool set bootfs=zroot/ROOT/manjaro zroot | |
sudo zpool export zroot | |
sudo zpool import -d /dev/disk/by-id -R /mnt zroot | |
! Can not import more than one mathcing names | |
! import by numeric ID instead | |
! do this | |
! zpool labelclear [-f] /dev/sda | |
! repeat previous | |
sudo zpool set cachefile=/etc/zfs/zpool.cache zroot | |
# =================================== | |
# BOOT PARTITION | |
# =================================== | |
mkfs.ext2 /dev/sda2 | |
sudo mkdir -p /mnt/boot | |
sudo mount /dev/sda2 /mnt/boot | |
# =================================== | |
# INSTALL PACSTRAP | |
# =================================== | |
sudo pacstrap -i /mnt manjaro-system mc manjarozfs zfs manjaro-tools | |
sudo 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 | |
sudo cp /etc/zfs/zpool.cache /mnt/etc/zfs/zpool.cache | |
# =================================== | |
# CHANGE ROOT | |
# =================================== | |
sudo 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 | |
# 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 | |
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 linux | |
# went without any error: | |
# =================================== | |
# GRUB INSTALL | |
# =================================== | |
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