Why you want a persistent MX Linux install on a USB drive
For a while now, I’ve wanted the ability to sit down in front of any computer in the house and have access to everything I prefer to have on my personal workstation. This project was to create a persistent Linux install on a USB drive that I can boot from on any (x86) PC that has everything pre-installed and configured for my preferred desktop.
So, why?
Originally I thought of doing this just as a fun project. Then this last weekend, the PSU died in my NAS.
I’ve mentioned that we are a low income household, so dropping $50 on a new PSU is out of the question at the moment. I think I can pick one up in March. But, this would leave me without a NAS until then, which is unacceptable. To fix the problem, I pulled the PSU out of my desktop, which fixed my main problem while leaving me without a desktop PC.
This brought me back to the persistent USB install. In times like this, I’d love to have a portable desktop I could plug into any PC in the house and get to my desktop. Losing my desktop was the perfect opportunity to try out a persistent install.
My Linux desktop anywhere projects
I’ve tried other options in the past and all work well. However, since I setup a persistent USB install, I like it much better than the other options.
I’ve tried running a VM on my homelab and then configuring it with a Sunshine server. The performance is remarkable for streaming the full desktop. But, it requires I install Moonlight on the client PC. For the most part, this is fine. But, I want to leave no trace. I don’t want to install anything or leave files around after I’m done.
I’ve also tried running a Guacamole server that then points to a VM or a low-powered PC. For me, this was a better option because it only requires the browser on the client PC. I can navigate to my domain, login, and get a full desktop. The problem was it only works on my LAN. I don’t want to open my Guacamole instance to the internet. If that’s the case, then I’d have to install a VPN on the client PC. Using Guacamole also leaves files and browser history around on the client PC and, like I said above, I want to leave no trace.
The most recent version I’ve been using is to make everything a web app. I made sure everything I use has a web app and I can access it from any web browser. But, this is the same problem as Guacamole. I leave info in the browser and I need a VPN to get back to my LAN if I’m out of the house.
All of these reasons are why I wanted a USB persistent install. Once configured, all I have to do is reboot the PC and choose the USB drive at boot. Then, the persistent install has all my apps, everything configured, and Tailscale setup so I can get back to my LAN from anywhere. Plus, it has the most important files locally and I don’t have to have the internet if it is not available.
Why MX Linux
MX makes setting up persistence easy, that’s why. AntiX could work here, too, since it is based on MX Linux. I decided against AntiX just because the distro is… Weird. Just not my thing.
But MX makes setting this up a breeze and has built-in tooling for doing this exact setup.
How-to | Setting up persistence
I chose to do this with two USB devices. I have (A) an SSD running Ventoy with a dozen or so ISO’s that includes MX Linux 23.5 with XFCE, which is the version I’m using for this instance. Then I have (B) a m.2 external enclosure with a 256GB SSD that I will clone the live CD to, encrypt the installation, and configure for persistence. This will be the drive that will have the permanent install.
This is the way I did it. However, it is possible to do this with just one USB drive.
Getting it running is fairly simple.
Download and start the live ISO
You do this however you want. I use Ventoy. You can write the ISO to a drive using Rufus, Etcher, or just dd it.
Boot into the live ISO and start the system. Once you are to the desktop, now is the time to plug in the second USB drive that will have the persistence install (for me, its the m.2 SSD).
To clone and encrypt the installation, I used the built-in tool provided by MX Linux. From the whisker menu find MX Tools:

In MX Tools, select “Live USB Maker”:

In the live USB maker, we need to select which USB device to clone the system to, check the box to clone the live running system, and leave in full-featured mode. I chose to also encrypt the installation since I’ll be carrying this drive with me. I want to make sure that if I lose the drive, no one else has access to my files.

Once it is complete, now we can reboot and remove the USB drive with the live ISO (A) and leave our cloned drive (B) connected.
Boot from the cloned system (B) (for me, the m.2 SSD) and in GRUB is where you will setup the persistence.
From GRUB, select “Advanced Options”:

On the next screen, choose “Persistence option”:

There are lots of options for persistence and I’ll leave it up to you what is best. For me, I chose “persist_static” because I want the rootfs and homefs to stay on the USB drive and not load them into RAM. Using a m.2 SSD over USB 3.2 is fast. Its so fast it feels like its a native install. However, I encourage you to read about the other options and choose what is right for you.

Now we need to back back one menu to the “Advanced options” and choose “Save options”:

And choose “grubsave Save options (Live USB only)” -> GRUB menu".

