Installare Arch Linux su ZFS
Requisiti
- Un sistema funzionante con Arch Linux x86_64
- Almeno 4 GB di RAM
Installation media
Dato che lo ZFS non è ufficialmente supportato da nessuna distribuzione Linux, tantomento da Arch, sarà necessario realizzare un'immagine live appositamente per questo scopo.
Archiso
A tale scopo, Arch Linux mette a disposizione un pacchetto denominato Archiso che contiene una serie di script per realizzare supporti per l'installazione.
# pacman -S archiso
Start the process:
- cp -r /usr/share/archiso/configs/releng /root/media
Embed the archzfs packages into an archiso It is a good idea make an installation media with the needed software included. Otherwise, the latest archiso installation media burned to a CD or a USB key is required. To embed zfs in the archiso, from an existing install, download the archiso package.
- pacman -S archiso
Start the process:
- cp -r /usr/share/archiso/configs/releng /root/media
Edit the packages.x86_64 file adding those lines: spl-utils spl zfs-utils zfs net-tools
Edit the pacman.conf file adding those lines (TODO, correctly embed keys in the installation media?): [demz-repo-core] SigLevel = Never Server = http://demizerone.com/$repo/$arch
Add other packages in packages.both, packages.i686, or packages.x86_64 if needed and create the image.
- ./build.sh -v
The image will be in the /root/media/out directory.
Boot with the new media.
Choose x86_64, I suggest to set a root password, enable ssh daemon and do the install process from another computer so you can easily have paste and copy from this guide.
- systemctl enable sshd.service
- systemctl start sshd.service
- Create a bios_grub partition (type EF02) starting at 1MB with size 64MB. The
- 1MB offset is to ensure proper sector alignment for SSD's and other 4k sector drives.
- After the utility partition, the rest of the drive is setup for ZFS. Repeat for all
- drives to be used in the pool.
$ sgdisk \ --new=1:2048:133120 --typecode=1:EF02 --change-name=1:"grub" \ --largest-new=2 --typecode=2:BF01 --change-name=2:"zfs" \ /dev/sda
- Create a pool:
$ zpool create rpool sda2
- The zpool will initially be mounted at /rpool, but we need to move it to /mnt/ to work on it
$ zfs unmount rpool $ zfs set mountpoint=/mnt/ rpool
- $ zfs set canmount=off rpool
$ zfs create -o mountpoint=legacy rpool/ROOT $ zpool set bootfs=rpool/ROOT rpool
- Now mount the root filesystem in the usual spot:
$ mount -t zfs rpool/ROOT /mnt
- In addition to the root dataset, we'll create several other datasets to help keep things organized.
- Note that /bin, /boot, /sbin, /etc, /dev, /sys, and /proc must all be in the root dataset, not part of sub-datasets.
$ zfs create rpool/home $ zfs create rpool/usr/src $ zfs create rpool/var $ zfs create rpool/srv
- zpool set cachefile=/etc/zfs/rpool.cache rpool
Copy zpool.cache Now is also a good time to copy over the zpool cache so your initramfs will have access to it.
$ mkdir -p /mnt/etc/zfs $ cp /etc/zfs/rpool.cache /mnt/etc/zfs/rpool.cache
- pacstrap /mnt base base-devel
- #
- CHROOT #
- #
- arch-chroot /mnt
- zpool set cachefile=/etc/zfs/rpool.cache rpool
I don't have uefi so I install the regular grub
- pacman -S grub
- DIVERSAMENTE ########################################################
- mkdir /boot/EFI
- mount /dev/sda1 /boot/EFI
- grub-install --target=x86_64-efi --efi-directory=$esp --bootloader-id=grub --recheck --debug
- grub-mkconfig -o /boot/grub/grub.cfg
- nano /etc/fstab
rpool/ROOT / zfs noatime 0 0
Edit /etc/mkinitcpio.conf and add zfs before filesystems. Also, move keyboard hook before zfs so you can type in console if something goes wrong. Your HOOKS line should look something like this:
HOOKS="base udev autodetect modconf block keyboard zfs filesystems"
Edit the pacman.conf in the chroot adding those lines
[demz-repo-core] Server = http://demizerone.com/$repo/$arch SigLevel = Never
- pacman -Sy
- pacman -S archzfs
To regenerate the initramfs with the command:
- mkinitcpio -p linux
- ln -s /usr/share/zoneinfo/Europe/Rome /etc/localtime
- nano /etc/vconsole.conf
KEYMAP=it
Create Swap (Optional)
Running swap in ZVOL will currently deadlock when the system grows into swap.
If you NEED swap, you must create separate partitions for it and setup mdadm in necessary.
Swap can be run from with the zpool as a zvol:
# Set size as desired. Checksum'ing isn't necessary for swap and turning it off improves performance.
$ zfs create -V 2G rpool/swap $ zfs set checksum=off rpool/swap $ swapon /dev/rpool/swap $ echo "/dev/rpool/swap none swap sw 0 0" >> /mnt/etc/fstab
- grub-mkconfig -o /boot/grub/grub.cfg
- grub-install /dev/sda
Add zfs=bootfs to the kernel line of grub.cfg
- systemctl enable zfs.service
- exit
- zfs unmount -a
- zfs set mountpoint=/ rpool
- cp /etc/zfs/rpool.cache /mnt/etc/zfs/rpool.cache
- zpool export rpool
After the first boot
If everything went fine up to this point, your system will boot. Once. For your system to be able to reboot without issues, you need to enable the zfs service and set the hostid. When running ZFS on root, the machine's hostid will not be available at the time of mounting the root filesystem. There are two solutions to this. You can either place your spl hostid in the kernel parameters in your boot loader. For example, adding spl.spl_hostid=0x00bab10c. The other solution is to make sure that there is a hostid in /etc/hostid, and then regenerate the initramfs image. Which will copy the hostid into the initramfs image.
- hostid > /etc/hostid
- mkinitcpio -p linux
BIBLIOGRAFIA https://github.com/pendor/gentoo-zfs-install/blob/master/install/GentooInstall.mdown https://github.com/zfsonlinux/pkg-zfs/wiki/HOWTO-install-Ubuntu-to-a-Native-ZFS-Root-Filesystem http://www.howtoforge.com/a-beginners-guide-to-btrfs https://wiki.archlinux.org/index.php/Installing_Arch_Linux_on_ZFS https://bbs.archlinux.org/viewtopic.php?pid=1365007#p1365007