I am installing a headless nas/media server on artix. The general Idea is:
- Boot partition on md raid1 following this blog post
- System partition on btrfs raid1
- ssd cache partition on a drive separate from where system partition is
- A small partition for the grub environment that is not in raid1. The idea is to make sure that grub-reboot works.
- btrfs raid6 for my data, media but also for things like /var /var/log
I am trying to write a documentation for myself as I move along to know how to fix things or reinstall if needed. This is said documentation so far:
1. Base System Installation
https://wiki.artixlinux.org/Main/Installation
https://wiki.archlinux.org/title/Installation_guide
1.1. Download artix image
https://torrents.artixlinux.org/torrents.php
Depending on hardware and what is supported an image with a desktop environment may work or not
1.2. Set keyboard layout
See https://wiki.artixlinux.org/Main/Installation#:~:text=and%20UEFI%20systems.-,Set%20the%20keyboard%20layout,-To%20check%20the
1.3. Partition the disks
https://wiki.artixlinux.org/Main/Installation#:~:text=KEYMAP%3Dde%2Dlatin1-,Partition%20your%20disk,-Partition%20your%20hard
Use cfdisk on block devices
cfdisk /dev/[block device, no partition]
1.3.1. Partition layout
• Boot partition:
Recommended size is 1GiB. If possible 2GiB or even 4GiB to avoid resizing and moving partitions in worst case scenario.
https://wiki.archlinux.org/title/Installation_guide#:~:text=systems%20supporting%20it.-,Example%20layouts,-UEFI%20with%20GPT
https://askubuntu.com/questions/1400872/what-is-the-correct-type-and-size-for-a-boot-partition-for-bios
mkfs.fat -F 32 /dev/[partition]
o If the system will be a raid1 with N mirrors it makes sense to have the boot partitions on N mirrors as well. In this case mdadm raid1 will be used
https://outflux.net/blog/archives/2018/04/19/uefi-booting-and-raid1/
mdadm --create /dev/md0 --level 1 --raid-disks N --metadata 1.0 /dev/[first boot partition] /dev/[second boot partition]
--metadata 1.0 puts md raid metadata at the end of a drive which means that uefi can read any of the drives without knowing it is a raid.
mkfs.fat -F 32 /dev/md0
• Swap partition
All swap partitions should add up at least to the size of physical memory if the space needed for that is not important for other things. If there may be more memory in the future, swap of at least the size of maximum physical memory achievable in the system would be a good idea to avoid resizing and moving partitions in the future.
If the system will be on a raid1, each system drive may have a portion of the swap. With right configuration the OS will use both drives equally which boosts performance and spreads wear on multiple drives in case of a ssd.
If a cache drive for data will be used a part of swap may be on that drive. With the right configuration the OS may prioritize to use the swap on system drives or cache drive first. It would make sense to prioritize the cache drive swap because it will typically be more wear resistant than a cheap system drive and is much easier to replace in case of failure.
mkswap -L [label] /dev/[partition]
If system drives are not equal in size The bigger drive may be bigger since the system partitions need to be equal in size for raid1 configuration.
• Grub environment partition (optional if there is a separate drive to accommodate it. E.g. cache drive.)
Will be used for grub environment. If we use grub-reboot without it, it would be replicated on all boot partitions if they are in a raid. That means that during boot only one of them would be reset back to default leading to desync. Simplest solution is a partition on a separate drive.
• Cache partition (if a cache drive is present)
Remaining space of the cache drive after grub environment and swap. Will be setup when data drives will be setup.
• System partition
mkfs.btrfs -L SYSTEM –csum xxhash -d raid1 -m raid1 /dev/[first system partition] [/dev/[second system partition]…]
• Data partition
For raid 6 at least 3 drives are needed. The profiles can be changed after creation of the btrfs filesystem.
Important: metadata shouldn’t be on a raid 5/6. For data on raid5 or 6 put metadata on raid1 or raid1c3 respectively.
o If cache drive is present
Connect to internet. If connmanctl doesn’t work correctly restart connmanctl service with s6-svc -r /run/service/connmand-srv
rfkill unblock wifi
ip link set wlan0 up
connmanctl
scan wifi
services
connect wifi_[…]
quit
Install git and base-devel
pacman -Sy git base-devel
Download bcache aur package as non-root user in home
git clone https://aur.archlinux.org/bcache-tools.git
cd bcache-tools
optional: set make args to -j[core count] in /etc/makepkg.conf
vi /etc/makepkg.conf
makepkg
pacman -U bcache-tools-*.pkg.tar.zst
For each data drive
make-bcache -B /dev/[data partition or device]
make-bcache -C /dev/[cache partition]
o Create btrfs on raw devices, partitions or in case of cache the newly created bcache decices
mkfs.btrfs -L DATA -d raid6 -m raid1c3 –csum xxhash /dev/[first data partition, raw device or cache device] [/dev/[second data partition, raw device or cache device]…]
1.3.2. Root filesystem
Under /mnt create /mnt/btrfs/system and /mnt/btrfs/data directories/mountpoints
mkdir /mnt/btrfs
mkdir /mnt/btrfs/system
mkdir /mnt/btrfs/data
Mount btrfs filesystems
mount -t btrfs -o compress=zstd,ssd /dev/[one of system partitions] /mnt/btrfs/system
mount -t btrfs -o compress=zstd,nossd /dev/[one of data partitions(bcache if used)] /mnt/btrfs/data
Create directory/mountpoint for the target system
mkdir /mnt/root
Mount boot
mount /dev/md0 /mnt/root/boot
Create subvolumes
• Root
btrfs sub create /mnt/btrfs/system/@root
mount -t btrfs -o acl,noautodefrag,barrier,datacow,datasum,ssd,subvolid=[subvolume id of @root subvolume] /dev/[system btrfs partition] /mnt/root
• Home
btrfs sub create /mnt/btrfs/data/@home
mount -t btrfs -o acl,autodefrag,barrier,compress=zstd,datacow,datasum,nossd,subvolid=[subvolume id of @home subvolume] /dev/[data btrfs partition] /mnt/root/home
• Srv
btrfs sub create /mnt/btrfs/data/@srv
mount -t btrfs -o acl,autodefrag,barrier,compress=zstd,datacow,datasum,nossd,subvolid=[subvolume id of @srv subvolume] /dev/[data btrfs partition] /mnt/root/srv
• Var
btrfs sub create /mnt/btrfs/data/@var
mount -t btrfs -o acl,autodefrag,barrier,compress=zstd,datacow,datasum,nossd,subvolid=[subvolume id of @srv subvolume] /dev/[data btrfs partition] /mnt/root/var
• Var/log
btrfs sub create /mnt/btrfs/data/@varlog
mount -t btrfs -o noatime,acl,autodefrag,barrier,compress=zstd,nodatacow,nodatasum,nossd,subvolid=[subvolume id of @varlog subvolume] /dev/[data btrfs partition] /mnt/root/var/log
• Var/lock
btrfs sub create /mnt/btrfs/data/@varlock
mount first after installation
mount -t btrfs -o acl,noautodefrag,barrier,nodatacow,nodatasum,nossd,subvolid=[subvolume id of @varlock subvolume] /dev/[data btrfs partition] /mnt/root/var/lock
• Var/cache
btrfs sub create /mnt/btrfs/data/@varcache
mount -t btrfs -o noatime,acl,barrier,compress=zstd,nodatacow,nodatasum,nossd,subvolid=[subvolume id of @varcache subvolume] /dev/[data btrfs partition] /mnt/root/var/cache
• Usr
btrfs sub create /mnt/btrfs/system/@usr
mount -t btrfs -o acl,noautodefrag,barrier,datacow,datasum,ssd,subvolid=[subvolume id of @usr subvolume] /dev/[system btrfs partition] /mnt/root/usr
• Opt
btrfs sub create /mnt/btrfs/system@opt
mount -t btrfs -o acl,noautodefrag,barrier,datacow,datasum,ssd,subvolid=[subvolume id of @opt subvolume] /dev/[system btrfs partition] /mnt/root/opt
• Torrents
btrfs sub create /mnt/btrfs/data/@torrents
mount -t btrfs -o acl,autodefrag,barrier,compress=zstd,nodatacow,nodatasum,nossd,subvolid=[subvolume id of @torrents subvolume] /dev/[data btrfs partition] /mnt/root/var/torrents
1.4. Update system clock
If not already done connect to internet
If connmanctl doesn’t work correctly restart connmanctl service with s6-svc -r /run/service/connmand-srv
rfkill unblock wifi
ip link set wlan0 up
connmanctl
scan wifi
services
connect wifi_[…]
quit
Start ntp service
s6-rc -u change ntpd
1.5. Install base system
basestrap /mnt/root base base-devel s6-base elogind-s6
Install kernel
basestrap /mnt/root linux linux-firmware
The last basestrap line produces following
Creating install root at /mnt/root
Installing packages to /mnt/root
:: Synchronizing package databases...
system downloading...
world downloading...
galaxy downloading...
resolving dependencies...
looking for conflicting packages...
Packages (2) linux-6.10.2.artix1-1 linux-firmware-20240703.e94a2a3b-1
Total Installed Size: 372.49 MiB
Net Upgrade Size: 0.00 MiB
:: Proceed with installation? [Y/n]
checking keyring...
checking package integrity...
loading package files...
checking for file conflicts...
checking available disk space...
:: Processing package changes...
reinstalling linux...
reinstalling linux-firmware...
:: Running post-transaction hooks...
(1/2) Updating module dependencies...
(2/2) Updating linux initcpios...
==> Building image from preset: /etc/mkinitcpio.d/linux.preset: 'default'
==> Using default configuration file: '/etc/mkinitcpio.conf'
-> -k /boot/vmlinuz-linux -g /boot/initramfs-linux.img
==> Starting build: '6.10.2-artix1-1'
-> Running build hook: [base]
-> Running build hook: [udev]
-> Running build hook: [autodetect]
-> Running build hook: [microcode]
-> Running build hook: [modconf]
-> Running build hook: [kms]
-> Running build hook: [keyboard]
==> WARNING: Possibly missing firmware for module: 'xhci_pci'
-> Running build hook: [keymap]
-> Running build hook: [consolefont]
==> WARNING: consolefont: no font found in configuration
-> Running build hook: [block]
-> Running build hook: [filesystems]
-> Running build hook: [fsck]
==> WARNING: No fsck helpers found. fsck will not be run on boot.
==> Generating module dependencies
==> Creating zstd-compressed initcpio image: '/boot/initramfs-linux.img'
==> WARNING: errors were encountered during the build. The image may not be complete.
==> Building image from preset: /etc/mkinitcpio.d/linux.preset: 'fallback'
==> Using default configuration file: '/etc/mkinitcpio.conf'
-> -k /boot/vmlinuz-linux -g /boot/initramfs-linux-fallback.img -S autodetect
==> Starting build: '6.10.2-artix1-1'
-> Running build hook: [base]
-> Running build hook: [udev]
-> Running build hook: [microcode]
-> Running build hook: [modconf]
-> Running build hook: [kms]
==> WARNING: Possibly missing firmware for module: 'ast'
-> Running build hook: [keyboard]
==> WARNING: Possibly missing firmware for module: 'xhci_pci'
-> Running build hook: [keymap]
-> Running build hook: [consolefont]
==> WARNING: consolefont: no font found in configuration
-> Running build hook: [block]
==> WARNING: Possibly missing firmware for module: 'aic94xx'
==> WARNING: Possibly missing firmware for module: 'bfa'
==> WARNING: Possibly missing firmware for module: 'qed'
==> WARNING: Possibly missing firmware for module: 'qla2xxx'
==> WARNING: Possibly missing firmware for module: 'qla1280'
==> WARNING: Possibly missing firmware for module: 'wd719x'
-> Running build hook: [filesystems]
-> Running build hook: [fsck]
==> Generating module dependencies
==> Creating zstd-compressed initcpio image: '/boot/initramfs-linux-fallback.img'
-> Early uncompressed CPIO image generation successful
==> Initcpio image generation successful
I am following artix and arch installation guides as closely as applicable. Am I doing something that will not work? Or am I missing something, to do, what I am trying to do?