[How To] Persistent Boot-Anywhere USB Drive

I am a Manjaro Xfce user that always wanted a persistent “live” version of the system on a USB drive that could be booted on ANY system.

I tried the Persistent USB Release using ALMA but ran into a few problems with it. For example it would block the WiFi adapter on my laptop.

So I tried a simpler DIY approach which appears to be working. At least, it works on all the 7 computers that I have access to.

I’ve set out the steps I took in case it is helpful for others. And to solicit any comments on the dangers and shortcomings as well as any suggested improvements.

I installed Manjaro Xfce to a clean USB drive in the normal manner. However, I did select manual partitioning like this:

   8 MB    unformatted              bios-grub flag
 512 MB    fat32         /boot/efi  boot flag
8192 MB    linuxswap     swap       swap flag
rest       ext4          /          root flag

Note the 8MB unformatted partition.

Once I booted up the fresh install and updated it I ran:

sudo grub-install --target i386-pc --debug /dev/sd(x)
sudo update-grub

This made the drive bootable on UEFI AND non-UEFI systems.

Next I used pacman to install “amd-ucode”. I’m not sure if this is essential but I installed it anyway.

Then I created the three files intel.conf, nvidia.conf and amd.conf in /etc/X11/mhwd.d/

Section "Device"
     Identifier "AMD"
     Driver "amdgpu"

Section "Device"
  Identifier  "Intel Graphics"
  Driver      "intel"

Section "Device"
    Identifier     "Device0"
    Driver         "nouveau"
    VendorName     "NVIDIA Corporation"
	Option "NoLogo" "1"

Next I created a custom service:

Create: /usr/lib/systemd/system/myboot.service
Description=LiveMedia Config Script



And enabled it with systemctl. The myboot service runs at startup, detects the video card in the system and calls mhwd-gpu accordingly:

if lspci -nn | grep -i '\[0300\].*amd'; then
  mhwd-gpu --setxorg /etc/X11/mhwd.d/amd.conf
  exit 0
if lspci -nn | grep -i '\[0300\].*intel'; then
  mhwd-gpu --setxorg /etc/X11/mhwd.d/intel.conf
  exit 0
if lspci -nn | grep -i '\[0300\].*nvidia'; then
  mhwd-gpu --setxorg /etc/X11/mhwd.d/nvidia.conf
  exit 0
mhwd-gpu --setxorg /etc/X11/mhwd.d/intel.conf

Finally a couple of my systems have 4K displays, I wanted to automate some rescaling of the desktop, so I added the following script which is run on login by the Xfce session manager:

if xrandr | grep \* | grep '[2-9][0-9][0-9][0-9]x' ; then
  xfconf-query -c xsettings -p /Gdk/WindowScalingFactor -s 2
  xfconf-query -c xsettings -p /Gtk/CursorThemeSize -t int -s 64
  xfconf-query -c xfwm4 -p /general/theme -t string -s "Numix HiDPI"
  export QT_SCALE_FACTOR=2
  xfconf-query -c xsettings -p /Gdk/WindowScalingFactor -s 1
  xfconf-query -c xsettings -p /Gtk/CursorThemeSize -t int -s 32
  xfconf-query -c xfwm4 -p /general/theme -t string -s "Piranha"
  export QT_SCALE_FACTOR=1
xfce4-panel -r

Comments and feedback very welcome.

1 Like

Nice implementation of selecting different GPU drivers

I created somthing similar a couple of years ago.