Last active
October 25, 2025 02:36
-
-
Save johnramsden/2128a1a8a9b100537f17b4cbb26070cb to your computer and use it in GitHub Desktop.
Revisions
-
John Ramsden revised this gist
Jun 23, 2016 . 1 changed file with 6 additions and 12 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -9,12 +9,6 @@ DISK_1="ata-SanDisk_SDSSDXPS480G_152271401093" DISK_2="ata-SanDisk_SDSSDXPS480G_154501401266" POOL="vault" # Check for zfs modprobe zfs @@ -93,8 +87,8 @@ mount "/dev/${BOOT_PARTITION}" /boot # Generate the fstab genfstab -U -p /mnt >> /mnt/etc/fstab # Comment out all non-legacy datasets apart from the root dataset, # the swap file and the boot/EFI partition. nano /mnt/etc/fstab # Edit mirrorlist @@ -103,10 +97,10 @@ nano /etc/pacman.d/mirrorlist # Install the base system pacstrap -i /mnt base base-devel # Edit ramdisk hooks # If you are using a separate dataset for /usr, have the usr hook enabled after zfs # If using a separate dataset for /var, add shutdowm hook # HOOKS="base udev autodetect modconf block keyboard zfs usr filesystems shutdown" nano /mnt/etc/mkinitcpio.conf # Enter chroot -
johnramsden revised this gist
Jun 23, 2016 . 3 changed files with 4 additions and 19 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -15,16 +15,6 @@ POOL="vault" # DISK_2="${3}" # POOL="${4}" # Check for zfs modprobe zfs @@ -66,14 +56,12 @@ zfs create "${POOL}/usr" -o mountpoint=legacy zfs umount -a # Put them in /etc/fstab nano /etc/fstab # <pass><file system> <dir> <type> <options> <dump> # vault/ROOT/default / zfs rw,relatime,xattr,noacl 0 0 # vault/var /var zfs rw,relatime,xattr,noacl 0 0 # vault/usr /usr zfs rw,relatime,xattr,noacl 0 0 # set boot property zpool set bootfs="${POOL}/ROOT/default" ${POOL} @@ -107,12 +95,10 @@ genfstab -U -p /mnt >> /mnt/etc/fstab echo "Comment out all non-legacy datasets apart from the root dataset," echo "the swap file and the boot/EFI partition." nano /mnt/etc/fstab # Edit mirrorlist nano /etc/pacman.d/mirrorlist # Install the base system pacstrap -i /mnt base base-devel @@ -121,7 +107,6 @@ echo "Edit ramdisk hooks" echo "If you are using a separate dataset for /usr, have the usr hook enabled after zfs" echo "If using a separate dataset for /var, add shutdowm hook" echo 'HOOKS="base udev autodetect modconf block keyboard zfs usr filesystems shutdown"' nano /mnt/etc/mkinitcpio.conf # Enter chroot File renamed without changes.File renamed without changes. -
John Ramsden revised this gist
Jun 23, 2016 . 3 changed files with 93 additions and 67 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,41 @@ #!/bin/bash ## After reboot ## zpool set cachefile=/etc/zfs/zpool.cache vault systemctl enable zfs.target # To write the hostid file safely you need to use a small C program: #include <stdio.h> #include <errno.h> #include <unistd.h> # int main() { # int res; # res = sethostid(gethostid()); # if (res != 0) { # switch (errno) { # case EACCES: # fprintf(stderr, "Error! No permission to write the" # " file used to store the host ID.\n" # "Are you root?\n"); # break; # case EPERM: # fprintf(stderr, "Error! The calling process's effective" # " user or group ID is not the same as" # " its corresponding real ID.\n"); # break; # default: # fprintf(stderr, "Unknown error.\n"); # } # return 1; # } # return 0; # } # Copy it, save it as writehostid.c and compile it with gcc -o writehostid writehostid.c, finally execute it and regenerate the initramfs image: nano writehostid.c gcc -o writehostid writehostid.c chmod +x writehostid ./writehostid mkinitcpio -p linux This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,14 +1,30 @@ #!/bin/bash # Check before running, may need intervention # Pass in the following to the script, or hardcode it. # Uncomment if hardcoding input. BOOT_PARTITION="/dev/sdg1" DISK_1="ata-SanDisk_SDSSDXPS480G_152271401093" DISK_2="ata-SanDisk_SDSSDXPS480G_154501401266" POOL="vault" # # Uncomment if passing in input. # BOOT_PARTITION="${1}" # DISK_1="${2}" # DISK_2="${3}" # POOL="${4}" ask-edit(){ echo "Do you wish to edit ${1}?" select yn in "Yes" "No"; do case $yn in Yes ) nano ${1}; break;; No ) exit;; esac done } # Check for zfs modprobe zfs @@ -50,12 +66,14 @@ zfs create "${POOL}/usr" -o mountpoint=legacy zfs umount -a # Put them in /etc/fstab #nano /etc/fstab # <pass><file system> <dir> <type> <options> <dump> # vault/ROOT/default / zfs rw,relatime,xattr,noacl 0 0 # vault/var /var zfs rw,relatime,xattr,noacl 0 0 # vault/usr /usr zfs rw,relatime,xattr,noacl 0 0 ask-edit "/etc/fstab" # set boot property zpool set bootfs="${POOL}/ROOT/default" ${POOL} @@ -87,20 +105,23 @@ mount "/dev/${BOOT_PARTITION}" /boot # Generate the fstab genfstab -U -p /mnt >> /mnt/etc/fstab echo "Comment out all non-legacy datasets apart from the root dataset," echo "the swap file and the boot/EFI partition." #nano /mnt/etc/fstab ask-edit "/mnt/etc/fstab" # Edit mirrorlist #nano /etc/pacman.d/mirrorlist ask-edit "/etc/pacman.d/mirrorlist" # Install the base system pacstrap -i /mnt base base-devel echo "Edit ramdisk hooks" echo "If you are using a separate dataset for /usr, have the usr hook enabled after zfs" echo "If using a separate dataset for /var, add shutdowm hook" echo 'HOOKS="base udev autodetect modconf block keyboard zfs usr filesystems shutdown"' #nano /mnt/etc/mkinitcpio.conf ask-edit "/mnt/etc/mkinitcpio.conf" # Enter chroot This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ #!/bin/bash # Run in chroot # arch-chroot /mnt /bin/bash # Add the Arch ZFS repository to /etc/pacman.conf nano /etc/pacman.conf @@ -41,25 +41,27 @@ mkinitcpio -p linux # If intel cpu, set ucode as the first initrd in the bootloader pacman -S intel-ucode # Install systemd-boot to wherever esp mounted bootctl --path=/boot install # Bootloader entry # title Arch Linux # linux /vmlinuz-linux # initrd /intel-ucode.img # initrd /initramfs-linux.img # options zfs=vault/ROOT/default rw nano /loader/entries/Arch.conf ## Configure the network ## # Set the hostname to your liking: nano /etc/hostname ## /etc/hosts: static lookup table for host names ## <ip-address> <hostname.domain.org> <hostname> # 127.0.0.1 localhost.localdomain localhost # ::1 localhost.localdomain localhost # 192.168.0.2 Archon.localdomain Archon nano /etc/hosts # get nic ip link @@ -74,7 +76,7 @@ systemctl enable mkinitcpio-generate-shutdown-ramfs.service ## Install Done, Customize ## # Make a user pacman -S zsh sudo useradd -m -G wheel -s /usr/bin/zsh john passwd john EDITOR=nano visudo @@ -85,51 +87,13 @@ nano /etc/ssh/sshd_config # Done! exit umount /mnt/boot umount /mnt/home umount /mnt/tmp umount /mnt/usr umount /mnt/var zfs umount -a zpool export vault ## Reboot! -
johnramsden revised this gist
Jun 23, 2016 . 1 changed file with 135 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,135 @@ #!/bin/bash # Chroot in arch-chroot /mnt /bin/bash # Add the Arch ZFS repository to /etc/pacman.conf nano /etc/pacman.conf # [archzfs] # Server = http://archzfs.com/$repo/x86_64 # sign its key pacman-key -r 5E1ABF240EE7A126 && pacman-key --lsign-key 5E1ABF240EE7A126 # install zfs-linux pacman -Syyu pacman -S zfs-linux-git # For /tmp, mask (disable) systemd's automatic tmpfs-backed /tmp systemctl mask tmp.mount ## Install as normal ## nano /etc/pacman.d/mirrorlist # set locale, uncomment en_US.UTF-8 UTF-8 nano /etc/locale.gen # generate the new locales locale-gen # set locale, LANG refers to the first column of locale nano /etc/locale.conf # LANG=en_US.UTF-8 # timezone ln -s /usr/share/zoneinfo/Canada/Pacific /etc/localtime # set the time standard to UTC hwclock --systohc --utc ## Bootloader ## # re-generate the initramfs image mkinitcpio -p linux # If intel cpu, set ucode as the first initrd in the bootloader pacman -S intel-ucode # Install systemd-boot to wherever esp mounted bootctl --path=/mnt/efi install # Bootloader entry # # /mnt/efi/loader/entries/Archon.conf # title Archon default (Arch Linux) # linux /installs/Archon/vmlinuz-linux # initrd /installs/Archon/intel-ucode.img # initrd /installs/Archon/initramfs-linux.img # options zfs=vault/ARCHON/ROOT/default rw ## Configure the network ## # Set the hostname to your liking: nano /etc/hostname nano /etc/hosts ## /etc/hosts: static lookup table for host names ## <ip-address> <hostname.domain.org> <hostname> # 127.0.0.1 localhost.localdomain localhost # ::1 localhost.localdomain localhost # 192.168.0.2 Archon.localdomain Archon # get nic ip link # enable internet systemctl enable dhcpcd@eno1.service # root pass passwd # Set either shutdown hook or this systemctl enable mkinitcpio-generate-shutdown-ramfs.service ## Install Done, Customize ## # Make a user pacman -S zsh sudo useradd -m -G wheel -s /usr/bin/zsh john passwd john EDITOR=nano visudo nano /etc/pacman.conf pacman -S openssh systemctl enable sshd nano /etc/ssh/sshd_config # Done! exit umount /mnt/boot umount /mnt/mnt/efi umount /mnt/home :( umount /mnt/tmp umount /mnt/usr umount /mnt/var zfs umount -a zpool export vault # # After reboot zpool set cachefile=/etc/zfs/zpool.cache vault systemctl enable zfs.target # To write the hostid file safely you need to use a small C program: #include <stdio.h> #include <errno.h> #include <unistd.h> int main() { int res; res = sethostid(gethostid()); if (res != 0) { switch (errno) { case EACCES: fprintf(stderr, "Error! No permission to write the" " file used to store the host ID.\n" "Are you root?\n"); break; case EPERM: fprintf(stderr, "Error! The calling process's effective" " user or group ID is not the same as" " its corresponding real ID.\n"); break; default: fprintf(stderr, "Unknown error.\n"); } return 1; } return 0; } # Copy it, save it as writehostid.c and compile it with gcc -o writehostid writehostid.c, finally execute it and regenerate the initramfs image: nano writehostid.c gcc -o writehostid writehostid.c chmod +x writehostid ./writehostid mkinitcpio -p linux -
johnramsden renamed this gist
Jun 23, 2016 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
John Ramsden revised this gist
Jun 23, 2016 . 1 changed file with 47 additions and 185 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,74 +1,71 @@ #!/bin/bash # Check before running, may need intervention # Replace the following: BOOT_PARTITION="/dev/sdg1" DISK_1="ata-SanDisk_SDSSDXPS480G_152271401093" DISK_2="ata-SanDisk_SDSSDXPS480G_154501401266" # Replace with poolname. I use 'vault' here POOL="vault" # Check for zfs modprobe zfs # Create pool zpool create -f -o ashift=12 ${POOL} mirror ${DISK_1} ${DISK_2} ## Properties # Compression zfs set compression=on ${POOL} # Access time zfs set atime=on ${POOL} zfs set relatime=on ${POOL} # Create key datasets zfs create -o mountpoint=none "${POOL}/ROOT" zfs create -o mountpoint=legacy "${POOL}/ROOT/default" zfs create -o mountpoint=/home "${POOL}/home" ## Optional datasets ## # tmp zfs create "${POOL}/tmp" \ -o setuid=off \ -o devices=off \ -o sync=disabled \ -o mountpoint=/tmp # Mask systemd’s automatic tmpfs-backed tmp systemctl mask tmp.mount # var zfs create "${POOL}/var" \ -o xattr=sa \ -o mountpoint=legacy # usr zfs create "${POOL}/usr" -o mountpoint=legacy ## End Optional # Unmount pool zfs umount -a # Put them in /etc/fstab nano /etc/fstab # <pass><file system> <dir> <type> <options> <dump> # vault/ROOT/default / zfs rw,relatime,xattr,noacl 0 0 # vault/var /var zfs rw,relatime,xattr,noacl 0 0 # vault/usr /usr zfs rw,relatime,xattr,noacl 0 0 # set boot property zpool set bootfs="${POOL}/ROOT/default" ${POOL} ## Setup Installation ## # Export the pool zpool export ${POOL} # re-import the pool, zpool import -d /dev/disk/by-id -R /mnt ${POOL} # bring the zpool.cache file into your new system mkdir -p /mnt/etc/zfs @@ -78,167 +75,32 @@ cp /etc/zfs/zpool.cache /mnt/etc/zfs/zpool.cache # Mount legacy zfs mkdir /mnt/{home,var,usr,tmp,boot} mount -t zfs "${POOL}/home" "/mnt/home" mount -t zfs "${POOL}/var" "/mnt/var" mount -t zfs "${POOL}/usr" "/mnt/usr" mount -t zfs "${POOL}/tmp" "/mnt/tmp" # Boot mkdir -p /boot mount "/dev/${BOOT_PARTITION}" /boot # Generate the fstab genfstab -U -p /mnt >> /mnt/etc/fstab # Comment out all non-legacy datasets apart from the root dataset, # the swap file and the boot/EFI partition nano /mnt/etc/fstab # Edit mirrorlist nano /etc/pacman.d/mirrorlist # Install the base system pacstrap -i /mnt base base-devel # Edit ramdisk hooks # If you are using a separate dataset for /usr, have the usr hook enabled after zfs # If using a separate dataset for /var, add shutdowm hook # HOOKS="base udev autodetect modconf block keyboard zfs usr filesystems shutdown" nano /mnt/etc/mkinitcpio.conf # Enter Chroot -
johnramsden created this gist
Jun 22, 2016 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,244 @@ #!/bin/bash # Check before running, may need intervention # Check for zfs modprobe zfs # Create pool zpool create -f -o ashift=12 -o compression=on -o relatime=on vault mirror \ /dev/disk/by-id/ata-SanDisk_SDSSDXPS480G_152271401093 \ /dev/disk/by-id/ata-SanDisk_SDSSDXPS480G_154501401266 # zfs snapshot -r vault@fresh-pool ## Custom settings ## # Compression zfs set compression=on vault # Access time zfs set relatime=on vault # Create datasets zfs create -o mountpoint=none vault/ARCHON zfs create -o mountpoint=none vault/ARCHON/ROOT zfs create -o mountpoint=/ vault/ARCHON/ROOT/default zfs create -o mountpoint=/home vault/ARCHON/home ## Optional datasets ## # tmp zfs create vault/ARCHON/tmp \ -o setuid=off \ -o devices=off \ -o sync=disabled \ -o mountpoint=/tmp # var zfs create vault/ARCHON/var \ -o xattr=sa \ # http://www.nerdblog.com/2013/10/zfs-xattr-tuning-on-linux.html -o acltype=posixacl \ # Bad for replication -o mountpoint=/var #cannot receive acltype property on tank/backups/Archon/Replication: invalid property value #xattr=on #relatime=off # usr zfs create vault/ARCHON/usr -o mountpoint=/usr ## End Optional # Set mountpoints zfs set mountpoint=/ vault/ARCHON/ROOT/default zfs set mountpoint=legacy vault/ARCHON/home zfs set mountpoint=legacy vault/ARCHON/tmp zfs set mountpoint=legacy vault/ARCHON/var zfs set mountpoint=legacy vault/ARCHON/usr # Unmount pool zfs umount -a # Put them in /etc/fstab nano /etc/fstab # <pass><file system> <dir> <type> <options> <dump> vault/ARCHON/ROOT/default / zfs rw,relatime,xattr,noacl 0 0 vault/ARCHON/home /home zfs rw,relatime,xattr,noacl 0 0 vault/ARCHON/var /var zfs rw,relatime,xattr,posixacl 0 0 vault/ARCHON/usr /usr zfs rw,relatime,xattr,noacl 0 0 vault/ARCHON/tmp /tmp zfs rw,relatime,xattr,noacl 0 0 # set boot property zpool set bootfs=vault/ARCHON/ROOT/default vault # Export the pool zpool export vault # re-import the pool, zpool import -d /dev/disk/by-id -R /mnt vault # bring the zpool.cache file into your new system mkdir -p /mnt/etc/zfs cp /etc/zfs/zpool.cache /mnt/etc/zfs/zpool.cache # OR, if you do not have /etc/zfs/zpool.cache, create it: # zpool set cachefile=/etc/zfs/zpool.cache zroot # Mount legacy zfs mkdir /mnt/{home,var,usr,tmp,boot} mount -t zfs vault/ARCHON/home /mnt/home mount -t zfs vault/ARCHON/var /mnt/var mount -t zfs vault/ARCHON/usr /mnt/usr mount -t zfs vault/ARCHON/tmp /mnt/tmp # Boot mkdir -p /mnt/mnt/efi mount /dev/sdxY /mnt/mnt/efi # Replace /dev/sdxY! # bind mount mount --bind /mnt/mnt/efi/installs/Archon /mnt/boot # Generate the fstab genfstab -U -p /mnt >> /mnt/etc/fstab # Comment out all non-legacy datasets apart from the root dataset, # the swap file and the boot/EFI partition nano /mnt/etc/fstab # Edit mirrorlist nano /etc/pacman.d/mirrorlist # Install the base system pacstrap -i /mnt base base-devel # Edit ramdisk hooks # Add hooks after block: keyboard zfs usr filesystems # HOOKS="base udev autodetect modconf block keyboard zfs usr filesystems" # If you are using a separate dataset for /usr # have the usr hook enabled after zfs # If you keep /usr as a separate partition, you must adhere to the following requirements: # Enable mkinitcpio-generate-shutdown-ramfs.service or add the shutdown hook # https://wiki.archlinux.org/index.php/Mkinitcpio#.2Fusr_as_a_separate_partition nano /mnt/etc/mkinitcpio.conf # Chroot in arch-chroot /mnt /bin/bash # Add the Arch ZFS repository to /etc/pacman.conf nano /etc/pacman.conf # [archzfs] # Server = http://archzfs.com/$repo/x86_64 # sign its key pacman-key -r 5E1ABF240EE7A126 && pacman-key --lsign-key 5E1ABF240EE7A126 # install zfs-linux pacman -Syyu pacman -S zfs-linux-git # For /tmp, mask (disable) systemd's automatic tmpfs-backed /tmp systemctl mask tmp.mount ## Install as normal ## nano /etc/pacman.d/mirrorlist # set locale, uncomment en_US.UTF-8 UTF-8 nano /etc/locale.gen # generate the new locales locale-gen # set locale, LANG refers to the first column of locale nano /etc/locale.conf # LANG=en_US.UTF-8 # timezone ln -s /usr/share/zoneinfo/Canada/Pacific /etc/localtime # set the time standard to UTC hwclock --systohc --utc ## Bootloader ## # re-generate the initramfs image mkinitcpio -p linux # If intel cpu, set ucode as the first initrd in the bootloader pacman -S intel-ucode # Install systemd-boot to wherever esp mounted bootctl --path=/mnt/efi install # Bootloader entry # # /mnt/efi/loader/entries/Archon.conf # title Archon default (Arch Linux) # linux /installs/Archon/vmlinuz-linux # initrd /installs/Archon/intel-ucode.img # initrd /installs/Archon/initramfs-linux.img # options zfs=vault/ARCHON/ROOT/default rw ## Configure the network ## # Set the hostname to your liking: nano /etc/hostname nano /etc/hosts ## /etc/hosts: static lookup table for host names ## <ip-address> <hostname.domain.org> <hostname> # 127.0.0.1 localhost.localdomain localhost # ::1 localhost.localdomain localhost # 192.168.0.2 Archon.localdomain Archon # get nic ip link # enable internet systemctl enable dhcpcd@eno1.service # root pass passwd # Set either shutdown hook or this systemctl enable mkinitcpio-generate-shutdown-ramfs.service ## Install Done, Customize ## # Make a user pacman -S zsh sudo useradd -m -G wheel -s /usr/bin/zsh john passwd john EDITOR=nano visudo nano /etc/pacman.conf pacman -S openssh systemctl enable sshd nano /etc/ssh/sshd_config # Done! exit umount /mnt/boot umount /mnt/mnt/efi umount /mnt/home :( umount /mnt/tmp umount /mnt/usr umount /mnt/var zfs umount -a zpool export vault # # After reboot zpool set cachefile=/etc/zfs/zpool.cache vault systemctl enable zfs.target # To write the hostid file safely you need to use a small C program: #include <stdio.h> #include <errno.h> #include <unistd.h> int main() { int res; res = sethostid(gethostid()); if (res != 0) { switch (errno) { case EACCES: fprintf(stderr, "Error! No permission to write the" " file used to store the host ID.\n" "Are you root?\n"); break; case EPERM: fprintf(stderr, "Error! The calling process's effective" " user or group ID is not the same as" " its corresponding real ID.\n"); break; default: fprintf(stderr, "Unknown error.\n"); } return 1; } return 0; } # Copy it, save it as writehostid.c and compile it with gcc -o writehostid writehostid.c, finally execute it and regenerate the initramfs image: nano writehostid.c gcc -o writehostid writehostid.c chmod +x writehostid ./writehostid mkinitcpio -p linux