Finally we can go back to the main menu and boot into MX Linux and will have persistence. As it boots, it will detect that persistence has been selected and will walk you through setting up encryption and the partition sizes. After entering my encryption password, I chose this for the partitions:
- 30 GB
rootfs - 200 GB
homefs - 2 GB
swap
When you get to the desktop, reboot the system, check in GRUB that all the persistence options have been selected. In one round of my testing I had to select them a second time. But, the other 4 times it worked fine.
At last it is setup and you can install and configure away!
- - - - -
Did you like this post? Give it an upvote by clicking on the arrows below! Sending me an upvote is like you and I giving each other a high five.
🙏 😎
Thank you for reading! If you would like to comment on this post you can start a conversation on the Fediverse. Message me on Mastodon at @cinimodev@masto.ctms.me. Or, you may email me at blog.discourse904@8alias.com. This is an intentionally masked email address that will be forwarded to the correct inbox.If you enjoy the random stuff I write here, post to Mastodon, or watch on YouTube, and are feeling generous, I am open to tips of Ko-fi.
This area are my notes for setting up the various apps and services I like to have on my desktop. Some things are straightforward. For example, running binaries, installing flatpaks, and browsing the web work out of the box. Some more advanced services require additional steps using MX Linux.
Installing and using Docker
I first tried installing with the Docker script, but it fails because MX doesn’t have systemd. This also makes it so I can’t remove Docker as it never ran and can’t be “stopped”.
The solution is to move /var/lib/dpkg/info/docker-ce.prerm to /var/lib/dpkg/info/docker-ce.prerm_ORIG (keeping the file just in case) which is the pre-remove script check to see if Docker is running. Changing this makes it so the pre-remove script isn’t checked.
Install and run Docker
We cannot use the script from Docker because of no systemd. I have lots of links that got me here, this is the starting point - MX Linux & Docker. The note about cgroup-mount here. And installing elogind here.
Get Docker repository key:
wget -O docker.gpg https://download.docker.com/linux/debian/gpg
Check public-key and add to apt trusted keyring:
gpg --keyid-format 0xlong docker.gpg 2>/dev/null | grep -sq 0x8D81803C0EBFCD88 && sudo apt-key add docker.gpg
Add Docker repository to apt’s sources.list:
echo "deb [arch=amd64] https://download.docker.com/linux/debian $CODENAME stable" | sudo tee /etc/apt/sources.list.d/docker.list
Be sure to change $CODENAME to whatever version of Debian your install is based on. For my current build its bookworm.
MX Linux also needs a few extra packages:
sudo apt install cgroupfs-mount elogind libpam-elogind
Now we can install Docker:
sudo apt install docker-ce docker-compose-plugin
Add my user to the Docker group:
sudo usermod -aG docker demo
Start the Docker engine:
sudo service docker start
Then reboot.
Running Tailscale
Another systemd issue. Tailscale can be installed, but it won’t start. These are the steps to fix it so it will run as a daemon with SysVint.
First, we need to make a init script:
sudo nano /etc/init.d/tailscaled
And then add this:
#!/bin/sh
### BEGIN INIT INFO
# Provides: tailscale
# Required-Start: $local_fs $all $network
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: Tailscale daemon
# Description: Runs the tailscale daemon.
### END INIT INFO
# Source function library.
. /lib/lsb/init-functions
PIDFILE=/var/run/tailscale.pid
LOGFILE=/var/log/tailscale.log
TAILSCALED=/usr/sbin/tailscaled
fail_unless_root() {
if [ "$(id -u)" != '0' ]; then
log_failure_msg "must be run as root"
exit 1
fi
}
case "$1" in
start)
fail_unless_root
$TAILSCALED --cleanup
start-stop-daemon --start --background --no-close \
--exec $TAILSCALED \
--pidfile "$PIDFILE" \
--make-pidfile \
-- \
--state=/var/lib/tailscale/tailscaled.state \
--socket=/run/tailscale/tailscaled.sock >> $LOGFILE 2>&1
status=$?
log_end_msg $status
;;
stop)
fail_unless_root
start-stop-daemon --stop --pidfile "$PIDFILE" \
--remove-pidfile --retry 10
status=$?
log_end_msg $status
;;
status)
status_of_proc -p "$PIDFILE" "$TAILSCALED" "tailscaled"
;;
*)
echo "Usage: $0 {start|stop|status}"
exit 1 ;;
esac
Save and then make executable.
sudo chmod +x /etc/init.d/tailscaled
Then, enable and start the service with:
sudo update-rc.d tailscaled defaults
sudo service tailscaled start
Now we can run sudo tailscale up, login, and use.
- - - - -
Did you like this post? Give it an upvote by clicking on the arrows below! Sending me an upvote is like you and I giving each other a high five.
🙏 😎
Thank you for reading! If you would like to comment on this post you can start a conversation on the Fediverse. Message me on Mastodon at @cinimodev@masto.ctms.me. Or, you may email me at blog.discourse904@8alias.com. This is an intentionally masked email address that will be forwarded to the correct inbox.If you enjoy the random stuff I write here, post to Mastodon, or watch on YouTube, and are feeling generous, I am open to tips of Ko-fi.