Calamares and predefined partitions

I was hoping to set up Endeavour with a custom partitioning scheme not directly supported by Calamares (as far as I can tell).

  • Two drives, each with three partitions.
  • Parition 1 on each is a Fat32 partition for esp, synced via pacman hooks.
  • Parition 2 on each is a separate swap partition (on the theory that parallelizing swap will be good for performance)
  • An mdadm raid-1 array mirroring the third partitions.
  • The mdadm array formatted as xfs, with the options su=64k,sw=1 -m crc=1,reflink=1

I have a script that seems like it ought to work, but when I run Calamares (online or offline), at the manual partitioning screenm, I only see the XFS-formatted md0, but not the existing fat32 and swap partitions, which means I cannot edit them and manually set their moutpoints.

Ideally, I would like to have a totally hands-off installation with everything preconfigured beforehand, but based on what I have read, the installer cannot go completely unsupervised and there is no automation-friendly alternative.

Is what I am trying to do realistic, or should I give up and just use plain Arch if I want special disk setups?

My current script:

#!/bin/bash

set -euo pipefail

# Devices
# DISK1="/dev/sdb"
# DISK2="/dev/sdg"
PRIMARY_DISPLAY=DP-2
DISK1=$1
DISK2=$2


# Partitions
ESP_SIZE="2GiB"
SWAP_SIZE="64GiB"

# Cleanup
sudo wipefs -a "$DISK1" "$DISK2"
sudo sgdisk --zap-all "$DISK1" "$DISK2"

# Partition layout: ESP (1), SWAP (2), RAID (3)
for DISK in "$DISK1" "$DISK2"; do
  sudo sgdisk -n1:0:+$ESP_SIZE -t1:ef00 "$DISK"
  sudo sgdisk -n2:0:+$SWAP_SIZE -t2:8200 "$DISK"
  sudo sgdisk -n3:0:0      -t3:fd00 "$DISK"
done

# Wait for partitions
udevadm settle

# Create RAID1 array
sudo mdadm --create /dev/md0 --level=1 --raid-devices=2 \
  "${DISK1}3" "${DISK2}3" --metadata=1.2

# Format partitions
sudo mkfs.vfat -F32 "${DISK1}1"
sudo mkfs.vfat -F32 "${DISK2}1"
sudo mkswap "${DISK1}2"
sudo mkswap "${DISK2}2"

# Format XFS with reflink and metadata checksum
sudo mkfs.xfs -d su=64k,sw=1 -m crc=1,reflink=1 /dev/md0

# Mount for Calamares
sudo mount /dev/md0 /mnt
sudo mkdir -p /mnt/boot
sudo mount "${DISK1}1" /mnt/boot

# Setup mdadm.conf for installed system
sudo mkdir -p /mnt/etc
sudo mdadm --detail --scan | sudo tee /mnt/etc/mdadm.conf

# Inform the kernel of partition table changes
sudo partprobe "$DISK1"
sudo partprobe "$DISK2"

# Copy Calamares config overrides
sudo mkdir -p /mnt/etc/calamares/modules

cat | sudo tee /mnt/etc/calamares/modules/partition.conf <<EOF
---
mount:
  - mountPoint: /
    device: /dev/md0
    fs: xfs
    format: false
  - mountPoint: /boot
    device: ${DISK1}1
    fs: vfat
    format: false

swap:
  - device: ${DISK1}2
    enabled: true
    priority: 100
  - device: ${DISK2}2
    enabled: true
    priority: 100
EOF

cat | sudo tee /mnt/etc/calamares/modules/bootloader.conf <<EOF
---
bootLoader: grub
efiBootLoader: true
EOF

# Create mirror-esp hook and script
sudo mkdir -p /mnt/usr/local/bin
cat | sudo tee /mnt/usr/local/bin/mirror-esp <<'EOS'
#!/bin/bash
set -euo pipefail
SRC=/boot
DST=/boot2

mkdir -p "$DST"
mount /dev/sdg1 "$DST"
rsync -a --delete "$SRC/" "$DST/"
umount "$DST"
EOS

sudo chmod +x /mnt/usr/local/bin/mirror-esp

sudo mkdir -p /mnt/etc/pacman.d/hooks
cat | sudo tee /mnt/etc/pacman.d/hooks/mirror-esp.hook <<EOF
[Trigger]
Type = Path
Operation = Install
Operation = Upgrade
Target = linux*

[Action]
Description = Mirroring ESP to /dev/sdg1...
When = PostTransaction
Exec = /usr/local/bin/mirror-esp
EOF


# Create weston.ini to specify the primary display for Wayland
sudo mkdir -p /mnt/etc/xdg/weston
cat | sudo tee /mnt/etc/xdg/weston/weston.ini <<EOF
[output]
name=$PRIMARY_DISPLAY
primary=true
EOF




