Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Persistent home directory

Featured Replies

Good evening!
I'd like to not only request this as a feature, but explain how one could implement this on their own!

Basically, the idea is that all user customization done via configuration files located in "/root" are lost on each boot.
I know this is intentional, but there's an "easy" way to implement this with clever failsafe mechanics.
I also know that one can work around this by adding a couple of lines to /boot/config/go, and storing the configuration files on the flash drive. This isn't as desirable as Fat32 doesn't properly handle Linux permissions, and can require other manual edits to the go file down the road.


Enter OverlayFS (a feature built into the Linux kernel for eons)

 

First we create the container for our data. I use the truncate command as it is safe and "quick" (note: we are writing over USB so this step will take time no matter which option we use)

truncate -s 4000M /boot/config/root.persist

 


I chose to go with 4000M as it is close to the Fat32 ceiling of "4gb" (note: if you specify 4G you will receive an error)
 

 

Next we format that image, and set up some important directories within it:

mkfs.ext4 /boot/config/root.persist
mkdir /tmp/overlay
mount /boot/config/root.persist /tmp/overlay
mkdir /tmp/overlay/upper
mkdir /tmp/overlay/workdir


 

Finally the special sauce that overlays the image we created on top of the normal unraid /root/ directory:

mount -t overlay -o lowerdir=/root,upperdir=/tmp/overlay/upper,workdir=/tmp/overlay/workdir none /root


 

Anything written to /root/ after this command is run will actually be writting to /tmp/overlay/upperdir, and permanently stored there. The lowerdir will never be modified in this situation as it isn't addressable since we are placing the overlay on top of lowerdir.

 

And to make it persistent, we add this block to /boot/config/go:

if [ -f /boot/config/root.persist ]; then
        mkdir /tmp/overlay
        mount /boot/config/root.persist /tmp/overlay
        mount -t overlay -o lowerdir=/root,upperdir=/tmp/overlay/upper,workdir=/tmp/overlay/workdir none /root
fi


 

A couple of notes:

The if statement above makes sure that we don't try doing anything if there isn't a persistent image for the root folder. It's kind of redundant (the first and second mount commands will just fail and regurgitate errors if the file isn't there) but I prefer a clean console log.
If the image becomes corrupt, or unusable you can safely discard it this way.

Safe mode shouldn't use /boot/config/go so if anything goes wrong safe mode will undo any of the changes contained in the image. Meaning you can boot into safe mode, manually mount the image, and undo whatever you did in upperdir and be back up and running. I'm not sure what you could do to cause those sorts of things.

This also allows for:
Persistent bash history (forget that command you ran before you rebooted? No more.)
Persistent config file storage (tmux preferences, terminal colors, and htop profiles? Oh my.)
Persistent KNOWN_HOSTS and AUTHORIZED_KEYS for ssh.
Anything you would normally want a home directory to be useful for in LinuxLand.

 

 

Edited by Xaero
Fixed two typos

Archived

This topic is now archived and is closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.