From 6d3e5b049560cb1b9c1118a335b22b5aacdc5a6c Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Mon, 11 Nov 2024 08:35:57 -0600 Subject: moving things around --- TODO.org | 38 ++++ Vagrantfile | 71 ------- assets/Vagrantfile | 71 +++++++ assets/gitrepos.sh | 6 - assets/post-install.sh | 52 ------ assets/user_configuration.json | 281 ---------------------------- assets/user_credentials.json | 5 + assets/zfs/README.org | 13 ++ assets/zfs/script | 69 +++++++ assets/zfs/stage0.sh | 13 ++ assets/zfs/stage1.sh | 210 +++++++++++++++++++++ assets/zfs/stage2.sh | 199 ++++++++++++++++++++ assets/zfssetup | 406 +++++++++++++++++++++++++++++++++++++++++ config.json | 281 ++++++++++++++++++++++++++++ iso/create-archiso-zfs.sh | 31 ---- scripts/create-archiso-zfs.sh | 33 ++++ scripts/gitrepos.sh | 6 + scripts/post-install.sh | 52 ++++++ zfs_assets/README.org | 13 -- zfs_assets/script | 69 ------- zfs_assets/stage0.sh | 13 -- zfs_assets/stage1.sh | 210 --------------------- zfs_assets/stage2.sh | 199 -------------------- zfssetup | 406 ----------------------------------------- 24 files changed, 1396 insertions(+), 1351 deletions(-) delete mode 100644 Vagrantfile create mode 100644 assets/Vagrantfile delete mode 100755 assets/gitrepos.sh delete mode 100755 assets/post-install.sh delete mode 100644 assets/user_configuration.json create mode 100644 assets/user_credentials.json create mode 100644 assets/zfs/README.org create mode 100644 assets/zfs/script create mode 100755 assets/zfs/stage0.sh create mode 100755 assets/zfs/stage1.sh create mode 100755 assets/zfs/stage2.sh create mode 100755 assets/zfssetup create mode 100644 config.json delete mode 100644 iso/create-archiso-zfs.sh create mode 100644 scripts/create-archiso-zfs.sh create mode 100755 scripts/gitrepos.sh create mode 100755 scripts/post-install.sh delete mode 100644 zfs_assets/README.org delete mode 100644 zfs_assets/script delete mode 100755 zfs_assets/stage0.sh delete mode 100755 zfs_assets/stage1.sh delete mode 100755 zfs_assets/stage2.sh delete mode 100755 zfssetup diff --git a/TODO.org b/TODO.org index b6faebf..d20199a 100644 --- a/TODO.org +++ b/TODO.org @@ -515,3 +515,41 @@ sudo mkarchiso -vo ~/iso/out ~/iso ** Info on Local Pacman Cache/Mirror [[https://bbs.archlinux.org/viewtopic.php?id=242471][Use pacman cache as local package mirror / Pacman & Package Upgrade Issues / Arch Linux Forums]] Captured On: [2024-04-13 Sat 12:07] +* Arch Install Steps +** References +[[https://youtu.be/zQQN3Pj4K0Y?list=PLHlcDXHFansDuXdFbU2XZXoNOGQiq1zr3][Stephen's Tech Talks: Arch Linux the Easy Way: Encrypted Wayland KDE, Timeshift, Working Boot from Snapshots]] +** Arch Install Choices +These are saved as "user_configuration.json" and "user_credentials.json" in the assets folder + +*** Disk Layout +- Wipe all selected drives and use a best-effort default partition layout +- Select btrfs +- Select "yes" to using BTRFS subvolumes with a default structure +- Select "yes" to BTRFS compression +*** Encryption password +This is the LUKS encryption password. Choose whatever password you like. +*** Bootloader +- Select "yes" to "use GRUB as bootloader instead of systemd-boot" +*** Profile +- Choose minimal +*** Kernels +- Choose linux +*** Additional Packages +git neovim openssh terminus-font +*** Optional Repositories +Select multilib +** Chroot Activities +After checking these items, you can exit and reboot +*** Check /etc/fstab +change relatime to noatime for SSD performance +remove space_cache=v2 as it's redundant +*** Check /etc/default/grub +check that encryption is setup properly (look for cryptdevice in grub_cmdline_linux) +add video=1920x1080 in grub_cmdline_linux_default after "loglevel-3 quiet" + +if you modify anything, make sure to type + +grub-mkconfig -o /boot/grub/grub.cfg +*** Check /etc/mkinitcpio.conf +check MODULES=(btrfs) +ensure that the HOOKS= line has encrypt before filesystems diff --git a/Vagrantfile b/Vagrantfile deleted file mode 100644 index f84a67a..0000000 --- a/Vagrantfile +++ /dev/null @@ -1,71 +0,0 @@ -# -*- mode: ruby -*- -# vi: set ft=ruby : - -# All Vagrant configuration is done below. The "2" in Vagrant.configure -# configures the configuration version (we support older styles for -# backwards compatibility). Please don't change it unless you know what -# you're doing. -Vagrant.configure("2") do |config| - # The most common configuration options are documented and commented below. - # For a complete reference, please see the online documentation at - # https://docs.vagrantup.com. - - # Every Vagrant development environment requires a box. You can search for - # boxes at https://vagrantcloud.com/search. - config.vm.box = "archlinux/archlinux" - - # Disable automatic box update checking. If you disable this, then - # boxes will only be checked for updates when the user runs - # `vagrant box outdated`. This is not recommended. - # config.vm.box_check_update = false - - # Create a forwarded port mapping which allows access to a specific port - # within the machine from a port on the host machine. In the example below, - # accessing "localhost:8080" will access port 80 on the guest machine. - # NOTE: This will enable public access to the opened port - # config.vm.network "forwarded_port", guest: 80, host: 8080 - - # Create a forwarded port mapping which allows access to a specific port - # within the machine from a port on the host machine and only allow access - # via 127.0.0.1 to disable public access - # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1" - - # Create a private network, which allows host-only access to the machine - # using a specific IP. - # config.vm.network "private_network", ip: "192.168.33.10" - - # Create a public network, which generally matched to bridged network. - # Bridged networks make the machine appear as another physical device on - # your network. - config.vm.network "public_network", bridge: "enp2s0", type: "dhcp" - config.vm.hostname = "archlinux-base" - - # Share an additional folder to the guest VM. The first argument is - # the path on the host to the actual folder. The second argument is - # the path on the guest to mount the folder. And the optional third - # argument is a set of non-required options. - config.vm.synced_folder "~cjennings/code/archsetup/", "/vagrant_data" - - # Provider-specific configuration so you can fine-tune various - # backing providers for Vagrant. These expose provider-specific options. - # Example for VirtualBox: - # - config.vm.provider "virtualbox" do |vb| - # # Display the VirtualBox GUI when booting the machine - vb.gui = false - # - # # Customize the amount of memory on the VM: - vb.memory = "8192" - end - # - # View the documentation for the provider you are using for more - # information on available options. - - # Enable provisioning with a shell script. Additional provisioners such as - # Ansible, Chef, Docker, Puppet and Salt are also available. Please see the - # documentation for more information about their specific syntax and use. - # config.vm.provision "shell", inline: <<-SHELL - # apt-get update - # apt-get install -y apache2 - # SHELL -end diff --git a/assets/Vagrantfile b/assets/Vagrantfile new file mode 100644 index 0000000..f84a67a --- /dev/null +++ b/assets/Vagrantfile @@ -0,0 +1,71 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# All Vagrant configuration is done below. The "2" in Vagrant.configure +# configures the configuration version (we support older styles for +# backwards compatibility). Please don't change it unless you know what +# you're doing. +Vagrant.configure("2") do |config| + # The most common configuration options are documented and commented below. + # For a complete reference, please see the online documentation at + # https://docs.vagrantup.com. + + # Every Vagrant development environment requires a box. You can search for + # boxes at https://vagrantcloud.com/search. + config.vm.box = "archlinux/archlinux" + + # Disable automatic box update checking. If you disable this, then + # boxes will only be checked for updates when the user runs + # `vagrant box outdated`. This is not recommended. + # config.vm.box_check_update = false + + # Create a forwarded port mapping which allows access to a specific port + # within the machine from a port on the host machine. In the example below, + # accessing "localhost:8080" will access port 80 on the guest machine. + # NOTE: This will enable public access to the opened port + # config.vm.network "forwarded_port", guest: 80, host: 8080 + + # Create a forwarded port mapping which allows access to a specific port + # within the machine from a port on the host machine and only allow access + # via 127.0.0.1 to disable public access + # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1" + + # Create a private network, which allows host-only access to the machine + # using a specific IP. + # config.vm.network "private_network", ip: "192.168.33.10" + + # Create a public network, which generally matched to bridged network. + # Bridged networks make the machine appear as another physical device on + # your network. + config.vm.network "public_network", bridge: "enp2s0", type: "dhcp" + config.vm.hostname = "archlinux-base" + + # Share an additional folder to the guest VM. The first argument is + # the path on the host to the actual folder. The second argument is + # the path on the guest to mount the folder. And the optional third + # argument is a set of non-required options. + config.vm.synced_folder "~cjennings/code/archsetup/", "/vagrant_data" + + # Provider-specific configuration so you can fine-tune various + # backing providers for Vagrant. These expose provider-specific options. + # Example for VirtualBox: + # + config.vm.provider "virtualbox" do |vb| + # # Display the VirtualBox GUI when booting the machine + vb.gui = false + # + # # Customize the amount of memory on the VM: + vb.memory = "8192" + end + # + # View the documentation for the provider you are using for more + # information on available options. + + # Enable provisioning with a shell script. Additional provisioners such as + # Ansible, Chef, Docker, Puppet and Salt are also available. Please see the + # documentation for more information about their specific syntax and use. + # config.vm.provision "shell", inline: <<-SHELL + # apt-get update + # apt-get install -y apache2 + # SHELL +end diff --git a/assets/gitrepos.sh b/assets/gitrepos.sh deleted file mode 100755 index b33c72c..0000000 --- a/assets/gitrepos.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash -# cjennings -# replaces original http remote repositories with git ones - -cd ~/.emacs.d && git remote remove origin && git remote add origin git@cjennings.net:dotemacs.git && git pull --set-upstream origin main -cd ~/.dotfiles.d && git remote remove origin && git remote add origin git@cjennings.net:dotfiles.git && git pull --set-upstream origin main diff --git a/assets/post-install.sh b/assets/post-install.sh deleted file mode 100755 index 57825a5..0000000 --- a/assets/post-install.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/sh - -logfile="$HOME/post-install.log" -touch $logfile - -echo "fixing perms on gpg directory" -{ - chown -R $(whoami) ~/.gnupg/ - find ~/.gnupg -type f -exec chmod 600 {} \; - find ~/.gnupg -type d -exec chmod 700 {} \; -} >> $logfile 2>&1 - -echo "fixing remote repositories" -{ - cd ~/.dotfiles && \ - git remote remove origin && \ - git remote add origin git@cjennings.net:dotfiles.git - - cd ~/.emacs.d && \ - git remote remove origin && \ - git remote add origin git@cjennings.net:dotemacs.git -} - -echo "cloning git repos" -{ - git clone cjennings@cjennings.net:git/org.git ~/sync/org - git clone --depth 1 cjennings@cjennings.net:git/wallpaper.git ~/pictures/wallpaper - git clone cjennings@cjennings.net:git/documents.git ~/projects/documents - git clone cjennings@cjennings.net:git/kit.git ~/projects/kit - git clone cjennings@cjennings.net:git/clipper.git ~/projects/clipper - git clone cjennings@cjennings.net:git/finances.git ~/projects/finances - - git clone git@cjennings.net:dwm.git ~/code/dwm - git clone git@cjennings.net:dmenu.git ~/code/dmenu - git clone git@cjennings.net:st.git ~/code/st - git clone cjennings@cjennings.net:git/slock.git ~/code/slock - git clone git@cjennings.net:pinentry-dmenu.git ~/code/pinentry-dmenu - - git clone cjennings@cjennings.net:git/bsdsetup.git ~/code/bsdsetup - git clone git@cjennings.net:archsetup.git ~/code/archsetup - - git clone cjennings@cjennings.net:git/exercism.git ~/code/exercism - git clone cjennings@cjennings.net:git/elisp.git ~/code/elisp - git clone cjennings@cjennings.net:git/clisp.git ~/code/clisp - git clone cjennings@cjennings.net:git/100dayspython.git ~/code/100dayspython - - git clone cjennings@cjennings.net:git/nasbuild.git ~/projects/nasbuild - git clone cjennings@cjennings.net:git/nextjob.git ~/projects/nextjob - git clone cjennings@cjennings.net:git/elibrary.git ~/projects/elibrary -} >> $logfile 2>&1 - -printf "\n\nDone.\n\n" diff --git a/assets/user_configuration.json b/assets/user_configuration.json deleted file mode 100644 index 565d7f6..0000000 --- a/assets/user_configuration.json +++ /dev/null @@ -1,281 +0,0 @@ -{ - "additional-repositories": [ - "multilib" - ], - "archinstall-language": "English", - "bootloader": "Grub", - "config_version": "2.8.6", - "debug": false, - "disk_config": { - "config_type": "default_layout", - "device_modifications": [ - { - "device": "/dev/nvme0n1", - "partitions": [ - { - "btrfs": [], - "dev_path": null, - "flags": [ - "Boot", - "ESP" - ], - "fs_type": "fat32", - "mount_options": [], - "mountpoint": "/boot", - "obj_id": "3a0f0cc1-6323-4a53-bb0e-534225a806b9", - "size": { - "sector_size": { - "unit": "B", - "value": 512 - }, - "unit": "GiB", - "value": 1 - }, - "start": { - "sector_size": { - "unit": "B", - "value": 512 - }, - "unit": "MiB", - "value": 1 - }, - "status": "create", - "type": "primary" - }, - { - "btrfs": [ - { - "mountpoint": "/", - "name": "@" - }, - { - "mountpoint": "/home", - "name": "@home" - }, - { - "mountpoint": "/var/log", - "name": "@log" - }, - { - "mountpoint": "/var/cache/pacman/pkg", - "name": "@pkg" - }, - { - "mountpoint": "/.snapshots", - "name": "@.snapshots" - } - ], - "dev_path": null, - "flags": [], - "fs_type": "btrfs", - "mount_options": [ - "compress=zstd" - ], - "mountpoint": null, - "obj_id": "7a153a7e-09ee-4a68-9cd7-fe38905318aa", - "size": { - "sector_size": { - "unit": "B", - "value": 512 - }, - "unit": "B", - "value": 8000487383040 - }, - "start": { - "sector_size": { - "unit": "B", - "value": 512 - }, - "unit": "B", - "value": 1074790400 - }, - "status": "create", - "type": "primary" - } - ], - "wipe": true - } - ] - }, - "disk_encryption": { - "encryption_type": "luks", - "lvm_volumes": [], - "partitions": [ - "7a153a7e-09ee-4a68-9cd7-fe38905318aa" - ] - }, - "hostname": "velox", - "kernels": [ - "linux" - ], - "locale_config": { - "kb_layout": "us", - "sys_enc": "UTF-8", - "sys_lang": "en_US" - }, - "mirror_config": { - "custom_mirrors": [], - "mirror_regions": { - "United States": [ - "http://us.arch.niranjan.co/$repo/os/$arch", - "http://arch.mirror.constant.com/$repo/os/$arch", - "https://us-mnz.soulharsh007.dev/archlinux/$repo/os/$arch", - "http://mirrors.lug.mtu.edu/archlinux/$repo/os/$arch", - "https://us.arch.niranjan.co/$repo/os/$arch", - "http://mirror.math.princeton.edu/pub/archlinux/$repo/os/$arch", - "http://ziply.mm.fcix.net/archlinux/$repo/os/$arch", - "http://ridgewireless.mm.fcix.net/archlinux/$repo/os/$arch", - "http://archmirror1.octyl.net/$repo/os/$arch", - "http://mirrors.xtom.com/archlinux/$repo/os/$arch", - "http://arch.hu.fo/archlinux/$repo/os/$arch", - "http://nnenix.mm.fcix.net/archlinux/$repo/os/$arch", - "https://mirrors.lug.mtu.edu/archlinux/$repo/os/$arch", - "http://opencolo.mm.fcix.net/archlinux/$repo/os/$arch", - "http://mirrors.ocf.berkeley.edu/archlinux/$repo/os/$arch", - "http://mirror.fcix.net/archlinux/$repo/os/$arch", - "http://codingflyboy.mm.fcix.net/archlinux/$repo/os/$arch", - "http://mirror.sfo12.us.leaseweb.net/archlinux/$repo/os/$arch", - "http://mirrors.rit.edu/archlinux/$repo/os/$arch", - "http://uvermont.mm.fcix.net/archlinux/$repo/os/$arch", - "http://southfront.mm.fcix.net/archlinux/$repo/os/$arch", - "http://mirror.hasphetica.win/archlinux/$repo/os/$arch", - "http://plug-mirror.rcac.purdue.edu/archlinux/$repo/os/$arch", - "http://mirror.wdc1.us.leaseweb.net/archlinux/$repo/os/$arch", - "https://mirror.hasphetica.win/archlinux/$repo/os/$arch", - "http://irltoolkit.mm.fcix.net/archlinux/$repo/os/$arch", - "https://m.lqy.me/arch/$repo/os/$arch", - "http://mirrors.bjg.at/arch/$repo/os/$arch", - "https://mirrors.rit.edu/archlinux/$repo/os/$arch", - "http://mirror.adectra.com/archlinux/$repo/os/$arch", - "http://volico.mm.fcix.net/archlinux/$repo/os/$arch", - "https://archlinux.doridian.net/$repo/os/$arch", - "https://archmirror1.octyl.net/$repo/os/$arch", - "http://mirror.dal10.us.leaseweb.net/archlinux/$repo/os/$arch", - "http://mirrors.vectair.net/archlinux/$repo/os/$arch", - "http://iad.mirrors.misaka.one/archlinux/$repo/os/$arch", - "http://mnvoip.mm.fcix.net/archlinux/$repo/os/$arch", - "https://arlm.tyzoid.com/$repo/os/$arch", - "https://ziply.mm.fcix.net/archlinux/$repo/os/$arch", - "http://mirror.mia11.us.leaseweb.net/archlinux/$repo/os/$arch", - "http://forksystems.mm.fcix.net/archlinux/$repo/os/$arch", - "http://coresite.mm.fcix.net/archlinux/$repo/os/$arch", - "https://mirror.sfo12.us.leaseweb.net/archlinux/$repo/os/$arch", - "https://coresite.mm.fcix.net/archlinux/$repo/os/$arch", - "http://arlm.tyzoid.com/$repo/os/$arch", - "https://ridgewireless.mm.fcix.net/archlinux/$repo/os/$arch", - "https://irltoolkit.mm.fcix.net/archlinux/$repo/os/$arch", - "https://arch.hu.fo/archlinux/$repo/os/$arch", - "https://nnenix.mm.fcix.net/archlinux/$repo/os/$arch", - "https://arch.mirror.constant.com/$repo/os/$arch", - "https://opencolo.mm.fcix.net/archlinux/$repo/os/$arch", - "https://mirror.fcix.net/archlinux/$repo/os/$arch", - "https://codingflyboy.mm.fcix.net/archlinux/$repo/os/$arch", - "https://mirror.zackmyers.io/archlinux/$repo/os/$arch", - "https://mirrors.vectair.net/archlinux/$repo/os/$arch", - "https://uvermont.mm.fcix.net/archlinux/$repo/os/$arch", - "http://nocix.mm.fcix.net/archlinux/$repo/os/$arch", - "https://southfront.mm.fcix.net/archlinux/$repo/os/$arch", - "https://volico.mm.fcix.net/archlinux/$repo/os/$arch", - "https://plug-mirror.rcac.purdue.edu/archlinux/$repo/os/$arch", - "https://forksystems.mm.fcix.net/archlinux/$repo/os/$arch", - "https://mnvoip.mm.fcix.net/archlinux/$repo/os/$arch", - "https://america.mirror.pkgbuild.com/$repo/os/$arch", - "http://arch-mirror.marcusspencer.xyz:8080/archlinux/$repo/os/$arch", - "https://iad.mirrors.misaka.one/archlinux/$repo/os/$arch", - "https://us.mirrors.cicku.me/archlinux/$repo/os/$arch", - "http://us.mirrors.cicku.me/archlinux/$repo/os/$arch", - "https://mirror.theash.xyz/arch/$repo/os/$arch", - "http://mirrors.rutgers.edu/archlinux/$repo/os/$arch", - "https://zxcvfdsa.com/arch/$repo/os/$arch", - "http://mirror.clarkson.edu/archlinux/$repo/os/$arch", - "http://mirrors.cat.pdx.edu/archlinux/$repo/os/$arch", - "http://mirrors.kernel.org/archlinux/$repo/os/$arch", - "https://mirrors.sonic.net/archlinux/$repo/os/$arch", - "http://mirrors.sonic.net/archlinux/$repo/os/$arch", - "http://mirrors.mit.edu/archlinux/$repo/os/$arch", - "http://ohioix.mm.fcix.net/archlinux/$repo/os/$arch", - "http://mirror.colonelhosting.com/archlinux/$repo/os/$arch", - "https://mirror.arizona.edu/archlinux/$repo/os/$arch", - "https://arch.mirror.k0.ae/$repo/os/$arch", - "http://mirror.arizona.edu/archlinux/$repo/os/$arch", - "https://mirrors.ocf.berkeley.edu/archlinux/$repo/os/$arch", - "http://repo.ialab.dsu.edu/archlinux/$repo/os/$arch", - "https://mirrors.mit.edu/archlinux/$repo/os/$arch", - "https://mirrors.xtom.com/archlinux/$repo/os/$arch", - "https://mirrors.kernel.org/archlinux/$repo/os/$arch", - "https://mirror.adectra.com/archlinux/$repo/os/$arch", - "https://mirror.colonelhosting.com/archlinux/$repo/os/$arch", - "https://mirror.wdc1.us.leaseweb.net/archlinux/$repo/os/$arch", - "https://mirror.mia11.us.leaseweb.net/archlinux/$repo/os/$arch", - "https://mirror.dal10.us.leaseweb.net/archlinux/$repo/os/$arch", - "https://ohioix.mm.fcix.net/archlinux/$repo/os/$arch", - "https://repo.ialab.dsu.edu/archlinux/$repo/os/$arch", - "https://nocix.mm.fcix.net/archlinux/$repo/os/$arch", - "http://mirrors.advancedhosters.com/archlinux/$repo/os/$arch", - "https://iad.mirror.rackspace.com/archlinux/$repo/os/$arch", - "https://mirror.clarkson.edu/archlinux/$repo/os/$arch", - "http://mirror.umd.edu/archlinux/$repo/os/$arch", - "http://arch.goober.cloud/$repo/os/$arch", - "https://arch.goober.cloud/$repo/os/$arch", - "http://mirror.vtti.vt.edu/archlinux/$repo/os/$arch", - "http://iad.mirror.rackspace.com/archlinux/$repo/os/$arch", - "http://mirrors.xmission.com/archlinux/$repo/os/$arch", - "http://mirrors.gigenet.com/archlinux/$repo/os/$arch", - "http://ord.mirror.rackspace.com/archlinux/$repo/os/$arch", - "https://ord.mirror.rackspace.com/archlinux/$repo/os/$arch", - "http://dfw.mirror.rackspace.com/archlinux/$repo/os/$arch", - "https://mirror.umd.edu/archlinux/$repo/os/$arch", - "https://dfw.mirror.rackspace.com/archlinux/$repo/os/$arch", - "http://mirrors.acm.wpi.edu/archlinux/$repo/os/$arch", - "http://mirrors.bloomu.edu/archlinux/$repo/os/$arch", - "https://mirrors.bloomu.edu/archlinux/$repo/os/$arch", - "http://mirror.ette.biz/archlinux/$repo/os/$arch", - "http://mirrors.iu13.net/archlinux/$repo/os/$arch", - "http://mirror.pit.teraswitch.com/archlinux/$repo/os/$arch", - "https://mirrors.iu13.net/archlinux/$repo/os/$arch", - "https://mirror.pit.teraswitch.com/archlinux/$repo/os/$arch", - "https://mirror.ette.biz/archlinux/$repo/os/$arch", - "http://mirror.metrocast.net/archlinux/$repo/os/$arch", - "http://mirror.cs.vt.edu/pub/ArchLinux/$repo/os/$arch", - "https://ftp.osuosl.org/pub/archlinux/$repo/os/$arch", - "http://ftp.osuosl.org/pub/archlinux/$repo/os/$arch", - "http://repo.miserver.it.umich.edu/archlinux/$repo/os/$arch", - "http://mirror.fossable.org/archlinux/$repo/os/$arch", - "http://distro.ibiblio.org/archlinux/$repo/os/$arch", - "http://www.gtlib.gatech.edu/pub/archlinux/$repo/os/$arch", - "https://mirror.pilotfiber.com/archlinux/$repo/os/$arch", - "http://wcbmedia.io:8000/$repo/os/$arch" - ] - } - }, - "network_config": { - "type": "nm" - }, - "no_pkg_lookups": false, - "ntp": true, - "offline": false, - "packages": [ - "git", - "neovim", - "openssh", - "terminus-font" - ], - "parallel downloads": 0, - "profile_config": { - "gfx_driver": null, - "greeter": null, - "profile": { - "custom_settings": {}, - "details": [], - "main": "Minimal" - } - }, - "script": "guided", - "silent": false, - "skip_ntp": false, - "skip_version_check": false, - "swap": true, - "timezone": "US/Central", - "uki": false, - "version": "2.8.6" -} \ No newline at end of file diff --git a/assets/user_credentials.json b/assets/user_credentials.json new file mode 100644 index 0000000..50e1c64 --- /dev/null +++ b/assets/user_credentials.json @@ -0,0 +1,5 @@ +{ + "!root-password": "cmjdase1n", + "!users": [], + "encryption_password": "cmjdase1n" +} diff --git a/assets/zfs/README.org b/assets/zfs/README.org new file mode 100644 index 0000000..3a46823 --- /dev/null +++ b/assets/zfs/README.org @@ -0,0 +1,13 @@ +* WHY THIS + +* INSTRUCTIONS +** Boot from a iso that contains zfs kernel modules +There are two ways of doing this. + +First, you can boot from the official Arch Linux +** Git clone this repository +#+begin_src sh +git clone git@cjennings.net:zfsarch.git +#+end_src +** Add the correct disk to the +** diff --git a/assets/zfs/script b/assets/zfs/script new file mode 100644 index 0000000..0a19346 --- /dev/null +++ b/assets/zfs/script @@ -0,0 +1,69 @@ +loadkeys us +setfont ter-132n + +# TK gparted commands + +zpool create -f \ + -o ashift=12 \ + -O acltype=posixacl -O canmount=off \ + -O dnodesize=auto -O normalization=formD \ + -O atime=off -O xattr=sa -O mountpoint=none \ + -R /mnt zroot /dev/nvme0n1p2 + +zfs create -o canmount=noauto -o mountpoint=/ zroot/rootfs +zpool set bootfs=zroot/rootfs zroot +zfs create zroot/rootfs/home +zfs mount zroot/rootfs + +mkdir -p /mnt/etc/zfs +zpool set cachefile=/etc/zfs/zpool.cache zroot +cp /etc/zfs/zpool.cache /mnt/etc/zfs/zpool.cache + +mkfs.vfat /dev/nvme0n1p1 +mkdir /mnt/boot +mount /dev/nvme0n1p1 /mnt/boot + +genfstab -U -p /mnt >> /mnt/etc/fstab + +pacstrap /mnt base base-devel linux-lts linux-lts-headers linux-firmware grub efibootmgr nano vi zsh openssh networkmanager reflector + +arch-chroot /mnt + +echo -e ' +[archzfs] +Server = https://archzfs.com/$repo/x86_64' >> /etc/pacman.conf + +pacman-key -r DDF7DB817396A49B2A2723F7403BD972F75D9D76 +pacman-key --lsign-key DDF7DB817396A49B2A2723F7403BD972F75D9D76 + +pacman -Sy zfs-dkms +pacman -Sy intel-ucode + +# TK edit mkinitcpio.conf, removing fsck adding zfs before filesystems + +mkinitcpio -p linux-lts + +mkdir /boot/grub +nano /etc/default/grub # GRUB_CMDLINE_LINUX_DEFAULT="zfs=zroot/rootfs" +grub-mkconfig -o /boot/grub/grub.cfg +grub-install --target=x86_64-efi --efi-directory=/boot + +systemctl enable zfs.target zfs-import-cache zfs-mount zfs-import.target NetworkManager reflector.timer + +ln -sf /usr/share/zoneinfo/US/Central /etc/localtime +hwclock --systohc + +echo -e 'en_US.UTF-8 UTF-8' >> /etc/locale.gen +echo 'KEYMAP=us' > /etc/vconsole.conf +echo 'LANG=en_US.UTF-8' > /etc/locale.conf +echo velox > /etc/hostname +echo -e '127.0.0.1 localhost\n::1 localhost\n127.0.1.1 velox' >> /etc/hosts + +echo "root:welcome" | chpasswd +chage -d 0 root + +exit # done with chroot +# ...back in the installer shell... +umount -R /mnt +zfs umount -a +zpool export -a diff --git a/assets/zfs/stage0.sh b/assets/zfs/stage0.sh new file mode 100755 index 0000000..74132dc --- /dev/null +++ b/assets/zfs/stage0.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +pacman-key --init +pacman-key --refresh-keys +pacman-key --populate +pacman -Syy +pacman -S --noconfirm openssh tmux +systemctl start sshd +echo "root:welcome" | chpasswd +# curl -s https://raw.githubusercontent.com/eoli3n/archiso-zfs/master/init | bash +# echo ""; echo "Enter password for zfsarch repository when prompted" +# git clone cjennings@cjennings.net:git/zfsarch.git +echo ""; echo "Stage 0 completed." diff --git a/assets/zfs/stage1.sh b/assets/zfs/stage1.sh new file mode 100755 index 0000000..392ff74 --- /dev/null +++ b/assets/zfs/stage1.sh @@ -0,0 +1,210 @@ +#!/usr/bin/env bash +# install arch linux on zfs root, stage one +# Craig Jennings +# +# https://openzfs.github.io/openzfs-docs/Getting%20Started/Arch%20Linux/Root%20on%20ZFS.html +# + +set -e # halt on any error + +# -------------------------- Prerequisites -------------------------- + +sed -i "s/^#ParallelDownloads = 5$/ParallelDownloads = 15/" /etc/pacman.conf +# These are now done in stage 0 +# pacman-key --init +# pacman-key --refresh-keys +# pacman --noconfirm -Sy archlinux-keyring +loadkeys us +timedatectl set-ntp true + +### --------------------------- Choose Disk --------------------------- + +all_disk_ids=( $(ls /dev/disk/by-id/) ) +echo ""; echo "Select the disk id to use. All data will be erased." +select disk_id in "${all_disk_ids[@]}"; do + # ensure valid selection + if [[ -n $disk_id ]]; then + selection=$disk_id + break + else + echo "Invalid. Try again." + fi +done + +# Confirm the selected disk +read -p "Confirm: '$selection' [y/n]? " choice +if [[ "$choice" != "y" ]]; then + echo "Exiting..." + exit 1 +fi + +DISK="/dev/disk/by-id/$selection" +MNT=/mnt # Set a mount point +SWAPSIZE=4 # Set swap size in GB +RESERVE=1 # Set how much space to leave at the end of disk, minimum 1GB + +### --------------------------- Erase Disk ------------------------- +echo ""; echo "### Erasing Disk" +blkdiscard -f "${DISK}" || true # discard all sectors on flash-based storage +sgdisk --zap-all "${DISK}" # clear the disk + +### ------------------------- Partition Disk ------------------------ +echo ""; echo "### Partitioning Disk" +parted --script --align=optimal "${DISK}" -- \ + mklabel gpt \ + mkpart EFI 2MiB 1GiB \ + mkpart bpool 1GiB 5GiB \ + mkpart rpool 5GiB -$((SWAPSIZE + RESERVE))GiB \ + mkpart swap -$((SWAPSIZE + RESERVE))GiB -"${RESERVE}"GiB \ + mkpart BIOS 1MiB 2MiB \ + set 1 esp on \ + set 5 bios_grub on \ + set 5 legacy_boot on + +### ---------------------- Setup Encrypted Swap --------------------- +echo ""; echo "### Encrypted Swap" +for i in ${DISK}; do + cryptsetup open --type plain --key-file /dev/random "${i}"-part4 "${i##*/}"-part4 + mkswap /dev/mapper/"${i##*/}"-part4 + swapon /dev/mapper/"${i##*/}"-part4 +done + +# ------------------- Create Boot And Root Pools ------------------ + +# This step creates a separate boot pool for /boot with the features limited to +# only those that GRUB supports, allowing the root pool to use any/all features. + +echo ""; echo "### Checking ZFS Module" +modprobe zfs # ensure zfs module is loaded + +echo ""; echo "### Creating Boot Pool" +# shellcheck disable=SC2046 +zpool create -d \ + -o feature@async_destroy=enabled \ + -o feature@bookmarks=enabled \ + -o feature@embedded_data=enabled \ + -o feature@empty_bpobj=enabled \ + -o feature@enabled_txg=enabled \ + -o feature@extensible_dataset=enabled \ + -o feature@filesystem_limits=enabled \ + -o feature@hole_birth=enabled \ + -o feature@large_blocks=enabled \ + -o feature@lz4_compress=enabled \ + -o feature@spacemap_histogram=enabled \ + -o ashift=12 \ + -o autotrim=on \ + -O acltype=posixacl \ + -O canmount=off \ + -O compression=lz4 \ + -O devices=off \ + -O normalization=formD \ + -O relatime=on \ + -O xattr=sa \ + -O mountpoint=/boot \ + -R "${MNT}" \ + bpool \ + $(for i in ${DISK}; do + printf '%s ' "${i}-part2"; + done) + +echo ""; echo "### Creating Root Pool" +# shellcheck disable=SC2046 +zpool create \ + -o ashift=12 \ + -o autotrim=on \ + -R "${MNT}" \ + -O acltype=posixacl \ + -O canmount=off \ + -O compression=zstd \ + -O dnodesize=auto \ + -O normalization=formD \ + -O relatime=on \ + -O xattr=sa \ + -O mountpoint=/ \ + rpool \ + $(for i in ${DISK}; do + printf '%s ' "${i}-part3"; + done) + +echo ""; echo "### Creating Unencrypted Root System Container" +# create UNENCRYPTED root system container +zfs create \ + -o canmount=off \ + -o mountpoint=none \ +rpool/archlinux + +# --------------------- Create System Datasets -------------------- +echo ""; echo "### Creating System Datasets" +zfs create -o canmount=noauto -o mountpoint=/ rpool/archlinux/root +zfs mount rpool/archlinux/root +zfs create -o mountpoint=legacy rpool/archlinux/home +mkdir "${MNT}"/home +mount -t zfs rpool/archlinux/home "${MNT}"/home +zfs create -o mountpoint=legacy rpool/archlinux/var +zfs create -o mountpoint=legacy rpool/archlinux/var/lib +zfs create -o mountpoint=legacy rpool/archlinux/var/log +zfs create -o mountpoint=none bpool/archlinux +zfs create -o mountpoint=legacy bpool/archlinux/root +mkdir "${MNT}"/boot +mount -t zfs bpool/archlinux/root "${MNT}"/boot +mkdir -p "${MNT}"/var/log +mkdir -p "${MNT}"/var/lib +mount -t zfs rpool/archlinux/var/lib "${MNT}"/var/lib +mount -t zfs rpool/archlinux/var/log "${MNT}"/var/log + +# ---------------------- Format And Mount ESP --------------------- +echo ""; echo "### Format And Mount ESP" +for i in ${DISK}; do + mkfs.vfat -n EFI "${i}"-part1 + mkdir -p "${MNT}"/boot/efis/"${i##*/}"-part1 + mount -t vfat -o iocharset=iso8859-1 "${i}"-part1 "${MNT}"/boot/efis/"${i##*/}"-part1 +done + +mkdir -p "${MNT}"/boot/efi +mount -t vfat -o iocharset=iso8859-1 "$(echo "${DISK}" | sed "s|^ *||" | cut -f1 -d' '|| true)"-part1 "${MNT}"/boot/efi + +### -------------------------- Install Base ------------------------- +echo ""; echo "### Installing Base" +# install packages with pacstrap +pacstrap "${MNT}" \ + base \ + base-devel \ + dkms \ + efibootmgr \ + git \ + grub \ + intel-ucode \ + linux-firmware \ + linux-lts \ + linux-lts-headers \ + man-db \ + man-pages \ + vi + +# create fstab and remove all zroot entries +genfstab -U -p "${MNT}" >> "${MNT}"/etc/fstab +sed -i '/^# zroot/d' "${MNT}"/etc/fstab +sed -i '/^zroot/d' "${MNT}"/etc/fstab +sed -i '/^$/d' "${MNT}"/etc/fstab +echo "" >> "${MNT}"/etc/fstab # one blank line at the end + +# copy over dns settings to the new system +cp -v /etc/resolv.conf "${MNT}"/etc + +# copy stage2 script to the new system +cp ./stage2.sh "${MNT}"/root + +# ----------------------------- Chroot ---------------------------- + +echo ""; echo "Done with Stage One" +chroot "${MNT}" /usr/bin/env DISK="${DISK}" /root/stage2.sh + +# -------------------------- After Chroot ------------------------- + +umount -Rl "${MNT}" +zfs snapshot -r rpool@initial-installation +zfs snapshot -r bpool@initial-installation + +zpool export -a + +echo ""; echo "Done with Stage Two" diff --git a/assets/zfs/stage2.sh b/assets/zfs/stage2.sh new file mode 100755 index 0000000..6ec1a52 --- /dev/null +++ b/assets/zfs/stage2.sh @@ -0,0 +1,199 @@ +#!/usr/bin/env bash +# install arch linux on zfs root, stage two +# + +set -e # halt on any error + +password="welcome" # root password; will force change after login +hostname="velox" +disk=/dev/nvme0n1 + +yay_repo="https://aur.archlinux.org/yay.git" +source_dir="/usr/src" +logfile=/root/zfsarch_stage2.log + +cd # go home + +# --------------------- Add ArchZFS Repository -------------------- + +echo ""; "### ADDING ARCHZFS REPOSITORY " echo "" | tee -a $logfile + +echo ""; "### handling arch keys" echo "" | tee -a $logfile +pacman-key --init >> $logfile 2>&1 +pacman-key --refresh-keys >> $logfile 2>&1 +pacman-key --populate >> $logfile 2>&1 + +curl --fail-early --fail -L https://archzfs.com/archzfs.gpg \ +| pacman-key -a - --gpgdir /etc/pacman.d/gnupg + +pacman-key \ +--lsign-key \ +--gpgdir /etc/pacman.d/gnupg \ +DDF7DB817396A49B2A2723F7403BD972F75D9D76 + +echo ""; "### adding repository info" echo "" | tee -a $logfile +tee -a /etc/pacman.d/mirrorlist-archzfs <<- 'EOF' +## See https://github.com/archzfs/archzfs/wiki +## France +#,Server = https://archzfs.com/$repo/$arch + +## Germany +#,Server = https://mirror.sum7.eu/archlinux/archzfs/$repo/$arch +#,Server = https://mirror.biocrafting.net/archlinux/archzfs/$repo/$arch + +## India +#,Server = https://mirror.in.themindsmaze.com/archzfs/$repo/$arch + +## United States +#,Server = https://zxcvfdsa.com/archzfs/$repo/$arch +EOF + +tee -a /etc/pacman.conf <<- 'EOF' +#[archzfs-testing] +#Include = /etc/pacman.d/mirrorlist-archzfs + +#,[archzfs] +#,Include = /etc/pacman.d/mirrorlist-archzfs +EOF + + +# the '#,' prefix is a workaround for ci/cd tests. we should remove them +sed -i 's|#,||' /etc/pacman.d/mirrorlist-archzfs +sed -i 's|#,||' /etc/pacman.conf +sed -i 's|^#||' /etc/pacman.d/mirrorlist + +# ---------- Install Packages And Linux Compatible Kernel --------- +echo ""; "### INSTALLING COMPATIBLE KERNEL " | tee -a $logfile +echo "### identifying kernel version" | tee -a $logfile + +pacman -Sy >> $logfile 2>&1 + +kernel_compatible_with_zfs="$(pacman -Si zfs-linux \ +| grep 'Depends On' \ +| sed "s|.*linux=||" \ +| awk '{ print $1 }')" + +echo "### installing kernel" | tee -a $logfile +pacman -U --noconfirm https://america.archive.pkgbuild.com/packages/l/linux/linux-"${kernel_compatible_with_zfs}"-x86_64.pkg.tar.zst >> $logfile 2>&1 +pacman -S --noconfirm zfs-linux zfs-utils >> $logfile 2>&1 + +# ---------------------- Configure Mkinitcpio --------------------- + +sed -i 's|filesystems|zfs filesystems|' /etc/mkinitcpio.conf +mkinitcpio -P + +# ------------------------- General Hostid ------------------------ + +zgenhostid -f -o /etc/hostid + +# ---------------------- Apply Grub Workaround ---------------------- +# Note: This workaround needs to be applied for every GRUB update, as the update will overwrite the changes. + +echo 'export ZPOOL_VDEV_NAME_PATH=YES' >> /etc/profile.d/zpool_vdev_name_path.sh +# shellcheck disable=SC1091 +. /etc/profile.d/zpool_vdev_name_path.sh + +# GRUB fails to detect rpool name, hard code as "rpool" +sed -i "s|rpool=.*|rpool=rpool|" /etc/grub.d/10_linux + +# -------------------------- Install Grub ------------------------- + +mkdir -p /boot/efi/archlinux/grub-bootdir/i386-pc/ +mkdir -p /boot/efi/archlinux/grub-bootdir/x86_64-efi/ +for i in ${DISK}; do + grub-install --target=i386-pc --boot-directory \ + /boot/efi/archlinux/grub-bootdir/i386-pc/ "${i}" +done +grub-install --target x86_64-efi --boot-directory \ + /boot/efi/archlinux/grub-bootdir/x86_64-efi/ --efi-directory \ + /boot/efi --bootloader-id archlinux --removable +if test -d /sys/firmware/efi/efivars/; then + grub-install --target x86_64-efi --boot-directory \ + /boot/efi/archlinux/grub-bootdir/x86_64-efi/ --efi-directory \ + /boot/efi --bootloader-id archlinux +fi + +# Import both bpool and rpool at boot: +echo 'GRUB_CMDLINE_LINUX="zfs_import_dir=/dev/"' >> /etc/default/grub + +# Generate GRUB menu: +mkdir -p /boot/grub +grub-mkconfig -o /boot/grub/grub.cfg +cp /boot/grub/grub.cfg \ + /boot/efi/archlinux/grub-bootdir/x86_64-efi/grub/grub.cfg +cp /boot/grub/grub.cfg \ + /boot/efi/archlinux/grub-bootdir/i386-pc/grub/grub.cfg + +# For both legacy and EFI booting: mirror ESP content: +espdir=$(mktemp -d) +find /boot/efi/ -maxdepth 1 -mindepth 1 -type d -print0 \ +| xargs -t -0I '{}' cp -r '{}' "${espdir}" +find "${espdir}" -maxdepth 1 -mindepth 1 -type d -print0 \ + | xargs -t -0I '{}' sh -vxc "find /boot/efis/ -maxdepth 1 -mindepth 1 -type d -print0 | xargs -t -0I '[]' cp -r '{}' '[]'" + + +### ----------------------- Config Environment --------------------- + +# required software +pacman -S --noconfirm sed networkmanager reflector +systemctl enable NetworkManager +systemctl enable reflector.timer + +# parallel downloads +sed -i "s/^#ParallelDownloads = 5$/ParallelDownloads = 15/" /etc/pacman.conf + +# aur config +sed -i '/^CFLAGS=/s/-march=x86-64 -mtune=generic/-march=native/' /etc/makepkg.conf +sed -i 's/^#RUSTFLAGS="-C opt-level=2"/RUSTFLAGS="-C opt-level=2 -C target-cpu=native"/g' /etc/makepkg.conf +sed -i 's/^#MAKEFLAGS="-j2"/MAKEFLAGS="-j$(nproc)"/g' /etc/makepkg.conf +sed -i 's/^COMPRESSXZ=(xz -c -z -)/COMPRESSXZ=(xz -c -z --threads=0 -)/g' /etc/makepkg.conf +sed -i 's/^COMPRESSZST=(zstd -c -z -q -)/COMPRESSZST=(zstd -c -z -q --threads=0 -)/g' /etc/makepkg.conf + +# set up local time +sudo ln -sf /usr/share/zoneinfo/US/Central /etc/localtime +hwclock --systohc + +# set up locale +echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen +locale-gen +echo "LANG=en_US.UTF-8" > /etc/locale.conf + +# set up hostname +echo "$hostname" > /etc/hostname +echo "127.0.0.1 localhost" >> /etc/hosts +echo "::1 localhost" >> /etc/hosts +echo "127.0.1.1 $hostname.localdomain $hostname" >> /etc/hosts + +# console settings +echo "KEYMAP=us" > /etc/vconsole.conf + +# ------------------------ Enable AUR Helper ------------------------ + +pacman -Syy +pacman -S --needed --noconfirm base-devel git openssh wget +build_dir="$source_dir/yay" +mkdir -p "$build_dir" +chown "$username:$username" -R "/home/$username" +sudo -u "$username" git clone --depth 1 "$yay_repo" "$build_dir" +cd "$build_dir" && sudo -u "$username" makepkg --noconfirm -si + +### ------------------------- Enable ZFS Services ---------------------- +# add kernel modules +pacman -S --noconfirm zfs-dkms + +# enable zfs services +systemctl enable zfs-import-cache +systemctl enable zfs-import.target +systemctl enable zfs-mount.service +systemctl enable zfs-share +systemctl enable zfs-zed +systemctl enable zfs.target + +### ----------------------------- Wrap Up -------------------------- + +# set root password; must change first login +echo "root:$password" | chpasswd +chage -d 0 root + +# --------------------------- Exit Chroot --------------------------- +exit diff --git a/assets/zfssetup b/assets/zfssetup new file mode 100755 index 0000000..6bc95ca --- /dev/null +++ b/assets/zfssetup @@ -0,0 +1,406 @@ +#!/usr/bin/env bash +# install arch linux on zfs root, stage one +# Craig Jennings +# +# https://openzfs.github.io/openzfs-docs/Getting%20Started/Arch%20Linux/Root%20on%20ZFS.html + +# set -e # halt on any error + +# -------------------------- Prerequisites -------------------------- + +sed -i "s/^#ParallelDownloads = 5$/ParallelDownloads = 15/" /etc/pacman.conf +loadkeys us +timedatectl set-ntp true + +### --------------------------- Choose Disk --------------------------- + +all_disk_ids=( $(ls /dev/disk/by-id/) ) +echo ""; echo "Select the disk id to use. All data will be erased." +select disk_id in "${all_disk_ids[@]}"; do + # ensure valid selection + if [[ -n $disk_id ]]; then + selection=$disk_id + break + else + echo "Invalid. Try again." + fi +done + +# Confirm the selected disk +read -p "Confirm: '$selection' [y/n]? " choice +if [[ "$choice" != "y" ]]; then + echo "Exiting..." + exit 1 +fi + +DISK="/dev/disk/by-id/$selection" +MNT=/mnt # Set a mount point +SWAPSIZE=4 # Set swap size in GB +RESERVE=1 # Set how much space to leave at the end of disk, minimum 1GB + +### --------------------------- Erase Disk ------------------------- + +echo ""; echo "### Erasing Disk" +blkdiscard -f "${DISK}" || true # discard all sectors on flash-based storage +sgdisk --zap-all "${DISK}" # clear the disk + +### ------------------------- Partition Disk ------------------------ + +echo ""; echo "### Partitioning Disk" +parted --script --align=optimal "${DISK}" -- \ + mklabel gpt \ + mkpart EFI 2MiB 1GiB \ + mkpart bpool 1GiB 5GiB \ + mkpart rpool 5GiB -$((SWAPSIZE + RESERVE))GiB \ + mkpart swap -$((SWAPSIZE + RESERVE))GiB -"${RESERVE}"GiB \ + mkpart BIOS 1MiB 2MiB \ + set 1 esp on \ + set 5 bios_grub on \ + set 5 legacy_boot on + +### ---------------------- Setup Encrypted Swap --------------------- + +echo ""; echo "### Encrypted Swap" +for i in ${DISK}; do + cryptsetup open --type plain --key-file /dev/random "${i}"-part4 "${i##*/}"-part4 + mkswap /dev/mapper/"${i##*/}"-part4 + swapon /dev/mapper/"${i##*/}"-part4 +done + +# ------------------- Create Boot And Root Pools ------------------ + +# This step creates a separate boot pool for /boot with the features limited to +# only those that GRUB supports, allowing the root pool to use any/all features. + +echo ""; echo "### Checking ZFS Module" +modprobe zfs # ensure zfs module is loaded + +echo ""; echo "### Creating Boot Pool" +# shellcheck disable=SC2046 +zpool create -d \ + -o feature@async_destroy=enabled \ + -o feature@bookmarks=enabled \ + -o feature@embedded_data=enabled \ + -o feature@empty_bpobj=enabled \ + -o feature@enabled_txg=enabled \ + -o feature@extensible_dataset=enabled \ + -o feature@filesystem_limits=enabled \ + -o feature@hole_birth=enabled \ + -o feature@large_blocks=enabled \ + -o feature@lz4_compress=enabled \ + -o feature@spacemap_histogram=enabled \ + -o ashift=12 \ + -o autotrim=on \ + -O acltype=posixacl \ + -O canmount=off \ + -O compression=lz4 \ + -O devices=off \ + -O normalization=formD \ + -O relatime=on \ + -O xattr=sa \ + -O mountpoint=/boot \ + -R "${MNT}" \ + bpool \ + $(for i in ${DISK}; do + printf '%s ' "${i}-part2"; + done) + +echo ""; echo "### Creating Root Pool" +# shellcheck disable=SC2046 +zpool create \ + -o ashift=12 \ + -o autotrim=on \ + -R "${MNT}" \ + -O acltype=posixacl \ + -O canmount=off \ + -O compression=zstd \ + -O dnodesize=auto \ + -O normalization=formD \ + -O relatime=on \ + -O xattr=sa \ + -O mountpoint=/ \ + rpool \ + $(for i in ${DISK}; do + printf '%s ' "${i}-part3"; + done) + +echo ""; echo "### Creating Unencrypted Root System Container" +# create UNENCRYPTED root system container +zfs create \ + -o canmount=off \ + -o mountpoint=none \ +rpool/archlinux + +# --------------------- Create System Datasets -------------------- + +echo ""; echo "### Creating System Datasets" +zfs create -o canmount=noauto -o mountpoint=/ rpool/archlinux/root +zfs mount rpool/archlinux/root +zfs create -o mountpoint=legacy rpool/archlinux/home +mkdir "${MNT}"/home +mount -t zfs rpool/archlinux/home "${MNT}"/home +zfs create -o mountpoint=legacy rpool/archlinux/var +zfs create -o mountpoint=legacy rpool/archlinux/var/lib +zfs create -o mountpoint=legacy rpool/archlinux/var/log +zfs create -o mountpoint=none bpool/archlinux +zfs create -o mountpoint=legacy bpool/archlinux/root +mkdir "${MNT}"/boot +mount -t zfs bpool/archlinux/root "${MNT}"/boot +mkdir -p "${MNT}"/var/log +mkdir -p "${MNT}"/var/lib +mount -t zfs rpool/archlinux/var/lib "${MNT}"/var/lib +mount -t zfs rpool/archlinux/var/log "${MNT}"/var/log + +# ---------------------- Format And Mount ESP --------------------- + +echo ""; echo "### Format And Mount ESP" +for i in ${DISK}; do + mkfs.vfat -n EFI "${i}"-part1 + mkdir -p "${MNT}"/boot/efis/"${i##*/}"-part1 + mount -t vfat -o iocharset=iso8859-1 "${i}"-part1 "${MNT}"/boot/efis/"${i##*/}"-part1 +done + +mkdir -p "${MNT}"/boot/efi +mount -t vfat -o iocharset=iso8859-1 "$(echo "${DISK}" | sed "s|^ *||" | cut -f1 -d' '|| true)"-part1 "${MNT}"/boot/efi + +### -------------------------- Install Base ------------------------- + +echo ""; echo "### Installing Base" +# install packages with pacstrap +pacstrap "${MNT}" \ + base \ + base-devel \ + dkms \ + efibootmgr \ + git \ + grub \ + intel-ucode \ + linux-firmware \ + linux-lts \ + linux-lts-headers \ + man-db \ + man-pages \ + vi + +# create fstab and remove all zroot entries +echo ""; echo "### Creating fstab" +genfstab -U -p "${MNT}" >> "${MNT}"/etc/fstab +sed -i '/^# zroot/d' "${MNT}"/etc/fstab +sed -i '/^zroot/d' "${MNT}"/etc/fstab +sed -i '/^$/d' "${MNT}"/etc/fstab +echo "" >> "${MNT}"/etc/fstab # one blank line at the end + +# copy over dns settings to the new system +echo ""; echo "### Copying DNS Settings" +cp -v /etc/resolv.conf "${MNT}"/etc + +# ----------------------------- Chroot ---------------------------- +# copy second part of this script to the new system + +echo ""; echo "### Copying script then chrooting" +sed '1,/^#part2$/d' `basename $0` > "${MNT}"/root +chroot "${MNT}" /usr/bin/env DISK="${DISK}" /root/stage2.sh + +# -------------------------- After Chroot ------------------------- + +umount -Rl "${MNT}" +zfs snapshot -r rpool@initial-installation +zfs snapshot -r bpool@initial-installation + +zpool export -a + +echo ""; echo "### Done with Stage Two" + +#part2 +#!/usr/bin/env bash +# install arch linux on zfs root, stage two +# Craig Jennings + +printf '\033c' + +password="welcome" # root password; will force change after login +hostname="velox" +disk=/dev/nvme0n1 + +yay_repo="https://aur.archlinux.org/yay.git" +source_dir="/usr/src" +logfile=/root/zfsarch_stage2.log + +cd # go home + +# --------------------- Add ArchZFS Repository -------------------- + +pacman-key --init +pacman-key --refresh-keys +pacman-key --populate + +curl --fail-early --fail -L https://archzfs.com/archzfs.gpg \ +| pacman-key -a - --gpgdir /etc/pacman.d/gnupg + +pacman-key \ +--lsign-key \ +--gpgdir /etc/pacman.d/gnupg \ +DDF7DB817396A49B2A2723F7403BD972F75D9D76 + +tee -a /etc/pacman.d/mirrorlist-archzfs <<- 'EOF' +## See https://github.com/archzfs/archzfs/wiki +## France +#,Server = https://archzfs.com/$repo/$arch + +## Germany +#,Server = https://mirror.sum7.eu/archlinux/archzfs/$repo/$arch +#,Server = https://mirror.biocrafting.net/archlinux/archzfs/$repo/$arch + +## India +#,Server = https://mirror.in.themindsmaze.com/archzfs/$repo/$arch + +## United States +#,Server = https://zxcvfdsa.com/archzfs/$repo/$arch +EOF + +tee -a /etc/pacman.conf <<- 'EOF' + +#[archzfs-testing] +#Include = /etc/pacman.d/mirrorlist-archzfs + +#,[archzfs] +#,Include = /etc/pacman.d/mirrorlist-archzfs +EOF + +# this #, prefix is a workaround for ci/cd tests +# remove them +sed -i 's|#,||' /etc/pacman.d/mirrorlist-archzfs +sed -i 's|#,||' /etc/pacman.conf +sed -i 's|^#||' /etc/pacman.d/mirrorlist + +# ---------- Install Packages And Linux Compatible Kernel --------- +pacman -Sy + +kernel_compatible_with_zfs="$(pacman -Si zfs-linux \ +| grep 'Depends On' \ +| sed "s|.*linux=||" \ +| awk '{ print $1 }')" +pacman -U --noconfirm https://america.archive.pkgbuild.com/packages/l/linux/linux-"${kernel_compatible_with_zfs}"-x86_64.pkg.tar.zst + +pacman -S --noconfirm zfs-linux zfs-utils + +# ---------------------- Configure Mkinitcpio --------------------- + +sed -i 's|filesystems|zfs filesystems|' /etc/mkinitcpio.conf +mkinitcpio -P + +# ------------------------- General Hostid ------------------------ + +zgenhostid -f -o /etc/hostid + +# ---------------------- Apply Grub Workaround ---------------------- +# Note: This workaround needs to be applied for every GRUB update, as the update will overwrite the changes. + +echo 'export ZPOOL_VDEV_NAME_PATH=YES' >> /etc/profile.d/zpool_vdev_name_path.sh +# shellcheck disable=SC1091 +. /etc/profile.d/zpool_vdev_name_path.sh + +# GRUB fails to detect rpool name, hard code as "rpool" +sed -i "s|rpool=.*|rpool=rpool|" /etc/grub.d/10_linux + +# -------------------------- Install Grub ------------------------- + +mkdir -p /boot/efi/archlinux/grub-bootdir/i386-pc/ +mkdir -p /boot/efi/archlinux/grub-bootdir/x86_64-efi/ +for i in ${DISK}; do + grub-install --target=i386-pc --boot-directory \ + /boot/efi/archlinux/grub-bootdir/i386-pc/ "${i}" +done +grub-install --target x86_64-efi --boot-directory \ + /boot/efi/archlinux/grub-bootdir/x86_64-efi/ --efi-directory \ + /boot/efi --bootloader-id archlinux --removable +if test -d /sys/firmware/efi/efivars/; then + grub-install --target x86_64-efi --boot-directory \ + /boot/efi/archlinux/grub-bootdir/x86_64-efi/ --efi-directory \ + /boot/efi --bootloader-id archlinux +fi + +# Import both bpool and rpool at boot: +echo 'GRUB_CMDLINE_LINUX="zfs_import_dir=/dev/"' >> /etc/default/grub + +# Generate GRUB menu: +mkdir -p /boot/grub +grub-mkconfig -o /boot/grub/grub.cfg +cp /boot/grub/grub.cfg \ + /boot/efi/archlinux/grub-bootdir/x86_64-efi/grub/grub.cfg +cp /boot/grub/grub.cfg \ + /boot/efi/archlinux/grub-bootdir/i386-pc/grub/grub.cfg + +# For both legacy and EFI booting: mirror ESP content: +espdir=$(mktemp -d) +find /boot/efi/ -maxdepth 1 -mindepth 1 -type d -print0 \ +| xargs -t -0I '{}' cp -r '{}' "${espdir}" +find "${espdir}" -maxdepth 1 -mindepth 1 -type d -print0 \ + | xargs -t -0I '{}' sh -vxc "find /boot/efis/ -maxdepth 1 -mindepth 1 -type d -print0 | xargs -t -0I '[]' cp -r '{}' '[]'" + +### ----------------------- Config Environment --------------------- + +# required software +pacman -S --noconfirm sed networkmanager reflector +systemctl enable NetworkManager +systemctl enable reflector.timer + +# parallel downloads +sed -i "s/^#ParallelDownloads = 5$/ParallelDownloads = 15/" /etc/pacman.conf + +# aur config +sed -i '/^CFLAGS=/s/-march=x86-64 -mtune=generic/-march=native/' /etc/makepkg.conf +sed -i 's/^#RUSTFLAGS="-C opt-level=2"/RUSTFLAGS="-C opt-level=2 -C target-cpu=native"/g' /etc/makepkg.conf +sed -i 's/^#MAKEFLAGS="-j2"/MAKEFLAGS="-j$(nproc)"/g' /etc/makepkg.conf +sed -i 's/^COMPRESSXZ=(xz -c -z -)/COMPRESSXZ=(xz -c -z --threads=0 -)/g' /etc/makepkg.conf +sed -i 's/^COMPRESSZST=(zstd -c -z -q -)/COMPRESSZST=(zstd -c -z -q --threads=0 -)/g' /etc/makepkg.conf + +# set up local time +sudo ln -sf /usr/share/zoneinfo/US/Central /etc/localtime +hwclock --systohc + +# set up locale +echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen +locale-gen +echo "LANG=en_US.UTF-8" > /etc/locale.conf + +# set up hostname +echo "$hostname" > /etc/hostname +echo "127.0.0.1 localhost" >> /etc/hosts +echo "::1 localhost" >> /etc/hosts +echo "127.0.1.1 $hostname.localdomain $hostname" >> /etc/hosts + +# console settings +echo "KEYMAP=us" > /etc/vconsole.conf + +# ------------------------ Enable AUR Helper ------------------------ + +pacman -Syy +pacman -S --needed --noconfirm base-devel git openssh wget +build_dir="$source_dir/yay" +mkdir -p "$build_dir" +chown "$username:$username" -R "/home/$username" +sudo -u "$username" git clone --depth 1 "$yay_repo" "$build_dir" +cd "$build_dir" && sudo -u "$username" makepkg --noconfirm -si + +### ------------------------- Enable ZFS Services ---------------------- +# add kernel modules + +pacman -S --noconfirm zfs-dkms + +# enable zfs services +systemctl enable zfs-import-cache +systemctl enable zfs-import.target +systemctl enable zfs-mount.service +systemctl enable zfs-share +systemctl enable zfs-zed +systemctl enable zfs.target + +### ----------------------------- Wrap Up -------------------------- + +# set root password; must change first login +echo "root:$password" | chpasswd +chage -d 0 root + +# --------------------------- Exit Chroot --------------------------- +exit diff --git a/config.json b/config.json new file mode 100644 index 0000000..565d7f6 --- /dev/null +++ b/config.json @@ -0,0 +1,281 @@ +{ + "additional-repositories": [ + "multilib" + ], + "archinstall-language": "English", + "bootloader": "Grub", + "config_version": "2.8.6", + "debug": false, + "disk_config": { + "config_type": "default_layout", + "device_modifications": [ + { + "device": "/dev/nvme0n1", + "partitions": [ + { + "btrfs": [], + "dev_path": null, + "flags": [ + "Boot", + "ESP" + ], + "fs_type": "fat32", + "mount_options": [], + "mountpoint": "/boot", + "obj_id": "3a0f0cc1-6323-4a53-bb0e-534225a806b9", + "size": { + "sector_size": { + "unit": "B", + "value": 512 + }, + "unit": "GiB", + "value": 1 + }, + "start": { + "sector_size": { + "unit": "B", + "value": 512 + }, + "unit": "MiB", + "value": 1 + }, + "status": "create", + "type": "primary" + }, + { + "btrfs": [ + { + "mountpoint": "/", + "name": "@" + }, + { + "mountpoint": "/home", + "name": "@home" + }, + { + "mountpoint": "/var/log", + "name": "@log" + }, + { + "mountpoint": "/var/cache/pacman/pkg", + "name": "@pkg" + }, + { + "mountpoint": "/.snapshots", + "name": "@.snapshots" + } + ], + "dev_path": null, + "flags": [], + "fs_type": "btrfs", + "mount_options": [ + "compress=zstd" + ], + "mountpoint": null, + "obj_id": "7a153a7e-09ee-4a68-9cd7-fe38905318aa", + "size": { + "sector_size": { + "unit": "B", + "value": 512 + }, + "unit": "B", + "value": 8000487383040 + }, + "start": { + "sector_size": { + "unit": "B", + "value": 512 + }, + "unit": "B", + "value": 1074790400 + }, + "status": "create", + "type": "primary" + } + ], + "wipe": true + } + ] + }, + "disk_encryption": { + "encryption_type": "luks", + "lvm_volumes": [], + "partitions": [ + "7a153a7e-09ee-4a68-9cd7-fe38905318aa" + ] + }, + "hostname": "velox", + "kernels": [ + "linux" + ], + "locale_config": { + "kb_layout": "us", + "sys_enc": "UTF-8", + "sys_lang": "en_US" + }, + "mirror_config": { + "custom_mirrors": [], + "mirror_regions": { + "United States": [ + "http://us.arch.niranjan.co/$repo/os/$arch", + "http://arch.mirror.constant.com/$repo/os/$arch", + "https://us-mnz.soulharsh007.dev/archlinux/$repo/os/$arch", + "http://mirrors.lug.mtu.edu/archlinux/$repo/os/$arch", + "https://us.arch.niranjan.co/$repo/os/$arch", + "http://mirror.math.princeton.edu/pub/archlinux/$repo/os/$arch", + "http://ziply.mm.fcix.net/archlinux/$repo/os/$arch", + "http://ridgewireless.mm.fcix.net/archlinux/$repo/os/$arch", + "http://archmirror1.octyl.net/$repo/os/$arch", + "http://mirrors.xtom.com/archlinux/$repo/os/$arch", + "http://arch.hu.fo/archlinux/$repo/os/$arch", + "http://nnenix.mm.fcix.net/archlinux/$repo/os/$arch", + "https://mirrors.lug.mtu.edu/archlinux/$repo/os/$arch", + "http://opencolo.mm.fcix.net/archlinux/$repo/os/$arch", + "http://mirrors.ocf.berkeley.edu/archlinux/$repo/os/$arch", + "http://mirror.fcix.net/archlinux/$repo/os/$arch", + "http://codingflyboy.mm.fcix.net/archlinux/$repo/os/$arch", + "http://mirror.sfo12.us.leaseweb.net/archlinux/$repo/os/$arch", + "http://mirrors.rit.edu/archlinux/$repo/os/$arch", + "http://uvermont.mm.fcix.net/archlinux/$repo/os/$arch", + "http://southfront.mm.fcix.net/archlinux/$repo/os/$arch", + "http://mirror.hasphetica.win/archlinux/$repo/os/$arch", + "http://plug-mirror.rcac.purdue.edu/archlinux/$repo/os/$arch", + "http://mirror.wdc1.us.leaseweb.net/archlinux/$repo/os/$arch", + "https://mirror.hasphetica.win/archlinux/$repo/os/$arch", + "http://irltoolkit.mm.fcix.net/archlinux/$repo/os/$arch", + "https://m.lqy.me/arch/$repo/os/$arch", + "http://mirrors.bjg.at/arch/$repo/os/$arch", + "https://mirrors.rit.edu/archlinux/$repo/os/$arch", + "http://mirror.adectra.com/archlinux/$repo/os/$arch", + "http://volico.mm.fcix.net/archlinux/$repo/os/$arch", + "https://archlinux.doridian.net/$repo/os/$arch", + "https://archmirror1.octyl.net/$repo/os/$arch", + "http://mirror.dal10.us.leaseweb.net/archlinux/$repo/os/$arch", + "http://mirrors.vectair.net/archlinux/$repo/os/$arch", + "http://iad.mirrors.misaka.one/archlinux/$repo/os/$arch", + "http://mnvoip.mm.fcix.net/archlinux/$repo/os/$arch", + "https://arlm.tyzoid.com/$repo/os/$arch", + "https://ziply.mm.fcix.net/archlinux/$repo/os/$arch", + "http://mirror.mia11.us.leaseweb.net/archlinux/$repo/os/$arch", + "http://forksystems.mm.fcix.net/archlinux/$repo/os/$arch", + "http://coresite.mm.fcix.net/archlinux/$repo/os/$arch", + "https://mirror.sfo12.us.leaseweb.net/archlinux/$repo/os/$arch", + "https://coresite.mm.fcix.net/archlinux/$repo/os/$arch", + "http://arlm.tyzoid.com/$repo/os/$arch", + "https://ridgewireless.mm.fcix.net/archlinux/$repo/os/$arch", + "https://irltoolkit.mm.fcix.net/archlinux/$repo/os/$arch", + "https://arch.hu.fo/archlinux/$repo/os/$arch", + "https://nnenix.mm.fcix.net/archlinux/$repo/os/$arch", + "https://arch.mirror.constant.com/$repo/os/$arch", + "https://opencolo.mm.fcix.net/archlinux/$repo/os/$arch", + "https://mirror.fcix.net/archlinux/$repo/os/$arch", + "https://codingflyboy.mm.fcix.net/archlinux/$repo/os/$arch", + "https://mirror.zackmyers.io/archlinux/$repo/os/$arch", + "https://mirrors.vectair.net/archlinux/$repo/os/$arch", + "https://uvermont.mm.fcix.net/archlinux/$repo/os/$arch", + "http://nocix.mm.fcix.net/archlinux/$repo/os/$arch", + "https://southfront.mm.fcix.net/archlinux/$repo/os/$arch", + "https://volico.mm.fcix.net/archlinux/$repo/os/$arch", + "https://plug-mirror.rcac.purdue.edu/archlinux/$repo/os/$arch", + "https://forksystems.mm.fcix.net/archlinux/$repo/os/$arch", + "https://mnvoip.mm.fcix.net/archlinux/$repo/os/$arch", + "https://america.mirror.pkgbuild.com/$repo/os/$arch", + "http://arch-mirror.marcusspencer.xyz:8080/archlinux/$repo/os/$arch", + "https://iad.mirrors.misaka.one/archlinux/$repo/os/$arch", + "https://us.mirrors.cicku.me/archlinux/$repo/os/$arch", + "http://us.mirrors.cicku.me/archlinux/$repo/os/$arch", + "https://mirror.theash.xyz/arch/$repo/os/$arch", + "http://mirrors.rutgers.edu/archlinux/$repo/os/$arch", + "https://zxcvfdsa.com/arch/$repo/os/$arch", + "http://mirror.clarkson.edu/archlinux/$repo/os/$arch", + "http://mirrors.cat.pdx.edu/archlinux/$repo/os/$arch", + "http://mirrors.kernel.org/archlinux/$repo/os/$arch", + "https://mirrors.sonic.net/archlinux/$repo/os/$arch", + "http://mirrors.sonic.net/archlinux/$repo/os/$arch", + "http://mirrors.mit.edu/archlinux/$repo/os/$arch", + "http://ohioix.mm.fcix.net/archlinux/$repo/os/$arch", + "http://mirror.colonelhosting.com/archlinux/$repo/os/$arch", + "https://mirror.arizona.edu/archlinux/$repo/os/$arch", + "https://arch.mirror.k0.ae/$repo/os/$arch", + "http://mirror.arizona.edu/archlinux/$repo/os/$arch", + "https://mirrors.ocf.berkeley.edu/archlinux/$repo/os/$arch", + "http://repo.ialab.dsu.edu/archlinux/$repo/os/$arch", + "https://mirrors.mit.edu/archlinux/$repo/os/$arch", + "https://mirrors.xtom.com/archlinux/$repo/os/$arch", + "https://mirrors.kernel.org/archlinux/$repo/os/$arch", + "https://mirror.adectra.com/archlinux/$repo/os/$arch", + "https://mirror.colonelhosting.com/archlinux/$repo/os/$arch", + "https://mirror.wdc1.us.leaseweb.net/archlinux/$repo/os/$arch", + "https://mirror.mia11.us.leaseweb.net/archlinux/$repo/os/$arch", + "https://mirror.dal10.us.leaseweb.net/archlinux/$repo/os/$arch", + "https://ohioix.mm.fcix.net/archlinux/$repo/os/$arch", + "https://repo.ialab.dsu.edu/archlinux/$repo/os/$arch", + "https://nocix.mm.fcix.net/archlinux/$repo/os/$arch", + "http://mirrors.advancedhosters.com/archlinux/$repo/os/$arch", + "https://iad.mirror.rackspace.com/archlinux/$repo/os/$arch", + "https://mirror.clarkson.edu/archlinux/$repo/os/$arch", + "http://mirror.umd.edu/archlinux/$repo/os/$arch", + "http://arch.goober.cloud/$repo/os/$arch", + "https://arch.goober.cloud/$repo/os/$arch", + "http://mirror.vtti.vt.edu/archlinux/$repo/os/$arch", + "http://iad.mirror.rackspace.com/archlinux/$repo/os/$arch", + "http://mirrors.xmission.com/archlinux/$repo/os/$arch", + "http://mirrors.gigenet.com/archlinux/$repo/os/$arch", + "http://ord.mirror.rackspace.com/archlinux/$repo/os/$arch", + "https://ord.mirror.rackspace.com/archlinux/$repo/os/$arch", + "http://dfw.mirror.rackspace.com/archlinux/$repo/os/$arch", + "https://mirror.umd.edu/archlinux/$repo/os/$arch", + "https://dfw.mirror.rackspace.com/archlinux/$repo/os/$arch", + "http://mirrors.acm.wpi.edu/archlinux/$repo/os/$arch", + "http://mirrors.bloomu.edu/archlinux/$repo/os/$arch", + "https://mirrors.bloomu.edu/archlinux/$repo/os/$arch", + "http://mirror.ette.biz/archlinux/$repo/os/$arch", + "http://mirrors.iu13.net/archlinux/$repo/os/$arch", + "http://mirror.pit.teraswitch.com/archlinux/$repo/os/$arch", + "https://mirrors.iu13.net/archlinux/$repo/os/$arch", + "https://mirror.pit.teraswitch.com/archlinux/$repo/os/$arch", + "https://mirror.ette.biz/archlinux/$repo/os/$arch", + "http://mirror.metrocast.net/archlinux/$repo/os/$arch", + "http://mirror.cs.vt.edu/pub/ArchLinux/$repo/os/$arch", + "https://ftp.osuosl.org/pub/archlinux/$repo/os/$arch", + "http://ftp.osuosl.org/pub/archlinux/$repo/os/$arch", + "http://repo.miserver.it.umich.edu/archlinux/$repo/os/$arch", + "http://mirror.fossable.org/archlinux/$repo/os/$arch", + "http://distro.ibiblio.org/archlinux/$repo/os/$arch", + "http://www.gtlib.gatech.edu/pub/archlinux/$repo/os/$arch", + "https://mirror.pilotfiber.com/archlinux/$repo/os/$arch", + "http://wcbmedia.io:8000/$repo/os/$arch" + ] + } + }, + "network_config": { + "type": "nm" + }, + "no_pkg_lookups": false, + "ntp": true, + "offline": false, + "packages": [ + "git", + "neovim", + "openssh", + "terminus-font" + ], + "parallel downloads": 0, + "profile_config": { + "gfx_driver": null, + "greeter": null, + "profile": { + "custom_settings": {}, + "details": [], + "main": "Minimal" + } + }, + "script": "guided", + "silent": false, + "skip_ntp": false, + "skip_version_check": false, + "swap": true, + "timezone": "US/Central", + "uki": false, + "version": "2.8.6" +} \ No newline at end of file diff --git a/iso/create-archiso-zfs.sh b/iso/create-archiso-zfs.sh deleted file mode 100644 index cb12ac3..0000000 --- a/iso/create-archiso-zfs.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env bash -# -# create-archiso-zfs.sh -# Craig Jennings -# Creates an arch linux iso with zfs support. -# This script must be run as root. - -pacman -Sy --noconfirm archiso -mkdir ~/iso - -# copies the releng profile -cp -r /usr/share/archiso/configs/releng/* ~/iso - -# add the archzfs repository to the pacman configuration -echo -e ' -[archzfs] -Server = https://archzfs.com/$repo/$arch -SigLevel = Optional TrustAll' >> ~/iso/pacman.conf - -# tell archiso to install the zfs dkms module and zfs utils to resulting iso -echo -e ' -linux-lts-headers -linux-headers -archzfs-dkms -zfs-utils' >> ~/iso/packages.x86_64 - -# build the iso. this takes some time -mkarchiso -vo ~/iso/out ~/iso - - - diff --git a/scripts/create-archiso-zfs.sh b/scripts/create-archiso-zfs.sh new file mode 100644 index 0000000..3028468 --- /dev/null +++ b/scripts/create-archiso-zfs.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +# +# create-archiso-zfs.sh +# Craig Jennings +# Creates an arch linux iso with zfs support. +# This script must be run as root. + +pacman-key -r DDF7DB817396A49B2A2723F7403BD972F75D9D76 +pacman-key --lsign-key DDF7DB817396A49B2A2723F7403BD972F75D9D76 + +pacman -Syu --noconfirm archiso +mkdir ~/iso + +# copies the releng profile +cp -r /usr/share/archiso/configs/releng/* ~/iso + +# add the archzfs repository to the pacman configuration +echo -e ' +[archzfs] +Server = https://archzfs.com/$repo/$arch +SigLevel = Optional TrustAll' >> ~/iso/pacman.conf + +# tell archiso to install the zfs dkms module and zfs utils to resulting iso +echo -e ' +linux-headers +archzfs-dkms +zfs-utils' >> ~/iso/packages.x86_64 + +# build the iso. this takes some time +mkarchiso -vo ~/iso/out ~/iso + + + diff --git a/scripts/gitrepos.sh b/scripts/gitrepos.sh new file mode 100755 index 0000000..b33c72c --- /dev/null +++ b/scripts/gitrepos.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +# cjennings +# replaces original http remote repositories with git ones + +cd ~/.emacs.d && git remote remove origin && git remote add origin git@cjennings.net:dotemacs.git && git pull --set-upstream origin main +cd ~/.dotfiles.d && git remote remove origin && git remote add origin git@cjennings.net:dotfiles.git && git pull --set-upstream origin main diff --git a/scripts/post-install.sh b/scripts/post-install.sh new file mode 100755 index 0000000..57825a5 --- /dev/null +++ b/scripts/post-install.sh @@ -0,0 +1,52 @@ +#!/bin/sh + +logfile="$HOME/post-install.log" +touch $logfile + +echo "fixing perms on gpg directory" +{ + chown -R $(whoami) ~/.gnupg/ + find ~/.gnupg -type f -exec chmod 600 {} \; + find ~/.gnupg -type d -exec chmod 700 {} \; +} >> $logfile 2>&1 + +echo "fixing remote repositories" +{ + cd ~/.dotfiles && \ + git remote remove origin && \ + git remote add origin git@cjennings.net:dotfiles.git + + cd ~/.emacs.d && \ + git remote remove origin && \ + git remote add origin git@cjennings.net:dotemacs.git +} + +echo "cloning git repos" +{ + git clone cjennings@cjennings.net:git/org.git ~/sync/org + git clone --depth 1 cjennings@cjennings.net:git/wallpaper.git ~/pictures/wallpaper + git clone cjennings@cjennings.net:git/documents.git ~/projects/documents + git clone cjennings@cjennings.net:git/kit.git ~/projects/kit + git clone cjennings@cjennings.net:git/clipper.git ~/projects/clipper + git clone cjennings@cjennings.net:git/finances.git ~/projects/finances + + git clone git@cjennings.net:dwm.git ~/code/dwm + git clone git@cjennings.net:dmenu.git ~/code/dmenu + git clone git@cjennings.net:st.git ~/code/st + git clone cjennings@cjennings.net:git/slock.git ~/code/slock + git clone git@cjennings.net:pinentry-dmenu.git ~/code/pinentry-dmenu + + git clone cjennings@cjennings.net:git/bsdsetup.git ~/code/bsdsetup + git clone git@cjennings.net:archsetup.git ~/code/archsetup + + git clone cjennings@cjennings.net:git/exercism.git ~/code/exercism + git clone cjennings@cjennings.net:git/elisp.git ~/code/elisp + git clone cjennings@cjennings.net:git/clisp.git ~/code/clisp + git clone cjennings@cjennings.net:git/100dayspython.git ~/code/100dayspython + + git clone cjennings@cjennings.net:git/nasbuild.git ~/projects/nasbuild + git clone cjennings@cjennings.net:git/nextjob.git ~/projects/nextjob + git clone cjennings@cjennings.net:git/elibrary.git ~/projects/elibrary +} >> $logfile 2>&1 + +printf "\n\nDone.\n\n" diff --git a/zfs_assets/README.org b/zfs_assets/README.org deleted file mode 100644 index 3a46823..0000000 --- a/zfs_assets/README.org +++ /dev/null @@ -1,13 +0,0 @@ -* WHY THIS - -* INSTRUCTIONS -** Boot from a iso that contains zfs kernel modules -There are two ways of doing this. - -First, you can boot from the official Arch Linux -** Git clone this repository -#+begin_src sh -git clone git@cjennings.net:zfsarch.git -#+end_src -** Add the correct disk to the -** diff --git a/zfs_assets/script b/zfs_assets/script deleted file mode 100644 index 0a19346..0000000 --- a/zfs_assets/script +++ /dev/null @@ -1,69 +0,0 @@ -loadkeys us -setfont ter-132n - -# TK gparted commands - -zpool create -f \ - -o ashift=12 \ - -O acltype=posixacl -O canmount=off \ - -O dnodesize=auto -O normalization=formD \ - -O atime=off -O xattr=sa -O mountpoint=none \ - -R /mnt zroot /dev/nvme0n1p2 - -zfs create -o canmount=noauto -o mountpoint=/ zroot/rootfs -zpool set bootfs=zroot/rootfs zroot -zfs create zroot/rootfs/home -zfs mount zroot/rootfs - -mkdir -p /mnt/etc/zfs -zpool set cachefile=/etc/zfs/zpool.cache zroot -cp /etc/zfs/zpool.cache /mnt/etc/zfs/zpool.cache - -mkfs.vfat /dev/nvme0n1p1 -mkdir /mnt/boot -mount /dev/nvme0n1p1 /mnt/boot - -genfstab -U -p /mnt >> /mnt/etc/fstab - -pacstrap /mnt base base-devel linux-lts linux-lts-headers linux-firmware grub efibootmgr nano vi zsh openssh networkmanager reflector - -arch-chroot /mnt - -echo -e ' -[archzfs] -Server = https://archzfs.com/$repo/x86_64' >> /etc/pacman.conf - -pacman-key -r DDF7DB817396A49B2A2723F7403BD972F75D9D76 -pacman-key --lsign-key DDF7DB817396A49B2A2723F7403BD972F75D9D76 - -pacman -Sy zfs-dkms -pacman -Sy intel-ucode - -# TK edit mkinitcpio.conf, removing fsck adding zfs before filesystems - -mkinitcpio -p linux-lts - -mkdir /boot/grub -nano /etc/default/grub # GRUB_CMDLINE_LINUX_DEFAULT="zfs=zroot/rootfs" -grub-mkconfig -o /boot/grub/grub.cfg -grub-install --target=x86_64-efi --efi-directory=/boot - -systemctl enable zfs.target zfs-import-cache zfs-mount zfs-import.target NetworkManager reflector.timer - -ln -sf /usr/share/zoneinfo/US/Central /etc/localtime -hwclock --systohc - -echo -e 'en_US.UTF-8 UTF-8' >> /etc/locale.gen -echo 'KEYMAP=us' > /etc/vconsole.conf -echo 'LANG=en_US.UTF-8' > /etc/locale.conf -echo velox > /etc/hostname -echo -e '127.0.0.1 localhost\n::1 localhost\n127.0.1.1 velox' >> /etc/hosts - -echo "root:welcome" | chpasswd -chage -d 0 root - -exit # done with chroot -# ...back in the installer shell... -umount -R /mnt -zfs umount -a -zpool export -a diff --git a/zfs_assets/stage0.sh b/zfs_assets/stage0.sh deleted file mode 100755 index 74132dc..0000000 --- a/zfs_assets/stage0.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -pacman-key --init -pacman-key --refresh-keys -pacman-key --populate -pacman -Syy -pacman -S --noconfirm openssh tmux -systemctl start sshd -echo "root:welcome" | chpasswd -# curl -s https://raw.githubusercontent.com/eoli3n/archiso-zfs/master/init | bash -# echo ""; echo "Enter password for zfsarch repository when prompted" -# git clone cjennings@cjennings.net:git/zfsarch.git -echo ""; echo "Stage 0 completed." diff --git a/zfs_assets/stage1.sh b/zfs_assets/stage1.sh deleted file mode 100755 index 392ff74..0000000 --- a/zfs_assets/stage1.sh +++ /dev/null @@ -1,210 +0,0 @@ -#!/usr/bin/env bash -# install arch linux on zfs root, stage one -# Craig Jennings -# -# https://openzfs.github.io/openzfs-docs/Getting%20Started/Arch%20Linux/Root%20on%20ZFS.html -# - -set -e # halt on any error - -# -------------------------- Prerequisites -------------------------- - -sed -i "s/^#ParallelDownloads = 5$/ParallelDownloads = 15/" /etc/pacman.conf -# These are now done in stage 0 -# pacman-key --init -# pacman-key --refresh-keys -# pacman --noconfirm -Sy archlinux-keyring -loadkeys us -timedatectl set-ntp true - -### --------------------------- Choose Disk --------------------------- - -all_disk_ids=( $(ls /dev/disk/by-id/) ) -echo ""; echo "Select the disk id to use. All data will be erased." -select disk_id in "${all_disk_ids[@]}"; do - # ensure valid selection - if [[ -n $disk_id ]]; then - selection=$disk_id - break - else - echo "Invalid. Try again." - fi -done - -# Confirm the selected disk -read -p "Confirm: '$selection' [y/n]? " choice -if [[ "$choice" != "y" ]]; then - echo "Exiting..." - exit 1 -fi - -DISK="/dev/disk/by-id/$selection" -MNT=/mnt # Set a mount point -SWAPSIZE=4 # Set swap size in GB -RESERVE=1 # Set how much space to leave at the end of disk, minimum 1GB - -### --------------------------- Erase Disk ------------------------- -echo ""; echo "### Erasing Disk" -blkdiscard -f "${DISK}" || true # discard all sectors on flash-based storage -sgdisk --zap-all "${DISK}" # clear the disk - -### ------------------------- Partition Disk ------------------------ -echo ""; echo "### Partitioning Disk" -parted --script --align=optimal "${DISK}" -- \ - mklabel gpt \ - mkpart EFI 2MiB 1GiB \ - mkpart bpool 1GiB 5GiB \ - mkpart rpool 5GiB -$((SWAPSIZE + RESERVE))GiB \ - mkpart swap -$((SWAPSIZE + RESERVE))GiB -"${RESERVE}"GiB \ - mkpart BIOS 1MiB 2MiB \ - set 1 esp on \ - set 5 bios_grub on \ - set 5 legacy_boot on - -### ---------------------- Setup Encrypted Swap --------------------- -echo ""; echo "### Encrypted Swap" -for i in ${DISK}; do - cryptsetup open --type plain --key-file /dev/random "${i}"-part4 "${i##*/}"-part4 - mkswap /dev/mapper/"${i##*/}"-part4 - swapon /dev/mapper/"${i##*/}"-part4 -done - -# ------------------- Create Boot And Root Pools ------------------ - -# This step creates a separate boot pool for /boot with the features limited to -# only those that GRUB supports, allowing the root pool to use any/all features. - -echo ""; echo "### Checking ZFS Module" -modprobe zfs # ensure zfs module is loaded - -echo ""; echo "### Creating Boot Pool" -# shellcheck disable=SC2046 -zpool create -d \ - -o feature@async_destroy=enabled \ - -o feature@bookmarks=enabled \ - -o feature@embedded_data=enabled \ - -o feature@empty_bpobj=enabled \ - -o feature@enabled_txg=enabled \ - -o feature@extensible_dataset=enabled \ - -o feature@filesystem_limits=enabled \ - -o feature@hole_birth=enabled \ - -o feature@large_blocks=enabled \ - -o feature@lz4_compress=enabled \ - -o feature@spacemap_histogram=enabled \ - -o ashift=12 \ - -o autotrim=on \ - -O acltype=posixacl \ - -O canmount=off \ - -O compression=lz4 \ - -O devices=off \ - -O normalization=formD \ - -O relatime=on \ - -O xattr=sa \ - -O mountpoint=/boot \ - -R "${MNT}" \ - bpool \ - $(for i in ${DISK}; do - printf '%s ' "${i}-part2"; - done) - -echo ""; echo "### Creating Root Pool" -# shellcheck disable=SC2046 -zpool create \ - -o ashift=12 \ - -o autotrim=on \ - -R "${MNT}" \ - -O acltype=posixacl \ - -O canmount=off \ - -O compression=zstd \ - -O dnodesize=auto \ - -O normalization=formD \ - -O relatime=on \ - -O xattr=sa \ - -O mountpoint=/ \ - rpool \ - $(for i in ${DISK}; do - printf '%s ' "${i}-part3"; - done) - -echo ""; echo "### Creating Unencrypted Root System Container" -# create UNENCRYPTED root system container -zfs create \ - -o canmount=off \ - -o mountpoint=none \ -rpool/archlinux - -# --------------------- Create System Datasets -------------------- -echo ""; echo "### Creating System Datasets" -zfs create -o canmount=noauto -o mountpoint=/ rpool/archlinux/root -zfs mount rpool/archlinux/root -zfs create -o mountpoint=legacy rpool/archlinux/home -mkdir "${MNT}"/home -mount -t zfs rpool/archlinux/home "${MNT}"/home -zfs create -o mountpoint=legacy rpool/archlinux/var -zfs create -o mountpoint=legacy rpool/archlinux/var/lib -zfs create -o mountpoint=legacy rpool/archlinux/var/log -zfs create -o mountpoint=none bpool/archlinux -zfs create -o mountpoint=legacy bpool/archlinux/root -mkdir "${MNT}"/boot -mount -t zfs bpool/archlinux/root "${MNT}"/boot -mkdir -p "${MNT}"/var/log -mkdir -p "${MNT}"/var/lib -mount -t zfs rpool/archlinux/var/lib "${MNT}"/var/lib -mount -t zfs rpool/archlinux/var/log "${MNT}"/var/log - -# ---------------------- Format And Mount ESP --------------------- -echo ""; echo "### Format And Mount ESP" -for i in ${DISK}; do - mkfs.vfat -n EFI "${i}"-part1 - mkdir -p "${MNT}"/boot/efis/"${i##*/}"-part1 - mount -t vfat -o iocharset=iso8859-1 "${i}"-part1 "${MNT}"/boot/efis/"${i##*/}"-part1 -done - -mkdir -p "${MNT}"/boot/efi -mount -t vfat -o iocharset=iso8859-1 "$(echo "${DISK}" | sed "s|^ *||" | cut -f1 -d' '|| true)"-part1 "${MNT}"/boot/efi - -### -------------------------- Install Base ------------------------- -echo ""; echo "### Installing Base" -# install packages with pacstrap -pacstrap "${MNT}" \ - base \ - base-devel \ - dkms \ - efibootmgr \ - git \ - grub \ - intel-ucode \ - linux-firmware \ - linux-lts \ - linux-lts-headers \ - man-db \ - man-pages \ - vi - -# create fstab and remove all zroot entries -genfstab -U -p "${MNT}" >> "${MNT}"/etc/fstab -sed -i '/^# zroot/d' "${MNT}"/etc/fstab -sed -i '/^zroot/d' "${MNT}"/etc/fstab -sed -i '/^$/d' "${MNT}"/etc/fstab -echo "" >> "${MNT}"/etc/fstab # one blank line at the end - -# copy over dns settings to the new system -cp -v /etc/resolv.conf "${MNT}"/etc - -# copy stage2 script to the new system -cp ./stage2.sh "${MNT}"/root - -# ----------------------------- Chroot ---------------------------- - -echo ""; echo "Done with Stage One" -chroot "${MNT}" /usr/bin/env DISK="${DISK}" /root/stage2.sh - -# -------------------------- After Chroot ------------------------- - -umount -Rl "${MNT}" -zfs snapshot -r rpool@initial-installation -zfs snapshot -r bpool@initial-installation - -zpool export -a - -echo ""; echo "Done with Stage Two" diff --git a/zfs_assets/stage2.sh b/zfs_assets/stage2.sh deleted file mode 100755 index 6ec1a52..0000000 --- a/zfs_assets/stage2.sh +++ /dev/null @@ -1,199 +0,0 @@ -#!/usr/bin/env bash -# install arch linux on zfs root, stage two -# - -set -e # halt on any error - -password="welcome" # root password; will force change after login -hostname="velox" -disk=/dev/nvme0n1 - -yay_repo="https://aur.archlinux.org/yay.git" -source_dir="/usr/src" -logfile=/root/zfsarch_stage2.log - -cd # go home - -# --------------------- Add ArchZFS Repository -------------------- - -echo ""; "### ADDING ARCHZFS REPOSITORY " echo "" | tee -a $logfile - -echo ""; "### handling arch keys" echo "" | tee -a $logfile -pacman-key --init >> $logfile 2>&1 -pacman-key --refresh-keys >> $logfile 2>&1 -pacman-key --populate >> $logfile 2>&1 - -curl --fail-early --fail -L https://archzfs.com/archzfs.gpg \ -| pacman-key -a - --gpgdir /etc/pacman.d/gnupg - -pacman-key \ ---lsign-key \ ---gpgdir /etc/pacman.d/gnupg \ -DDF7DB817396A49B2A2723F7403BD972F75D9D76 - -echo ""; "### adding repository info" echo "" | tee -a $logfile -tee -a /etc/pacman.d/mirrorlist-archzfs <<- 'EOF' -## See https://github.com/archzfs/archzfs/wiki -## France -#,Server = https://archzfs.com/$repo/$arch - -## Germany -#,Server = https://mirror.sum7.eu/archlinux/archzfs/$repo/$arch -#,Server = https://mirror.biocrafting.net/archlinux/archzfs/$repo/$arch - -## India -#,Server = https://mirror.in.themindsmaze.com/archzfs/$repo/$arch - -## United States -#,Server = https://zxcvfdsa.com/archzfs/$repo/$arch -EOF - -tee -a /etc/pacman.conf <<- 'EOF' -#[archzfs-testing] -#Include = /etc/pacman.d/mirrorlist-archzfs - -#,[archzfs] -#,Include = /etc/pacman.d/mirrorlist-archzfs -EOF - - -# the '#,' prefix is a workaround for ci/cd tests. we should remove them -sed -i 's|#,||' /etc/pacman.d/mirrorlist-archzfs -sed -i 's|#,||' /etc/pacman.conf -sed -i 's|^#||' /etc/pacman.d/mirrorlist - -# ---------- Install Packages And Linux Compatible Kernel --------- -echo ""; "### INSTALLING COMPATIBLE KERNEL " | tee -a $logfile -echo "### identifying kernel version" | tee -a $logfile - -pacman -Sy >> $logfile 2>&1 - -kernel_compatible_with_zfs="$(pacman -Si zfs-linux \ -| grep 'Depends On' \ -| sed "s|.*linux=||" \ -| awk '{ print $1 }')" - -echo "### installing kernel" | tee -a $logfile -pacman -U --noconfirm https://america.archive.pkgbuild.com/packages/l/linux/linux-"${kernel_compatible_with_zfs}"-x86_64.pkg.tar.zst >> $logfile 2>&1 -pacman -S --noconfirm zfs-linux zfs-utils >> $logfile 2>&1 - -# ---------------------- Configure Mkinitcpio --------------------- - -sed -i 's|filesystems|zfs filesystems|' /etc/mkinitcpio.conf -mkinitcpio -P - -# ------------------------- General Hostid ------------------------ - -zgenhostid -f -o /etc/hostid - -# ---------------------- Apply Grub Workaround ---------------------- -# Note: This workaround needs to be applied for every GRUB update, as the update will overwrite the changes. - -echo 'export ZPOOL_VDEV_NAME_PATH=YES' >> /etc/profile.d/zpool_vdev_name_path.sh -# shellcheck disable=SC1091 -. /etc/profile.d/zpool_vdev_name_path.sh - -# GRUB fails to detect rpool name, hard code as "rpool" -sed -i "s|rpool=.*|rpool=rpool|" /etc/grub.d/10_linux - -# -------------------------- Install Grub ------------------------- - -mkdir -p /boot/efi/archlinux/grub-bootdir/i386-pc/ -mkdir -p /boot/efi/archlinux/grub-bootdir/x86_64-efi/ -for i in ${DISK}; do - grub-install --target=i386-pc --boot-directory \ - /boot/efi/archlinux/grub-bootdir/i386-pc/ "${i}" -done -grub-install --target x86_64-efi --boot-directory \ - /boot/efi/archlinux/grub-bootdir/x86_64-efi/ --efi-directory \ - /boot/efi --bootloader-id archlinux --removable -if test -d /sys/firmware/efi/efivars/; then - grub-install --target x86_64-efi --boot-directory \ - /boot/efi/archlinux/grub-bootdir/x86_64-efi/ --efi-directory \ - /boot/efi --bootloader-id archlinux -fi - -# Import both bpool and rpool at boot: -echo 'GRUB_CMDLINE_LINUX="zfs_import_dir=/dev/"' >> /etc/default/grub - -# Generate GRUB menu: -mkdir -p /boot/grub -grub-mkconfig -o /boot/grub/grub.cfg -cp /boot/grub/grub.cfg \ - /boot/efi/archlinux/grub-bootdir/x86_64-efi/grub/grub.cfg -cp /boot/grub/grub.cfg \ - /boot/efi/archlinux/grub-bootdir/i386-pc/grub/grub.cfg - -# For both legacy and EFI booting: mirror ESP content: -espdir=$(mktemp -d) -find /boot/efi/ -maxdepth 1 -mindepth 1 -type d -print0 \ -| xargs -t -0I '{}' cp -r '{}' "${espdir}" -find "${espdir}" -maxdepth 1 -mindepth 1 -type d -print0 \ - | xargs -t -0I '{}' sh -vxc "find /boot/efis/ -maxdepth 1 -mindepth 1 -type d -print0 | xargs -t -0I '[]' cp -r '{}' '[]'" - - -### ----------------------- Config Environment --------------------- - -# required software -pacman -S --noconfirm sed networkmanager reflector -systemctl enable NetworkManager -systemctl enable reflector.timer - -# parallel downloads -sed -i "s/^#ParallelDownloads = 5$/ParallelDownloads = 15/" /etc/pacman.conf - -# aur config -sed -i '/^CFLAGS=/s/-march=x86-64 -mtune=generic/-march=native/' /etc/makepkg.conf -sed -i 's/^#RUSTFLAGS="-C opt-level=2"/RUSTFLAGS="-C opt-level=2 -C target-cpu=native"/g' /etc/makepkg.conf -sed -i 's/^#MAKEFLAGS="-j2"/MAKEFLAGS="-j$(nproc)"/g' /etc/makepkg.conf -sed -i 's/^COMPRESSXZ=(xz -c -z -)/COMPRESSXZ=(xz -c -z --threads=0 -)/g' /etc/makepkg.conf -sed -i 's/^COMPRESSZST=(zstd -c -z -q -)/COMPRESSZST=(zstd -c -z -q --threads=0 -)/g' /etc/makepkg.conf - -# set up local time -sudo ln -sf /usr/share/zoneinfo/US/Central /etc/localtime -hwclock --systohc - -# set up locale -echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen -locale-gen -echo "LANG=en_US.UTF-8" > /etc/locale.conf - -# set up hostname -echo "$hostname" > /etc/hostname -echo "127.0.0.1 localhost" >> /etc/hosts -echo "::1 localhost" >> /etc/hosts -echo "127.0.1.1 $hostname.localdomain $hostname" >> /etc/hosts - -# console settings -echo "KEYMAP=us" > /etc/vconsole.conf - -# ------------------------ Enable AUR Helper ------------------------ - -pacman -Syy -pacman -S --needed --noconfirm base-devel git openssh wget -build_dir="$source_dir/yay" -mkdir -p "$build_dir" -chown "$username:$username" -R "/home/$username" -sudo -u "$username" git clone --depth 1 "$yay_repo" "$build_dir" -cd "$build_dir" && sudo -u "$username" makepkg --noconfirm -si - -### ------------------------- Enable ZFS Services ---------------------- -# add kernel modules -pacman -S --noconfirm zfs-dkms - -# enable zfs services -systemctl enable zfs-import-cache -systemctl enable zfs-import.target -systemctl enable zfs-mount.service -systemctl enable zfs-share -systemctl enable zfs-zed -systemctl enable zfs.target - -### ----------------------------- Wrap Up -------------------------- - -# set root password; must change first login -echo "root:$password" | chpasswd -chage -d 0 root - -# --------------------------- Exit Chroot --------------------------- -exit diff --git a/zfssetup b/zfssetup deleted file mode 100755 index 6bc95ca..0000000 --- a/zfssetup +++ /dev/null @@ -1,406 +0,0 @@ -#!/usr/bin/env bash -# install arch linux on zfs root, stage one -# Craig Jennings -# -# https://openzfs.github.io/openzfs-docs/Getting%20Started/Arch%20Linux/Root%20on%20ZFS.html - -# set -e # halt on any error - -# -------------------------- Prerequisites -------------------------- - -sed -i "s/^#ParallelDownloads = 5$/ParallelDownloads = 15/" /etc/pacman.conf -loadkeys us -timedatectl set-ntp true - -### --------------------------- Choose Disk --------------------------- - -all_disk_ids=( $(ls /dev/disk/by-id/) ) -echo ""; echo "Select the disk id to use. All data will be erased." -select disk_id in "${all_disk_ids[@]}"; do - # ensure valid selection - if [[ -n $disk_id ]]; then - selection=$disk_id - break - else - echo "Invalid. Try again." - fi -done - -# Confirm the selected disk -read -p "Confirm: '$selection' [y/n]? " choice -if [[ "$choice" != "y" ]]; then - echo "Exiting..." - exit 1 -fi - -DISK="/dev/disk/by-id/$selection" -MNT=/mnt # Set a mount point -SWAPSIZE=4 # Set swap size in GB -RESERVE=1 # Set how much space to leave at the end of disk, minimum 1GB - -### --------------------------- Erase Disk ------------------------- - -echo ""; echo "### Erasing Disk" -blkdiscard -f "${DISK}" || true # discard all sectors on flash-based storage -sgdisk --zap-all "${DISK}" # clear the disk - -### ------------------------- Partition Disk ------------------------ - -echo ""; echo "### Partitioning Disk" -parted --script --align=optimal "${DISK}" -- \ - mklabel gpt \ - mkpart EFI 2MiB 1GiB \ - mkpart bpool 1GiB 5GiB \ - mkpart rpool 5GiB -$((SWAPSIZE + RESERVE))GiB \ - mkpart swap -$((SWAPSIZE + RESERVE))GiB -"${RESERVE}"GiB \ - mkpart BIOS 1MiB 2MiB \ - set 1 esp on \ - set 5 bios_grub on \ - set 5 legacy_boot on - -### ---------------------- Setup Encrypted Swap --------------------- - -echo ""; echo "### Encrypted Swap" -for i in ${DISK}; do - cryptsetup open --type plain --key-file /dev/random "${i}"-part4 "${i##*/}"-part4 - mkswap /dev/mapper/"${i##*/}"-part4 - swapon /dev/mapper/"${i##*/}"-part4 -done - -# ------------------- Create Boot And Root Pools ------------------ - -# This step creates a separate boot pool for /boot with the features limited to -# only those that GRUB supports, allowing the root pool to use any/all features. - -echo ""; echo "### Checking ZFS Module" -modprobe zfs # ensure zfs module is loaded - -echo ""; echo "### Creating Boot Pool" -# shellcheck disable=SC2046 -zpool create -d \ - -o feature@async_destroy=enabled \ - -o feature@bookmarks=enabled \ - -o feature@embedded_data=enabled \ - -o feature@empty_bpobj=enabled \ - -o feature@enabled_txg=enabled \ - -o feature@extensible_dataset=enabled \ - -o feature@filesystem_limits=enabled \ - -o feature@hole_birth=enabled \ - -o feature@large_blocks=enabled \ - -o feature@lz4_compress=enabled \ - -o feature@spacemap_histogram=enabled \ - -o ashift=12 \ - -o autotrim=on \ - -O acltype=posixacl \ - -O canmount=off \ - -O compression=lz4 \ - -O devices=off \ - -O normalization=formD \ - -O relatime=on \ - -O xattr=sa \ - -O mountpoint=/boot \ - -R "${MNT}" \ - bpool \ - $(for i in ${DISK}; do - printf '%s ' "${i}-part2"; - done) - -echo ""; echo "### Creating Root Pool" -# shellcheck disable=SC2046 -zpool create \ - -o ashift=12 \ - -o autotrim=on \ - -R "${MNT}" \ - -O acltype=posixacl \ - -O canmount=off \ - -O compression=zstd \ - -O dnodesize=auto \ - -O normalization=formD \ - -O relatime=on \ - -O xattr=sa \ - -O mountpoint=/ \ - rpool \ - $(for i in ${DISK}; do - printf '%s ' "${i}-part3"; - done) - -echo ""; echo "### Creating Unencrypted Root System Container" -# create UNENCRYPTED root system container -zfs create \ - -o canmount=off \ - -o mountpoint=none \ -rpool/archlinux - -# --------------------- Create System Datasets -------------------- - -echo ""; echo "### Creating System Datasets" -zfs create -o canmount=noauto -o mountpoint=/ rpool/archlinux/root -zfs mount rpool/archlinux/root -zfs create -o mountpoint=legacy rpool/archlinux/home -mkdir "${MNT}"/home -mount -t zfs rpool/archlinux/home "${MNT}"/home -zfs create -o mountpoint=legacy rpool/archlinux/var -zfs create -o mountpoint=legacy rpool/archlinux/var/lib -zfs create -o mountpoint=legacy rpool/archlinux/var/log -zfs create -o mountpoint=none bpool/archlinux -zfs create -o mountpoint=legacy bpool/archlinux/root -mkdir "${MNT}"/boot -mount -t zfs bpool/archlinux/root "${MNT}"/boot -mkdir -p "${MNT}"/var/log -mkdir -p "${MNT}"/var/lib -mount -t zfs rpool/archlinux/var/lib "${MNT}"/var/lib -mount -t zfs rpool/archlinux/var/log "${MNT}"/var/log - -# ---------------------- Format And Mount ESP --------------------- - -echo ""; echo "### Format And Mount ESP" -for i in ${DISK}; do - mkfs.vfat -n EFI "${i}"-part1 - mkdir -p "${MNT}"/boot/efis/"${i##*/}"-part1 - mount -t vfat -o iocharset=iso8859-1 "${i}"-part1 "${MNT}"/boot/efis/"${i##*/}"-part1 -done - -mkdir -p "${MNT}"/boot/efi -mount -t vfat -o iocharset=iso8859-1 "$(echo "${DISK}" | sed "s|^ *||" | cut -f1 -d' '|| true)"-part1 "${MNT}"/boot/efi - -### -------------------------- Install Base ------------------------- - -echo ""; echo "### Installing Base" -# install packages with pacstrap -pacstrap "${MNT}" \ - base \ - base-devel \ - dkms \ - efibootmgr \ - git \ - grub \ - intel-ucode \ - linux-firmware \ - linux-lts \ - linux-lts-headers \ - man-db \ - man-pages \ - vi - -# create fstab and remove all zroot entries -echo ""; echo "### Creating fstab" -genfstab -U -p "${MNT}" >> "${MNT}"/etc/fstab -sed -i '/^# zroot/d' "${MNT}"/etc/fstab -sed -i '/^zroot/d' "${MNT}"/etc/fstab -sed -i '/^$/d' "${MNT}"/etc/fstab -echo "" >> "${MNT}"/etc/fstab # one blank line at the end - -# copy over dns settings to the new system -echo ""; echo "### Copying DNS Settings" -cp -v /etc/resolv.conf "${MNT}"/etc - -# ----------------------------- Chroot ---------------------------- -# copy second part of this script to the new system - -echo ""; echo "### Copying script then chrooting" -sed '1,/^#part2$/d' `basename $0` > "${MNT}"/root -chroot "${MNT}" /usr/bin/env DISK="${DISK}" /root/stage2.sh - -# -------------------------- After Chroot ------------------------- - -umount -Rl "${MNT}" -zfs snapshot -r rpool@initial-installation -zfs snapshot -r bpool@initial-installation - -zpool export -a - -echo ""; echo "### Done with Stage Two" - -#part2 -#!/usr/bin/env bash -# install arch linux on zfs root, stage two -# Craig Jennings - -printf '\033c' - -password="welcome" # root password; will force change after login -hostname="velox" -disk=/dev/nvme0n1 - -yay_repo="https://aur.archlinux.org/yay.git" -source_dir="/usr/src" -logfile=/root/zfsarch_stage2.log - -cd # go home - -# --------------------- Add ArchZFS Repository -------------------- - -pacman-key --init -pacman-key --refresh-keys -pacman-key --populate - -curl --fail-early --fail -L https://archzfs.com/archzfs.gpg \ -| pacman-key -a - --gpgdir /etc/pacman.d/gnupg - -pacman-key \ ---lsign-key \ ---gpgdir /etc/pacman.d/gnupg \ -DDF7DB817396A49B2A2723F7403BD972F75D9D76 - -tee -a /etc/pacman.d/mirrorlist-archzfs <<- 'EOF' -## See https://github.com/archzfs/archzfs/wiki -## France -#,Server = https://archzfs.com/$repo/$arch - -## Germany -#,Server = https://mirror.sum7.eu/archlinux/archzfs/$repo/$arch -#,Server = https://mirror.biocrafting.net/archlinux/archzfs/$repo/$arch - -## India -#,Server = https://mirror.in.themindsmaze.com/archzfs/$repo/$arch - -## United States -#,Server = https://zxcvfdsa.com/archzfs/$repo/$arch -EOF - -tee -a /etc/pacman.conf <<- 'EOF' - -#[archzfs-testing] -#Include = /etc/pacman.d/mirrorlist-archzfs - -#,[archzfs] -#,Include = /etc/pacman.d/mirrorlist-archzfs -EOF - -# this #, prefix is a workaround for ci/cd tests -# remove them -sed -i 's|#,||' /etc/pacman.d/mirrorlist-archzfs -sed -i 's|#,||' /etc/pacman.conf -sed -i 's|^#||' /etc/pacman.d/mirrorlist - -# ---------- Install Packages And Linux Compatible Kernel --------- -pacman -Sy - -kernel_compatible_with_zfs="$(pacman -Si zfs-linux \ -| grep 'Depends On' \ -| sed "s|.*linux=||" \ -| awk '{ print $1 }')" -pacman -U --noconfirm https://america.archive.pkgbuild.com/packages/l/linux/linux-"${kernel_compatible_with_zfs}"-x86_64.pkg.tar.zst - -pacman -S --noconfirm zfs-linux zfs-utils - -# ---------------------- Configure Mkinitcpio --------------------- - -sed -i 's|filesystems|zfs filesystems|' /etc/mkinitcpio.conf -mkinitcpio -P - -# ------------------------- General Hostid ------------------------ - -zgenhostid -f -o /etc/hostid - -# ---------------------- Apply Grub Workaround ---------------------- -# Note: This workaround needs to be applied for every GRUB update, as the update will overwrite the changes. - -echo 'export ZPOOL_VDEV_NAME_PATH=YES' >> /etc/profile.d/zpool_vdev_name_path.sh -# shellcheck disable=SC1091 -. /etc/profile.d/zpool_vdev_name_path.sh - -# GRUB fails to detect rpool name, hard code as "rpool" -sed -i "s|rpool=.*|rpool=rpool|" /etc/grub.d/10_linux - -# -------------------------- Install Grub ------------------------- - -mkdir -p /boot/efi/archlinux/grub-bootdir/i386-pc/ -mkdir -p /boot/efi/archlinux/grub-bootdir/x86_64-efi/ -for i in ${DISK}; do - grub-install --target=i386-pc --boot-directory \ - /boot/efi/archlinux/grub-bootdir/i386-pc/ "${i}" -done -grub-install --target x86_64-efi --boot-directory \ - /boot/efi/archlinux/grub-bootdir/x86_64-efi/ --efi-directory \ - /boot/efi --bootloader-id archlinux --removable -if test -d /sys/firmware/efi/efivars/; then - grub-install --target x86_64-efi --boot-directory \ - /boot/efi/archlinux/grub-bootdir/x86_64-efi/ --efi-directory \ - /boot/efi --bootloader-id archlinux -fi - -# Import both bpool and rpool at boot: -echo 'GRUB_CMDLINE_LINUX="zfs_import_dir=/dev/"' >> /etc/default/grub - -# Generate GRUB menu: -mkdir -p /boot/grub -grub-mkconfig -o /boot/grub/grub.cfg -cp /boot/grub/grub.cfg \ - /boot/efi/archlinux/grub-bootdir/x86_64-efi/grub/grub.cfg -cp /boot/grub/grub.cfg \ - /boot/efi/archlinux/grub-bootdir/i386-pc/grub/grub.cfg - -# For both legacy and EFI booting: mirror ESP content: -espdir=$(mktemp -d) -find /boot/efi/ -maxdepth 1 -mindepth 1 -type d -print0 \ -| xargs -t -0I '{}' cp -r '{}' "${espdir}" -find "${espdir}" -maxdepth 1 -mindepth 1 -type d -print0 \ - | xargs -t -0I '{}' sh -vxc "find /boot/efis/ -maxdepth 1 -mindepth 1 -type d -print0 | xargs -t -0I '[]' cp -r '{}' '[]'" - -### ----------------------- Config Environment --------------------- - -# required software -pacman -S --noconfirm sed networkmanager reflector -systemctl enable NetworkManager -systemctl enable reflector.timer - -# parallel downloads -sed -i "s/^#ParallelDownloads = 5$/ParallelDownloads = 15/" /etc/pacman.conf - -# aur config -sed -i '/^CFLAGS=/s/-march=x86-64 -mtune=generic/-march=native/' /etc/makepkg.conf -sed -i 's/^#RUSTFLAGS="-C opt-level=2"/RUSTFLAGS="-C opt-level=2 -C target-cpu=native"/g' /etc/makepkg.conf -sed -i 's/^#MAKEFLAGS="-j2"/MAKEFLAGS="-j$(nproc)"/g' /etc/makepkg.conf -sed -i 's/^COMPRESSXZ=(xz -c -z -)/COMPRESSXZ=(xz -c -z --threads=0 -)/g' /etc/makepkg.conf -sed -i 's/^COMPRESSZST=(zstd -c -z -q -)/COMPRESSZST=(zstd -c -z -q --threads=0 -)/g' /etc/makepkg.conf - -# set up local time -sudo ln -sf /usr/share/zoneinfo/US/Central /etc/localtime -hwclock --systohc - -# set up locale -echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen -locale-gen -echo "LANG=en_US.UTF-8" > /etc/locale.conf - -# set up hostname -echo "$hostname" > /etc/hostname -echo "127.0.0.1 localhost" >> /etc/hosts -echo "::1 localhost" >> /etc/hosts -echo "127.0.1.1 $hostname.localdomain $hostname" >> /etc/hosts - -# console settings -echo "KEYMAP=us" > /etc/vconsole.conf - -# ------------------------ Enable AUR Helper ------------------------ - -pacman -Syy -pacman -S --needed --noconfirm base-devel git openssh wget -build_dir="$source_dir/yay" -mkdir -p "$build_dir" -chown "$username:$username" -R "/home/$username" -sudo -u "$username" git clone --depth 1 "$yay_repo" "$build_dir" -cd "$build_dir" && sudo -u "$username" makepkg --noconfirm -si - -### ------------------------- Enable ZFS Services ---------------------- -# add kernel modules - -pacman -S --noconfirm zfs-dkms - -# enable zfs services -systemctl enable zfs-import-cache -systemctl enable zfs-import.target -systemctl enable zfs-mount.service -systemctl enable zfs-share -systemctl enable zfs-zed -systemctl enable zfs.target - -### ----------------------------- Wrap Up -------------------------- - -# set root password; must change first login -echo "root:$password" | chpasswd -chage -d 0 root - -# --------------------------- Exit Chroot --------------------------- -exit -- cgit v1.2.3