Migrating From Manjaro to Arch

2022-02-06

Background: My Main Desktop

Those of you who have read my About page know I like to keep what computers I use up to date in there. Well my current Ryzen 9 3950x rig in there started out as my Ryzen 1800x rig back in 2017 as a windows box due to the C-State problems linux had with first gen Ryzen. Eventually I figured it out and swapped my desktop from Windows to Manjaro back in mid 2019.

As for why Manjaro? Well I’ve been using ArchLinux for years, ever since high school I’ve been tinkering with it and loving it since its a minimal base you can build up to whatever you need it to be, and all the configs are mostly blank upstream configs that need to be edited & tuned to what you need.

But when it came to my desktop I didn’t know what to pick since I wanted something more stable than ArchLinux. (Yes I know that’s not correct per-say, but at the time I was doing pacman -Sy NewPackagetoInstall and having to reboot due to said partial upgrades and thinking that’s the os being ‘unstable’. I don’t think that anymore, but it’s important to know so it’s easier to understand why I steered away from ArchLinux at the time.) I didn’t want to go with Ubuntu since upgrading between releases on desktop variants have always been stupid for me. At one point going between I want to say 13.10 and 14.04 the upgrade uninstalled a package integral to VLC (it was like vlc-data or something to that affect) and for the life of me I couldn’t get VLC to work after that or reinstall it since the package manager thought everything was okay.

Ubuntu has it’s place, I just didn’t like it’s upgrade process on Desktop back in the day is all, it’s probably fine now, but back then it was a wild ride on what would break between releases. you were better off backing up your home folder and wiping the root filesystem each time and installing fresh.

I did try Fedora Linux at the time too, but I was disappointed in it’s lack of software available in yum/dnf (Both official and unofficial repos such as RPMFusion). Don’t get me wrong most of what I need was there, but for some obscure stuff (Like the Ryzen C-State disabler) there was no official packaged way to install it beyond make build and make install.

I’m fine with that for out of the way installs, but it got to the point where I was going to need to install python libraries via pip, and I learned my lesson long ago with ubuntu that you don’t run pip as root unless you want a broken install down the road, and since the software I wanted to install was going to run as root, I nope-d out of that.

The package manager is there for a reason, and that is to manage packages and simplify installs, upgrades, downgrades, and uninstalls. So trying to side-step the package manager just to put files its going to trip up on later feels wrong.

Eventually I settled on Manjaro, mainly because to me at the time it seemed to be like ArchLinux, except more ‘stable’ since they hold packages back by about a month, Unlike Ubuntu or Fedora, most if not all 3rd party pacman packages for Arch/Manjaro are either in the repos already or can be built using the AUR, and back in my Cup of Linux days, Spatry maintained his own flavour of Manjaro called mCOLe (Manjaro: Cup of Linux Edition)

So I loaded up Manjaro Gnome on my desktop and ran with it.

Why migrate?

Well most of what I said above is how I felt about Manjaro back in 2019 when I first dipped my toes into it. It seemed like the perfect match.

However over time how I use my machine has changed considerably. For example the way I make Manjaro installs now is closer to the ArchLinux way where I boot up the ISO and use the terminal to cli the install using pacstrap the same way I would with ArchLinux.

That and the Gnome interface I loaded onto my laptop & desktop are no longer in use, I swapped from Gnome to KDE and have been using it for the last two years. However due to QT defaults setup by Gnome (I forget if this was an upstream thing or the Manjaro Team) but a number of my QT apps, specifically the KDE Plasma Desktop Settings program are stuck in a pseudo white theme where my main dark theme is a tiny strip on the bottom and the rest is white with some font-clashing that requires me to highlight white text to read it.

Although, that one is on me since the way to fix it is to reinstall, or potentially make a new user profile.

So for my desktop and my laptop who both have this problem, the fix is to install the Manjaro KDE edition the standard way instead of the architech/Arch way I would normally do.

That and I’m treating Manjaro like ArchLinux, and having stale packages is annoying since some apps I use regularly will tell me “Hey you should update to the latest version” like Calibre when I can’t.

So over the Christmas holidays of 2021-2022 I ran a test and swapped my laptop from Manjaro to Archlinux using a combination of Docker and btrfs subvolumes.

That has worked perfectly and my laptop hasn’t run into any of my older ArchLinux problems since I’m now following pacman best practices by doing a full system upgrade before I install new software and rebooting/restarting services as required after said updates.

Now that I’m going to do the same to my desktop, I thought it would be best that I document it, not only for other’s benefit, but to document it incase I need to do this again to the other Manjaro machines in my life.

DISCLAIMER! If you don’t want background details. Start here

This is personal documentation for a way to migrate from Manjaro to ArchLinux that works for me. I may leave details out about my setup since some of this is my personal setup and certain pieces are no-one elses business.