cat | sudo tee /mnt/etc/calamares/modules/packages.conf <<EOF
---
packages:
  - base                            # Core system files
  - linux-lts                       # Long-term support kernel
  - linux-lts-headers               # Kernel headers for building modules

  # KDE Plasma and Applications
  - plasma-meta                     # Base KDE Plasma desktop environment
  - kde-applications-meta           # Common KDE applications (incl. ark, kwallet, etc.)

  # Networking & SSH
  - openssh                         # SSH server/client
  - fail2ban                        # Ban IPs after failed login attempts
  - wireguard-tools                 # WireGuard VPN support

  # Disk & Power Tools
  - gptfdisk                        # GPT partitioning tools (gdisk)
  - powertop                        # Power consumption tuner
  - smartmontools                  # Disk SMART diagnostics
  - hdparm                          # Disk parameter tuner
  - nvme-cli                        # NVMe drive utility
  - sysstat                         # iostat, mpstat, etc.

  # RAID / ZFS
  - zfs-dkms                        # ZFS kernel module (LTS-compatible)

  # File & System Info Tools
  - filelight                       # KDE disk usage visualizer
  - fastfetch                       # Terminal system info display
  - bat                             # Syntax-highlighted cat replacement
  - ripgrep                         # Fast recursive grep
  - exa                             # Enhanced ls alternative
  - fzf                             # Fuzzy finder for terminal
  - htop                            # Terminal process monitor
  - bmon                            # Bandwidth monitor
  - iftop                           # Real-time bandwidth usage by connection
  - lsof                            # List open files
  - strace                          # Trace system calls of a process
  - nvtop                           # Real-time NVIDIA GPU process monitor
  - usbutils                        # for lsusb, useful with peripheral debugging.
  - pciutils                        # for lspci, helpful for hardware checking.
  - ethtool                         # advanced network tuning.
  - ntfs-3g                         # NTFS read/write support (for shared drives with Windows).
  - rsync                           # rsync
  - man-db                          # man-db
  - man-pages                       # man-pages

  # Dev & Shell Tools
  - devtools                        # Arch packaging tools (makepkg, etc.)
  - git                             # Version control system
  - vim                             # Terminal text editor
  - tmux                            # Terminal multiplexer
  - stow                            # Dotfile symlink manager
  - zsh                             # Z shell
  - zsh-autosuggestions             # Autosuggestions for Zsh
  - zsh-autocomplete                # Zsh completion enhancements

  # KDE Wallet Integration
  - kwallet                         # KDE Wallet backend
  - kwalletmanager                  # GUI for managing KDE Wallets
  - kwallet-pam                     # KDE Wallet PAM integration
  - ksshaskpass                     # SSH key unlock integration for KDE

  # Networking/Diagnostics
  - nmap                            # Network scanner
  - tcpdump                         # Packet capture tool
  - netcat                          # Versatile networking tool
  - traceroute                      # Trace route to a host
  - wireshark-cli                   # CLI packet analyzer

  # Multimedia & Audio
  - ffmpeg                          # Media conversion and encoding
  - gst-plugin-va                   # Video acceleration plugins (VA-API)
  - strawberry                      # Music player (Qt-based alternative to Clementine)

  # Downloads & Torrents
  - transmission-qt                 # Qt-based torrent client

  # Boot/Login Display
  - sddm                            # KDE-compatible display/login manager
  - xorg                            # X11 server

  # Security
  - yubikey-manager                 # YubiKey configuration utility
  - gnupg                           # GPG encryption and key management
  - gpgme                           # GPG API for applications
EOF

echo "Done. You can now launch Calamares and install to the prepared partitions."

Welcome to the forum!

If you run the script before starting calamares, can you see the changes the script makes with e.g. gparted? Are they all OK?
This should be easy to test in a VM.

Yes, the partitions all exist, and mounted at /boot and /.

Make sure you unmount everything before starting the installer.

The changes to packages.conf and partition.conf all look incorrect. Those config files don’t have those keys. That would probably leave the installer in a broken state. That being said, it looks like you are writing them to wrong place. The config files need to be changed on the ISO, not in /mnt. You should not overwrite bootloader.conf.

Are you sure that your want kde-applications-meta? That will install hundreds of applications and not let you remove any of them easily. You don’t need to install base. That will get handled in the pacstrap.

1 Like

You mean to the mounted ISO right? I copied the files instead to /etc/calamares/modules/, and that didn’t seem to break anything (at least up to the manual partitioning screen), so I’m still not sure the files are even being read.

Good point about kde-applications-meta. I forgot just how big it actually is.

In any case, the information I am seeking is whether it is even possible for me to configure the installation I describe. Are the correct keys accepted in the partition.conf file listed in complete form anyplace?

It would basically take all defaults in that case since you aren’t setting any of the keys. The breakage would likely come after that point, when it tried to do the install. Especially the bootloader.conf changes.

Some of the things would have to be handled in manual partitioning, they can’t be automated.

Some of the things would be easier to deal with post-install.

It isn’t clear to me from the partitionLayout section in the reference partitions.conf if I can include options to mkfs.xfs such as -d su=64k,sw=1 -m crc=1,reflink=1.

Could I just do this?

      features:
        - "-d"
        - "su=64k,sw=1"
        - "-m"
        - "crc=1"

Also it isn’t clear to me from the example if I can specify which partition should be mounted as EFI.

efi:
    mountPoint:         "/boot/efi"
    recommendedSize:    300MiB
    minimumSize:        32MiB
    label:              "EFI"

I obviously do not want it to be carved out of the RAID array when I select that as the install target.

And I guess there is no actual reason I need to specify both swap partitions during installation so long as the partitions exist.

You can format the partition before installing. When you use manual partitioning, you can select to not format the partition.

You can’t, you do that in the installer itself.

Yes. Although, given your setup, have you considered using a swapfile on your md array?

You can’t, you do that in the installer itself.

How do I specify the EFI partition within the installer? I was expecting the fat32 partition to show in manual partitioning and then to set the mountpoint to /boot

Yes. Although, given your setup, have you considered using a swapfile on your md array?

I don’t see the point of mirroring swap, what would the benefit be? It seems like extra writes for nothing. My thought was to have two separate swaps on different disks, so that both could be used in parallel.

For the automated options there is a dropdown. For manual partitioning you pick it manually.

It should show up. Did you unmount it before launching the installer?

That being said, if you are using grub, it must be mounted to /boot/efi

Yes, I did unmount it, no luck. But if I can get it to appear, I will be sure to mount it at /boot/efi.

Can you share a screenshot of the manual partitioning screen?