Last active
November 5, 2017 11:18
-
-
Save aaronlauterer/dc878ab3e048a8fcf032b2153c166603 to your computer and use it in GitHub Desktop.
ZFSRoot installation over a dm-crypt volume for Arch Linux (UEFI)
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
# arch uefi dm-crypt zfsroot install (archiso) | |
# modified to work with current repos as of 2016-06-16 and with hints from | |
# comments by larskotthoff | |
# uses only one boot partition for EFI and initramfs | |
# partition disk | |
# start at 1MB (sector 2048) | |
512Mib EFI | |
Rest ZFS | |
(parted) mklabel gpt | |
(parted) mkpart ESP fat32 1MiB 513MiB | |
(parted) set 1 boot on | |
(parted) mkpart primary ext2 513MiB 99% | |
#setup encrypted partition | |
cryptsetup luksFormat /dev/disk/by-uuid/<uid> | |
cryptsetup luksOpen /dev/disk/by-uuid/<uid> cryptroot | |
# set architecture to x86_64 | |
# and | |
# add unofficial archzfs repo | |
# edit /etc/pacman.conf | |
Architecture = x86_64 | |
[archzfs] | |
Server = http://archzfs.com/$repo/$arch | |
# add keys for archzfs repo | |
pacman-key -r 0ee7a126 | |
pacman-key --lsign-key 0ee7a126 | |
# edit /etc/pacman.d/mirrorlist to get only your nearest mirrors | |
# setup networking | |
# for wifi: | |
wifi-menu | |
# set nameserver | |
# edit /etc/resolve.conf | |
nameserver <ip> | |
# update package index | |
pacman -Syy | |
# install archzfs | |
# default: all | |
pacman -S archzfs-archiso-linux | |
modprobe zfs | |
# zfs setup | |
touch /etc/zfs/zpool.cache | |
#setup ZFS (ashift for modern drives, ssd) | |
# -o ashift=12 when using a 4k device | |
zpool create -o cachefile=/etc/zfs/zpool.cache -m none -R /mnt zroot /dev/mapper/cryptroot | |
zfs create -o mountpoint=none -o compression=lz4 zroot/ROOT | |
#rootfs | |
# DONT'T CREATE extra /usr on arch, see here: | |
# - http://freedesktop.org/wiki/Software/systemd/separate-usr-is-broken/ | |
# - https://wiki.archlinux.org/index.php/Mkinitcpio | |
zfs create -o mountpoint=/ zroot/ROOT/default | |
zfs create -o mountpoint=/opt zroot/opt | |
#homedirs | |
zfs create -o mountpoint=/home zroot/home | |
zfs create -o mountpoint=/root zroot/home/root | |
zpool set bootfs=zroot zroot | |
# export and reimport pool, so you don't need to force next import | |
zpool export zroot | |
zpool import -R /mnt zroot | |
# mount boot partition | |
mkdir /mnt/boot | |
mount /dev/disk/by-uuid/<uid> /mnt/boot | |
# install base system | |
pacstrap -i /mnt base base-devel | |
# create fstab | |
genfstab -U -p /mnt | grep boot >> /mnt/etc/fstab | |
# chroot into installation | |
arch-chroot /mnt /bin/bash | |
# set locale | |
# edit /etc/locale.gen | |
en_US.UTF-8 UTF-8 | |
# or | |
en_IE.UTF-8 UTF-8 | |
# generate locale | |
locale-gen | |
# set default language | |
echo LANG=en_US.UTF-8 > /etc/locale.conf | |
# or | |
echo LANG=en_IE.UTF-8 > /etc/locale.conf | |
# set timezone | |
ln -s /usr/share/zoneinfo/Europe/Vienna /etc/localtime | |
# set hardware clock | |
hwclock --systohc --utc | |
# install ntp | |
pacman -S ntp | |
# add country pools to conf | |
# nano /etc/ntp.conf | |
# sync time | |
ntpd -q | |
# save to hardware clock | |
hwclock -w | |
# set keymap and font | |
loadkeys us | |
setfont Lat2-Terminus16 | |
# save keymap and font | |
# edit /etc/vconsole.conf | |
KEYMAP=us | |
FONT=Lat2-Terminus16 | |
# set architecture to x86_64 | |
# and | |
# add unofficial archzfs repo | |
# edit /etc/pacman.conf | |
Architecture = x86_64 | |
[archzfs] | |
Server = http://archzfs.com/$repo/$arch | |
# add keys for archzfs repo | |
pacman-key -r 0ee7a126 | |
pacman-key --lsign-key 0ee7a126 | |
# edit /etc/pacman.d/mirrorlist | |
# update package database | |
pacman -Syy | |
pacman -Su --ignore filesystem,bash | |
pacman -S bash | |
pacman -Su | |
# install other needed packages | |
pacman -S gnupg vim zfs-linux, tmux, rsync | |
# enable zfs automount | |
systemctl enable zfs.target | |
# add hooks for initramfs | |
# edit /etc/mkinitcpio.conf | |
# | |
# HOOKS=... keyboard before encrypt before zfs before filesystems. No fsck. | |
HOOKS="base udev autodetect modconf block keyboard encrypt zfs filesystems" | |
# make initramfs | |
mkinitcpio -p linux | |
# set root password | |
passwd | |
# set hostname | |
echo <name> > /etc/hostname | |
# EFISTUB refind | |
# | |
# install refind | |
pacman -S refind-efi | |
# create refind directories | |
mkdir -p /boot/EFI/refind/{drivers,icons} | |
# copy default files | |
cp /usr/share/refind/refind_<arch>.efi /boot/EFI/refind/ | |
cp /usr/share/refind/refind.conf-sample /boot/EFI/refind/refind.conf | |
cp /usr/share/refind/drivers/* /boot/EFI/refind/drivers/ | |
cp /usr/share/refind/icons/* /boot/EFI/refind/icons/ | |
cp /usr/share/refind/config/refind_linux.conf-sample /boot/refind_linux.conf | |
# edit /boot/refind_linux.conf | |
"Boot with defaults" "cryptdevice=/dev/disk/by-uuid/<uuid>:cryptoroot zfs=zroot/ROOT/default rw" | |
# add refind to efi | |
modprobe efivars | |
efibootmgr -c -d /dev/disk/by-id/<id> -p <efi_partition_nr> -l /EFI/refind/refind_<arch>.efi -L "rEFInd" | |
# if a no space error appears, tryo to delete dump files in /sys/firmware/efi/efivars | |
# install any software, for wifi: iw, wpa_supplicant, dialog | |
# exit chroot | |
# copy zpool.cache to chroot | |
# cp /etc/zfs/zpool.cache /mnt/etc/zfs/ | |
# umount /boot and /boot/efi | |
umount /mnt/boot/efi | |
umount /mnt/boot | |
# export zfs | |
zpool export zroot | |
# reboot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello please will you like to show me some help on my application PLEASE