Also the way I do this migration has large inherent risks to it that can result in dataloss if your not careful
PLEASE BACKUP YOUR DATA!

And to CMA, this guide is provided “as is”, meaning no warranty of any kind is expressed or implied. So if reading this guide ends with you losing data because of a command you typed in and either misread or misunderstood, you can’t hold me liable for any claim, damages, or other liability.

TL;DR if you brick your PC or delete your important data, it’s your own fault and don’t email me for help.

Plan overview

My plan hinges on btrfs subvolumes and wiping away most/all system data. This is the reason why I’ve been saying to backup your data.

Most other guides for migrating Manjaro will recommend upgrading to the “unstable” branch, Removing certain Manjaro only packages, then swap pacman to the Arch repos, next doing a full system upgrade, finally fix up key data points such as /etc/lsb-release and the grub vendor variable.

While it’s certainly a fine way to migrate a healthy system, mine is about 3-4 years old and has problems such as the “KDE QT theme problems” mentioned earlier, and I know where my important data is for VM’s, Docker, and my Home folder in it’s entirety, everything else can be easily reinstalled and tweaked slightly to work again.

The overall plan is this:

  • Backup system to external HDD incase anything gets deleted that shouldn’t
  • Using pacman -Qqent and pacman -Qqem we can generate a list of all installed apps using pacman
  • Using docker or a VM and the same lists from the prior step we can trim down the list of Manjaro only packages.
  • Boot machine off of the latest ArchISO, moving the old btrfs subvolumes out of the way, regenerating the original names as blank volumes and installing a base system via pacstrap, restoring key data such as the /etc/fstab file, then rebooting
  • Once the machine is up on Arch, restore packages with pacman -S --needed - < pkglist.txt and edit configurations as needed.
  • Finally clear out the old btrfs subvolumes that contain Manjaro to cleanup

Step One: Backups

Since I’m using btrfs subvolumes, this is really easy using a perl script known as btrbk. This script uses btrfs’ native snapshot send/receive functions to copy snapshots to either a local btrfs filesystem or a remote one via SSH

It will be important that you format your backup filesystem to be btrfs (in my case a 4TB external HDD), or loopback mount a thin IMG file on it formatted as btrfs if you can’t clear it.

Have btrbk snapshot the important subvolumes, and have their backup target set to your backup drive. Finally let it run for however long it needs, better to wait for the backup to complete instead of jumping ahead and chancing data loss later.

Step Two: Export pacman package lists

pacman -Qqent > pkglist.txt
pacman -Qqem > aurlist.txt

Quick & simple, this exports your currently installed packages to a couple of txt files, these will be required to install most if not all of the required packages back onto your new ArchLinux box

Step Three: Cleaning up the package lists

cp ./pkglist.txt ./pkglist_original.txt

Best to keep a backup incase a bad edit occurs, or if you need to reference the original export later.

I would recommend getting an archlinux docker container running via docker run -v $(PWD):/arch --rm -it docker.io/library/archlinux:latest or an ArchISO in a VM.
With said VM/Container we are going to import the pkglist.txt file into pacman using the pacman -Sy --needed - < /arch/pkglist.txt command.

The reason being is that we are trying to eliminate packages only available either in Manjaro’s repos, or AUR packages Manjaro’s team has included in their repos.

With every pass you will get output from pacman saying error: target not found: yay for example, this is letting you know that Archlinux doesn’t have this package available in it’s repositories.

So edit your pkgfile.txt file, search for the offending line, and if you know you will need it, make a note of it to install from the AUR later, Otherwise if it’s manjaro-system or manjaro-release or the like, your probably good to just delete the line.

Keep trimming the list until pacman is finally happy with your list of installed programs and is asking you to confirm your package selection.

Once you have your text files with the packages you need, I would recommend moving them to a safe spot so they don’t get accidentally lost once your in the ArchLinux console.

Step Four: Installing Arch

Not much to say other than install a basic Arch Install, this isn’t a tutorial on how to install ArchLinux, go to the Installation Guide on the ArchWiki if you want a hand with that.

The only note I will make is just do a basic install, enough to get internet and console output, but afterwards we will fix it up once we import the pkgfile.txt

Step Five: Install all the packages

pacman -S --needed - < pkglist.txt is really all you need to get stuff started.

After that’s all done & loaded, go through and install/configure additional items such as the Graphics Card, Display Manager, Virtual Machine Management daemons, etc as you would on a normal ArchLinux install.

As for the aurpkg.txt file, you *might* be able to pipe it into yay the same way as the above pacman command, but I would just recommend going through the list manually and reinstalling the programs you need.

Finally do some cleanup on any leftover manjaro pieces, such as any old btrfs subvolumes, and you should be all good.