Home Arch Linux How To Remove Everything Except The Base System In Arch Linux

How To Remove Everything Except The Base System In Arch Linux

Simplify Your Arch Linux Setup: Removing Everything But the Base

By sk
Published: Updated: 18.8K views

I use Oracle VirtualBox to test various Linux distributions. Recently, I wanted to experiment with different desktop environments on my Arch Linux, such as Deepin, MATE, LXDE, and XFCE. However, some environments were already installed, and I didn't have enough space to install others or any additional applications. More importantly, I wanted a fresh Arch Linux system. Reinstalling Arch from scratch seemed too tedious and time-consuming, which I wanted to avoid. While searching for a simpler solution, I discovered that it's possible to remove everything except the base system in Arch Linux.

This approach allows us to avoid reinstalling the entire Arch Linux OS each time. Instead, we can quickly remove all packages except for the base system and then install other applications or desktop environments on top of the base system as often as needed.

This method saves a significant amount of time since we don't need to install Arch Linux from scratch each time. If you're curious about how to do this, you're on the right track. Keep reading.

Remove Everything Except the Base System in Arch Linux

As usual, I strongly recommend you to backup of your important data and system configuration files in your Arch Linux system. Check the following link to know how to backup everything using rsync:

What we are going to do is mark all packages as dependencies, and then mark the base system as explicitly installed packages and finally remove the orphaned packages.

First, let us mark all packages as dependencies using command:

$ sudo pacman -D --asdeps $(pacman -Qe)

This command marks all explicitly installed packages as dependencies. This manipulation changes how packages are considered by the package manager, potentially making them eligible for automatic removal when the packages that depend on them are removed.

Here,

  • The asdeps option tells the pacman to install packages non-explicitly. In other words, we fake their install reason to be installed as a dependency.

Next, mark the base system as explicitly installed. Also, mention anything else you don't want to remove in the below command:

$ sudo pacman -S --asexplicit --needed base

Here,

  • The asexplicit option tells the pacman to install packages explicitly. In other words, we fake their install reason to be explicitly installed. This is useful if you want to mark a package as explicitly installed so it will not be removed by the --recursive remove operation.

Finally, remove the orphaned packages and their dependencies using the following command:

$ sudo pacman -Rsunc $(pacman -Qtdq)

Please make sure that you have mentioned all packages that you don't want to remove by pacman command.

Now, remove any unwanted configuration files and other files in your $HOME directory. You can also reset all customization and tweaks you made in your system, including the pinned applications in the Dock, desktop panel applets, desktop indicators, your system fonts, GTK themes, Icon themes, monitor resolution, keyboard shortcuts, window button placement, menu and launcher behaviour etc., as described in the following article.

Now, you have a fresh Arch Linux system. Go ahead and start installing any packages you want to test and explore.

For more details, refer pacman manual pages.

$ man pacman

Suggested Read:


And, that's all for now. Hope this helps. More good stuffs to come. Stay tuned!

You May Also Like

8 comments

Matt May 16, 2020 - 11:40 am

So this will leave everything in your home directory untouched, correct? It only removes the packages?

Reply
sk May 16, 2020 - 11:47 am

Yes, it will only delete the packages. However, it is recommended to backup important data just in case.

Reply
erickmufath July 7, 2020 - 7:15 am

After this, how to install package again? Like Network Manager and sudo?

Reply
sk July 7, 2020 - 11:04 am

It doesn’t remove pacman. So just the packages using pacman as usual.

Reply
erickmufath July 8, 2020 - 3:52 pm

My laptop using wifi connection, and what happen? I reinstall arch linux.. hmm, this tutorial really doesn’t remove pacman or this is my mistake? Tomorrow i try pacman -Syu and this say : command not found..

Reply
AstroCAR May 22, 2021 - 6:22 am

How are packages installed by yay or others treated through this?

Reply
sk May 22, 2021 - 12:06 pm

I deleted the Arch Linux setup, so I can’t confirm this at the moment. As stated in the article, it will keep only the base. Everything else will be treated as orphaned packages and deleted. Test this guide in a VM and verify yourself.

Reply
Tristan April 8, 2024 - 9:16 pm

well idk if i did something wrong but it deleted pacman lmao

Reply

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More