Manjaro

Some installation notes for my Manjaro setups.

Grub Settings

I like my Grub menu. So I want it enabled. Beneath that, I want to see what the kernel is doing during startup. So use the following settings:

Encrypted Swap

Encrypted SWAP doesn't work well together with suspend to disk. So disable suspend to disk:

Applications

Via Pamac GUI:

Some applications, that I install every time:

pamac install \
    chromium \
    difftastic \
    diffutils \
    element-desktop \
    epson-inkjet-printer-escpr2 \
    evince \
    firefox-i18n-de \
    firewall-applet
    firewall-config \
    firewalld \
    freecad \
    gimp \
    git \
    hibiscus \
    htop \
    hunspell-de \
    hyphen-de \
    inkscape \
    inotify-tools \
    keepassxc \
    languagetool \
    lsof \
    meld \
    mpv \
    neovim \
    nextcloud-client \
    nmap \
    onboard \
    openscad \
    qcad \
    signal-desktop \
    sshfs \
    syncthing \
    syncthingtray-qt6 \
    tcpdump \
    thunderbird \
    thunderbird-i18n-de \
    tmux \
    tree \
    ttf-opensans \
    uv \
    vim-spell-de \
    vim-spell-en \
    vlc \
    vlc-plugin-all \
    yakuake \
    yt-dlp

Network services

Udev

I want to mount my drives in /media, so that they can be easily typed in a console. For that create /etc/udev/rules.d/99-cm-mount-in-media.rules:

# Mount filesystems in /media

ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{UDISKS_FILESYSTEM_SHARED}="1"

Beneath that, I often want to use dd on a USB stick. To make that simpler from a user perspective, I allow writing as a user. That has the positive side effect, that I can't accidentally wipe my internal disk:

# Allow user access to USB storage

SUBSYSTEMS=="usb", DRIVERS=="usb-storage", GROUP="usbdisk", MODE="0660"

Migrating an ext4 Installation to btrfs

I had some bad experiences with btrfs in the past. Therefore I preferred an ext4 installation on some of my Manjaro machines. I later noted that this is a bad choice, because if an auto update fails (and it will fail at some point), it leaves you with a broken installation that needs manual fixes. btrfs is a good method to avoid these situations. So I decided to migrate these machines. Tricky part: I don't want to reinstall everything. So these are some notes what has to be adapted on a live migration.

I always have a separate home partition. So I assume that setup here.

This is intended as a collection of notes so that I can do that multiple times with some time in between. So it's not an entry level guide but just info for myself. To make sure, no one copy and pastes commands without knowing anything about them, I change the drive to /dev/sdz99. That drive should not exist on most systems. It has to be adapted to the root partition.

  1. Find the right partition. lsblk -f is useful for that. Keep that output on a separate console to find the old UUIDs!
  2. Backup: I change the root file system. So a backup of the entire file system is necessary. I just use dd for that to put an image to an external drive.
  3. Boot a live system. I use the Manjaro installer.
  4. Check file system: fsck.ext4 /dev/sdz99. Should show no errors.
  5. Convert to btrfs: btrfs-convert /dev/sdz99. Should finish with a Conversion complete.
  6. Mount the converted file system: mount -t btrfs -o subvol=/ /dev/sdz99 /mnt
  7. Adapt to standard layout that is used after a fresh installation:
    • Show subvolumes with btrfs subvolume list /mnt. Should be only the ext2_saved.
    • Add new subvolumes @, @log and @cache:
      btrfs subvolume create /mnt/@
      btrfs subvolume create /mnt/@log
      btrfs subvolume create /mnt/@cache
      
    • Rename saved file system:
      mv /mnt/ext2_saved /mnt/@ext2_saved
      
    • Move files to the new subvolumes
      mv /mnt/var/cache/* /mnt/@cache
      mv /mnt/var/cache/.* /mnt/@cache
      mv /mnt/var/log/* /mnt/@log
      mv /mnt/var/log/.* /mnt/@log
      mv /mnt/[a-z]* /mnt/@
      mv /mnt/.[a-z]* /mnt/@
      
    • Make sure that only the suvolumes are left (everything starting with @):
      ls -la /mnt
      
    • Set new default subvolume
      btrfs subvolume set-default /mnt/@
      
  8. Adapt /etc/fstab: vim /mnt/@/etc/fstab
    • Comment the current line for root file system. Should be something with / and the old UUID from the old lsblk call.
    • Add new entries (get new UUID from a new lsblk call):
      UUID=12345678-1234-1234-1234-123456789abc  /  btrfs  subvol=/@,defaults,compress=zstd:1,relatime,discard=sync 0 0
      UUID=12345678-1234-1234-1234-123456789abc  /var/cache  btrfs  subvol=/@cache,defaults,compress=zstd:1,relatime,discard=sync 0 0
      UUID=12345678-1234-1234-1234-123456789abc  /var/log  btrfs  subvol=/@log,defaults,compress=zstd:1,relatime,discard=sync 0 0
      
  9. Unmount umount /mnt and remount with all subvolumes:
    umount /mnt
    mount -t btrfs -o subvol=/@ /dev/sdz99 /mnt
    mount -t btrfs -o subvol=/@cache /dev/sdz99 /mnt/var/cache
    mount -t btrfs -o subvol=/@log /dev/sdz99 /mnt/var/log
    # mount other partitions like EFI here. Check in fstab what is necessary
    
  10. Chroot into that directory with manjaro-chroot /mnt and do the following
    • Change GRUB_SAVEDEFAULT from true to false in /etc/default/grub
    • Regenerate grub config with grub-mkconfig -o /boot/grub/grub.cfg
    • Reinstall grub with grub-install
    • Make sure that timeshift, timeshift-autosnap-manjaro and grub-btrfs are installed.
    • Enable btrfs mode with timeshift --btrfs
    • Regenerate initramfs with mkinitcpio -P
    • Logout from chroot
  11. Unmount everything: umount -R /mnt
  12. Cleanup new file system:
    • Mount again to /mnt with mount -t btrfs -o subvol=/ /dev/sdz99 /mnt
    • Delete old filesystem btrfs subvolume delete /mnt/@ext2_saved
    • Defrag btrfs filesystem defrag -v -r -f -t 32M /mnt
    • Balance (may need long) btrfs balance start -m /mnt/btrfs
  13. Unmount and reboot: umount /mnt && reboot
  14. Run sudo timeshift-gtk and run the Assistant once with default settings.

On the next pamac update, there should be a message about a BTRFS snapshot saved successfully.