Difference between revisions of "Installing Arch Linux on ZFS"
(Get rid of unnecessary filesystems for root, add some troubleshoot info, fstab generation command changed) |
(Add merge template) |
||
(19 intermediate revisions by 8 users not shown) | |||
Line 1: | Line 1: | ||
[[Category:Getting and installing Arch]] | [[Category:Getting and installing Arch]] | ||
{{Article summary start}} | {{Article summary start}} | ||
− | {{Article summary text|This article describes the | + | {{Article summary text|This article describes the necessary procedures for installing Arch Linux onto a ZFS root filesystem.}} |
{{Article summary heading|Related}} | {{Article summary heading|Related}} | ||
{{Article summary wiki|ZFS}} | {{Article summary wiki|ZFS}} | ||
{{Article summary wiki|ZFS on FUSE}} | {{Article summary wiki|ZFS on FUSE}} | ||
{{Article summary end}} | {{Article summary end}} | ||
+ | |||
+ | {{Merge|ZFS|This article has too much duplicate installation information from the Beginners Guide.}} | ||
The [[Wikipedia:ZFS|Zettabyte File System (ZFS)]] is an advanced [[Wikipedia:Copy-on-write|copy-on-write]] filesystem designed to preserve data integrity from a multitude of possible corruption scenarios as well as provide simple administration features. ZFS makes disk administration effortless with support ZFS storage pools (zpools) and automatic mount handling. First released in 2005 for Solaris OS, ZFS has since become the flag bearer for next generation filesystems. | The [[Wikipedia:ZFS|Zettabyte File System (ZFS)]] is an advanced [[Wikipedia:Copy-on-write|copy-on-write]] filesystem designed to preserve data integrity from a multitude of possible corruption scenarios as well as provide simple administration features. ZFS makes disk administration effortless with support ZFS storage pools (zpools) and automatic mount handling. First released in 2005 for Solaris OS, ZFS has since become the flag bearer for next generation filesystems. | ||
Line 15: | Line 17: | ||
==Notes before installation== | ==Notes before installation== | ||
− | * This guide uses the unofficial archzfs repository hosted at http://demizerone.com/ | + | * This guide uses the unofficial archzfs repository hosted at http://demizerone.com/demz-repo-core. This repository is maintained by Jesus Alvarez and is signed with his PGP key: [http://pgp.mit.edu:11371/pks/lookup?op=vindex&search=0x5E1ABF240EE7A126 0EE7A126]. |
* The ZFS packages are tied to the kernel version they were built against. This means it will not be possible to perform kernel updates until new packages (or package sources) are released by the ZFS package maintainer. | * The ZFS packages are tied to the kernel version they were built against. This means it will not be possible to perform kernel updates until new packages (or package sources) are released by the ZFS package maintainer. | ||
Line 23: | Line 25: | ||
It is a good idea make an installation media with the needed software included. Otherwise, you will need the latest archiso installation media burned to a CD or a USB key. | It is a good idea make an installation media with the needed software included. Otherwise, you will need the latest archiso installation media burned to a CD or a USB key. | ||
− | To embed {{ic|zfs}} in the archiso, download the {{ic|archiso}} package. | + | To embed {{ic|zfs}} in the archiso, from an existing install, download the {{ic|archiso}} package. |
+ | # pacman -S archiso | ||
Start the process: | Start the process: | ||
− | + | # cp -r /usr/share/archiso/configs/releng /root/media | |
Edit the {{ic|packages.x86_64}} file adding those lines: | Edit the {{ic|packages.x86_64}} file adding those lines: | ||
− | + | spl-utils | |
− | + | spl | |
− | + | zfs-utils | |
− | + | zfs | |
Edit the {{ic|pacman.conf}} file adding those lines (TODO, correctly embed keys in the installation media?): | Edit the {{ic|pacman.conf}} file adding those lines (TODO, correctly embed keys in the installation media?): | ||
− | + | [demz-repo-archiso] | |
− | + | SigLevel = Never | |
− | + | Server = <nowiki>http://demizerone.com/$repo/$arch</nowiki> | |
Add other packages in {{ic|packages.both}}, {{ic|packages.i686}}, or {{ic|packages.x86_64}} if needed and create the image. | Add other packages in {{ic|packages.both}}, {{ic|packages.i686}}, or {{ic|packages.x86_64}} if needed and create the image. | ||
− | + | # ./build.sh -v | |
The image will be in the {{ic|/root/media/out}} directory. | The image will be in the {{ic|/root/media/out}} directory. | ||
− | More informations about the process can be read in [http://kroweer.wordpress.com/2011/09/07/creating-a-custom-arch-linux-live-usb/ this guide] or in the [Archiso] article. | + | More informations about the process can be read in [http://kroweer.wordpress.com/2011/09/07/creating-a-custom-arch-linux-live-usb/ this guide] or in the [[Archiso]] article. |
If you are installing onto a UEFI system, see [[Unified Extensible Firmware Interface#Create UEFI bootable USB from ISO]] for creating UEFI compatible installation media. | If you are installing onto a UEFI system, see [[Unified Extensible Firmware Interface#Create UEFI bootable USB from ISO]] for creating UEFI compatible installation media. | ||
Line 53: | Line 56: | ||
{{hc|# nano /etc/pacman.conf|<nowiki> | {{hc|# nano /etc/pacman.conf|<nowiki> | ||
− | [ | + | [demz-repo-core] |
− | Server = http://demizerone.com/$repo | + | Server = http://demizerone.com/$repo/$arch</nowiki> |
}} | }} | ||
+ | |||
+ | {{Note|You should change the repo name from 'demz-repo-core' to 'demz-repo-archiso' if you are using the standard Arch ISOs to install (didn't build your own, above)}} | ||
Next, add the archzfs maintainer's PGP key to the local trust: | Next, add the archzfs maintainer's PGP key to the local trust: | ||
Line 140: | Line 145: | ||
# zfs create zroot/home | # zfs create zroot/home | ||
# zfs create zroot/root | # zfs create zroot/root | ||
+ | <!-- Taken the following Swap info from https://wiki.archlinux.org/index.php/ZFS --> | ||
+ | === Swap partition === | ||
+ | |||
+ | ZFS does not allow to use swapfiles, but you can use a ZFS volume as swap partition. It is importart to set the ZVOL block size to match the system page size, for x86_64 systems that is 4k. | ||
+ | |||
+ | Create a 8gb zfs volume: | ||
+ | |||
+ | # zfs create -V 8G -b 4K <pool>/swap | ||
+ | |||
+ | Prepare it as swap partition: | ||
+ | |||
+ | # mkswap /dev/zvol/<pool>/swap | ||
+ | |||
+ | Enable swap: | ||
+ | |||
+ | # swapon /dev/zvol/<pool>/swap | ||
+ | |||
+ | To make it permament you need to edit your {{ic|/mnt/etc/fstab}} after pacstraping the system: | ||
+ | |||
+ | Add a line to {{ic|/mnt/etc/fstab}}: | ||
+ | |||
+ | /dev/zvol/<pool>/swap none swap defaults 0 0 | ||
For safety, unmount all zfs filesystems if they are mounted: | For safety, unmount all zfs filesystems if they are mounted: | ||
Line 165: | Line 192: | ||
{{Warning|Don't skip this, otherwise you will be required to use -f when importing your pools. This unloads the imported pool.}} | {{Warning|Don't skip this, otherwise you will be required to use -f when importing your pools. This unloads the imported pool.}} | ||
+ | {{Note|This might fail if you added a swap partition above. Need to turn it off with the ''swapoff'' command.}} | ||
Finally, re-import the pool, | Finally, re-import the pool, | ||
Line 190: | Line 218: | ||
==Install and configure the Arch Linux installation== | ==Install and configure the Arch Linux installation== | ||
− | Install the base packages | + | Install the base packages |
− | + | ||
− | # pacstrap -i /mnt base base-devel | + | # pacstrap -i /mnt base base-devel |
+ | The other packages will be installed in the chrooted environment | ||
Generate the fstab, | Generate the fstab, | ||
Line 208: | Line 237: | ||
# arch-chroot /mnt /bin/bash | # arch-chroot /mnt /bin/bash | ||
− | Next, follow the [[Beginners' Guide]] from the "Locale" section to the "Configure Pacman Section". Once done, edit {{ic|pacman.conf}}, add the archzfs | + | Next, follow the [[Beginners' Guide]] from the "Locale" section to the "Configure Pacman Section". Once done, edit {{ic|pacman.conf}}, add the archzfs repo (change it to {{ic|[demz-repo-core]}} now if you were using {{ic|[demz-repo-archiso]}} earlier), and update the pacman database, |
# pacman -Syy | # pacman -Syy | ||
+ | # pacman -Su --ignore filesystem,bash | ||
+ | # pacman -S bash | ||
+ | # pacman -Su | ||
+ | |||
+ | Now lets install the other needed packages. | ||
+ | # pacman -S gnupg vim archzfs | ||
− | Re-create the initramfs, edit {{ic|/etc/mkinitcpio.conf}} and add {{ic|zfs}} before filesystems. Also, move {{ic|keyboard}} hook before {{ic|zfs}} so you can type in console if something goes wrong. | + | Re-create the initramfs, edit {{ic|/etc/mkinitcpio.conf}} and add {{ic|zfs}} before filesystems. Also, move {{ic|keyboard}} hook before {{ic|zfs}} so you can type in console if something goes wrong. You may also remove fsck. Your HOOKS line should look something like this:{{hc|/etc/mkinitcpio.conf|<nowiki> |
+ | HOOKS="base udev autodetect modconf block keyboard zfs filesystems" | ||
+ | </nowiki> | ||
+ | }} | ||
+ | Regenerate the initramfs with the command: | ||
# mkinitcpio -p linux | # mkinitcpio -p linux |
Revision as of 19:49, 15 July 2013
Template:Article summary start Template:Article summary text Template:Article summary heading Template:Article summary wiki Template:Article summary wiki Template:Article summary end
The Zettabyte File System (ZFS) is an advanced copy-on-write filesystem designed to preserve data integrity from a multitude of possible corruption scenarios as well as provide simple administration features. ZFS makes disk administration effortless with support ZFS storage pools (zpools) and automatic mount handling. First released in 2005 for Solaris OS, ZFS has since become the flag bearer for next generation filesystems.
ZFS was first developed and released by Sun (now owned by Oracle) as Open Source Software licensed under the Common Development and Distribution License (CDDL) which is famously incompatible with the GNU Public License. This incompatibility prevents ZFS from being merged into the mainline kernel, and generally presents some obstacles for users that want to use ZFS in Linux.
ZFSonLinux.org is a project funded by the Lawrence Livermore National Laboratory to develop a native Linux kernel module for its massive storage requirements and super computers.
Contents
- 1 Notes before installation
- 2 Boot from the installation media
- 3 Setup pacman
- 4 Install needed packages
- 5 Partition the destination drive
- 6 Format the destination disk
- 7 Setup the ZFS filesystem
- 8 Mount the boot partitions
- 9 Install and configure the Arch Linux installation
- 10 Setup the bootloader
- 11 Unmount and restart
- 12 Troubleshooting
- 13 See also
Notes before installation
- This guide uses the unofficial archzfs repository hosted at http://demizerone.com/demz-repo-core. This repository is maintained by Jesus Alvarez and is signed with his PGP key: 0EE7A126.
- The ZFS packages are tied to the kernel version they were built against. This means it will not be possible to perform kernel updates until new packages (or package sources) are released by the ZFS package maintainer.
Boot from the installation media
It is a good idea make an installation media with the needed software included. Otherwise, you will need the latest archiso installation media burned to a CD or a USB key.
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
Edit the pacman.conf
file adding those lines (TODO, correctly embed keys in the installation media?):
[demz-repo-archiso] 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.
More informations about the process can be read in this guide or in the Archiso article.
If you are installing onto a UEFI system, see Unified Extensible Firmware Interface#Create UEFI bootable USB from ISO for creating UEFI compatible installation media.
Setup pacman
Activate the required network connection and then edit /etc/pacman.d/mirrorlist
and configure the mirrors for pacman to use. Once that is done, edit /etc/pacman.conf
and add the archzfs repository:
# nano /etc/pacman.conf
[demz-repo-core] Server = http://demizerone.com/$repo/$arch
Next, add the archzfs maintainer's PGP key to the local trust:
# pacman-key -r 0EE7A126 # pacman-key --lsign-key 0EE7A126
Finally, update the pacman databases,
# pacman -Syy
Install needed packages
This is also the best time to install your favorite text editor, otherwise nano will have to be used.
# pacman -S archzfs dosfstools gptfdisk vim
Partition the destination drive
UEFI systems
Use the cgdisk partition utility and create a GPT partition table:
Part Size Type ==== ===== ============= 1 512M EFI (ef00) 2 512M Ext4 (8300) 2 XXXG Solaris Root (bf00)
BIOS systems
Part Size Type ==== ===== ============= 2 1007K BIOS Boot Partition (ef02) 1 512M Ext4 (8300) 3 XXXG Solaris Root (bf00)
Format the destination disk
UEFI systems
Format the EFI partition to FAT32
mkfs.vfat -F 32 /dev/sda1 -n EFIBOOT
Format the Ext4 boot partition
mkfs.ext4 /dev/sda2 -L BOOT
BIOS systems
Format the Ext4 boot partition
mkfs.ext4 /dev/sda1 -L BOOT
sda1
because of the order we created the partitionsThe BIOS partition does not need a filesystem.
Setup the ZFS filesystem
First, make sure the ZFS modules are loaded,
# modprobe zfs
Create the root zpool
# zpool create zroot /dev/disk/by-id/<id-to-partition>
Create necessary filesystems
If so desired, sub-filesystem mount points such as /home and /root can be created with the following commands:
# zfs create zroot/home # zfs create zroot/root
Swap partition
ZFS does not allow to use swapfiles, but you can use a ZFS volume as swap partition. It is importart to set the ZVOL block size to match the system page size, for x86_64 systems that is 4k.
Create a 8gb zfs volume:
# zfs create -V 8G -b 4K <pool>/swap
Prepare it as swap partition:
# mkswap /dev/zvol/<pool>/swap
Enable swap:
# swapon /dev/zvol/<pool>/swap
To make it permament you need to edit your /mnt/etc/fstab
after pacstraping the system:
Add a line to /mnt/etc/fstab
:
/dev/zvol/<pool>/swap none swap defaults 0 0
For safety, unmount all zfs filesystems if they are mounted:
# zfs umount -a
Configure the root filesystem
Now it is time to set the mount point of the root filesystem:
# zfs set mountpoint=/ zroot
and optionally, any sub-filesystems:
# zfs set mountpoint=/home zroot/home # zfs set mountpoint=/root zroot/root
Set the bootfs property on the descendant root filesystem so the boot loader knows where to find the operating system.
# zpool set bootfs=zroot zroot
Export the pool,
# zpool export zroot
Finally, re-import the pool,
# zpool import -d /dev/disk/by-id -R /mnt zroot
If there is an error in this step, you can export the pool to redo the command. The ZFS filesystem is now ready to use.
Mount the boot partitions
UEFI systems
# mkdir /mnt/boot # mount /dev/sda2 /mnt/boot # mkdir /mnt/boot/efi # mount /dev/sda1 /mnt/boot/efi
BIOS systems
# mkdir /mnt/boot # mount /dev/sda1 /mnt/boot
Install and configure the Arch Linux installation
Install the base packages
# pacstrap -i /mnt base base-devel
The other packages will be installed in the chrooted environment
Generate the fstab,
# genfstab -U -p /mnt | grep boot >> /mnt/etc/fstab
If installing on a UEFI system, you will need to load the efivars kernel module before chrooting into the installation:
# modprobe efivars
Chroot into the installation
# arch-chroot /mnt /bin/bash
Next, follow the Beginners' Guide from the "Locale" section to the "Configure Pacman Section". Once done, edit pacman.conf
, add the archzfs repo (change it to [demz-repo-core]
now if you were using [demz-repo-archiso]
earlier), and update the pacman database,
# pacman -Syy # pacman -Su --ignore filesystem,bash # pacman -S bash # pacman -Su Now lets install the other needed packages. # pacman -S gnupg vim archzfsRe-create the initramfs, 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. You may also remove fsck. Your HOOKS line should look something like this:/etc/mkinitcpio.conf
HOOKS="base udev autodetect modconf block keyboard zfs filesystems"
Regenerate the initramfs with the command:
# mkinitcpio -p linux
Finally, set root password and add a regular user.
Setup the bootloader
UEFI systems
Use EFISTUB and rEFInd for the UEFI boot loader. See Beginners' Guide#For UEFI motherboards. The kernel parameters in refind_linux.conf for zfs should include "zfs=bootfs", or "zfs=zroot", so the system can boot from ZFS. The 'root' and 'rootfstype' parameters aren't needed.
BIOS systems
Follow the Grub2#BIOS_systems_2 wiki. grub-mkconfig
fails for me, so I edited grub.cfg
manually.
/boot/grub/grub.cfg
set timeout=2 set default=0 # (0) Arch Linux menuentry "Arch Linux" { set root=(hd0,1) linux /vmlinuz-linux zfs=zroot initrd /initramfs-linux.img }
Unmount and restart
This is it, we are done!
# exit # umount /mnt/boot # zfs umount -a # zpool export zroot # reboot
Troubleshooting
If the new installation does not boot because the zpool cannot be imported, you will need to chroot into the installation and properly export the zpool. See ZFS#Emergency chroot repair with archzfs.
Once inside the chroot environment, load the ZFS module and force import the zpool,
# zpool import -a -f
now export the pool:
# zpool export <pool>
To see your available pools, use,
# zpool status
It is necessary to export a pool because of the way ZFS uses the hostid to track the system the zpool was created on. The hostid is generated partly based on your network setup. During the installation in the archiso your network configuration could be different generating a different hostid than the one contained in your new installation. Once the zfs filesystem is exported and then re-imported in the new installation, the hostid is reset. See Re: Howto zpool import/export automatically? - msg#00227.
If ZFS complains about "pool may be in use" after every reboot, you should properly export pool as described above, and then rebuild ramdisk in normally booted system:
# mkinitcpio -p linux