Installare Arch Linux su ZFS

Da GolemWiki.
Versione del 9 feb 2014 alle 12:01 di $pooky Hunter (discussione | contributi) (Creata pagina con '= 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 distribu...')
(diff) ← Versione meno recente | Versione attuale (diff) | Versione più recente → (diff)
Jump to navigation Jump to search

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:

  1. 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.

  1. pacman -S archiso

Start the process:

  1. 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.

  1. ./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.

  1. systemctl enable sshd.service
  2. systemctl start sshd.service


  1. Create a bios_grub partition (type EF02) starting at 1MB with size 64MB. The
  2. 1MB offset is to ensure proper sector alignment for SSD's and other 4k sector drives.
  3. After the utility partition, the rest of the drive is setup for ZFS. Repeat for all
  4. 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


  1. Create a pool:
   $ zpool create rpool sda2
  1. 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
                                            1. $ zfs set canmount=off rpool
   $ zfs create -o mountpoint=legacy rpool/ROOT
   $ zpool set bootfs=rpool/ROOT rpool
   
  1. Now mount the root filesystem in the usual spot:
   $ mount -t zfs rpool/ROOT /mnt


  1. In addition to the root dataset, we'll create several other datasets to help keep things organized.
  2. 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


  1. 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


  1. pacstrap /mnt base base-devel


  1. #
  2. CHROOT #
  3. #
  1. arch-chroot /mnt


  1. zpool set cachefile=/etc/zfs/rpool.cache rpool


I don't have uefi so I install the regular grub

  1. pacman -S grub


                                                    1. DIVERSAMENTE ########################################################
  1. mkdir /boot/EFI
  2. mount /dev/sda1 /boot/EFI
  3. grub-install --target=x86_64-efi --efi-directory=$esp --bootloader-id=grub --recheck --debug
  4. grub-mkconfig -o /boot/grub/grub.cfg


  1. 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

  1. pacman -Sy
  2. pacman -S archzfs


To regenerate the initramfs with the command:

  1. mkinitcpio -p linux
  1. ln -s /usr/share/zoneinfo/Europe/Rome /etc/localtime
  1. 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


  1. grub-mkconfig -o /boot/grub/grub.cfg
  2. grub-install /dev/sda

Add zfs=bootfs to the kernel line of grub.cfg


  1. systemctl enable zfs.service
  1. exit
  2. zfs unmount -a
  3. zfs set mountpoint=/ rpool
  1. cp /etc/zfs/rpool.cache /mnt/etc/zfs/rpool.cache
  1. 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.

  1. hostid > /etc/hostid
  2. 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