Recovering (Old & New) FreeNAS Configs from the Boot Media

Recently, I botched my FreeNAS configuration and wanted a more recent copy than I had backed up. FreeNAS actually keeps a long history of config backups on the boot media and it's very easy to extract these, without access to the web UI. You can create a FreeBSD VM and mount the partition on the boot media containing the configs, or boot FreeBSD directly on the FreeNAS box and do the work directly on the console (so boot media, flash drive to copy the config data to, and FreeBSD live media). I chose to do the latter, and here's a rough outline of what's involved:

1. Mount the configs slice from the boot media

Configurations are stored on slice 4 of the boot media. So if your boot media is a USB flash drive at da1, this would be da1s4 and you can mount this slice in read-only mode to /mnt/configs/ with the following commands:

mkdir /mnt/configs
mount -o ro /dev/da1s4 /mnt/configs

2. Mount a secondary USB

On another computer, format a USB flash drive as FAT32 - here are guides for MacOS and for Windows.

Once this is done, plug it into your FreeNAS box. Assuming your live media is a USB drive (da0), and the FreeNAS USB is da1, the flash drive you've just attached is likely da2. Mount it with the command:
mount -v -t msdosfs /dev/da2s1 /mnt/seconddrive

3. Copy the database

Once mounted, take a look at the contents of the folder:
ls /mnt/configs

Find the folder with the name of the update you're looking for (likely the most recent update) - in my case, this was FreeNAS-11.1-U5 (8e2a858a1).

Then, you can either copy a specific configuration out of the folder or just copy off the whole thing. I just copied the whole thing:
cp -a "/mnt/configs/FreeNAS-11.1-U5 (8e2a858a1)" /mnt/seconddrive/

Then, all you need to do is umount /mnt/seconddrive and you're done!

Show Comments