The Important Files: Part 7
All notes in this series:
Three years ago, I first set up my NAS using FreeNAS (see part 1). A few months later it was powered off, placed in a shipping container along with the rest of my household contents, as I moved across the world from the UK to Seattle. Now that I’ve been in Seattle for almost two years, I’ve finally got around to setting up my NAS again(!). These notes cover the process of getting it up and running, recovering from a dying USB stick, and bringing everything up-to-date.
An overview of this post is:
- Powered on NAS
- Unable to boot due to error message
- Determined error was due to USB stick used for FreeNAS OS dying
- Discovered that FreeNAS has become TrueNAS
- Used ddrescue to clone dying USB stick
- Resurrected NAS using cloned USB stick
- Decided to use SSD instead of USB stick to avoid same issue happening in future
- Ordered parts to fit extra SSD in NAS enclosure
- Installed FreeNAS on SSD
- Exported NAS config from USB stick
- Imported NAS config onto SSD
- Upgraded OS on SSD from FreeNAS to TrueNAS
- Verified backups still work
Powering on the NAS after two or more years gathering dust §
Powered on the NAS with a monitor connected. Was greeted with the following error:
The NAS was booting from a USB stick with FreeNAS installed. Some searching quickly indicated that the USB stick was most likely dying, causing this middleware error.
Further, I discovered that FreeNAS has become TrueNAS CORE. On my USB stick was installed FreeNAS 11.1. I decided to first fix the booting issue, sticking with FreeNAS 11.1, and only once that was fixed to upgrade to TrueNAS CORE 12.0.
Rescuing the USB stick §
Installing ddrescue §
dd
can be used to create a perfect copy of a disk. ddrescue
is the same idea, but designed to improve your chances of successfully copying a dying disk.
Note that there exists a dd_rescue
and ddrescue
, which serve the same purpose but are otherwise completely different! ddrescue
sounded preferable.
On my Debian laptop, the package for ddrescue
is gddrescue
(note the “g”):
Recovery overview §
I will use ddrescue
to copy the dying USB stick (aka source) onto a brand new, identical USB stick (aka destination).
Identifying the devices §
Before running ddrescue
, we must be certain which drive is source and which is destination. To do that, first we list all drives without either USB sticks connected:
Then we connect the destination USB drive:
The destination shows up as /dev/sdb
mounted to /media/sam/KINGSTON
.
We don’t want it to be mounted, because we want to ensure ddrescue is the only thing writing to it. Unmount it:
The destination USB drive is now unmounted.
Then we connect the source USB drive:
The source shows up as /dev/sdc
and does not automatically mount (presumably because my Debian laptop does not understand ZFS).
The ddrescue command §
The GNU ddrescue manual includes good examples of how to run the tool.
Following Section 10, Example 2 from the official documentation, we are going to run the following commands. Note that sudo
is required:
The flags are as follows:
-f
: Overwrite output device or partition (even if it exists).-n
: Skip the scraping phase.-d
: Use direct disk access for input file (skip any cache).-r3
: Exit after 3 retry passes (defaults to 0).
Actually running the ddrescue command §
Here goes:
(Started at 19:07)
After 1 hour (at 20:11)
Finish (at 20:50):
Second stage:
Instantaneous!
The destination USB stick is now an identical clone of the source, with no errors from the copying process.
Boot from cloned USB stick §
Inserted the cloned USB stick into the NAS and booted. No error this time! Was able to log in through the web UI.
Export NAS config §
Through the FreeNAS web UI, browsed to: System -> General, then clicked “Save Config” and ticked “Export Password Secret Seed” (to allow the config to be used with a new boot device).
Bought SSD (and related parts) §
Bought the following:
- 500GB SSD - Perhaps a little overkill, but I’d like this to last longer than the USB stick did!
- SATA cable - For connecting SSD to motherboard.
- 4-pin molex to SATA power cable - To power the SSD using the 4-pin molex. The server has no spare SATA power cables, but does have a spare 4-pin molex intended for an optical drive.
- 5.25" to 2.5" mounting kit - To mount the SSD in the optical drive bay.
Install SSD §
- Removed the cloned USB stick.
- Put mounting kit in optical drive bay. (I have no plans to install an optical drive).
- This mounting kit was not ideal for my optical drive. The kit assumes you can screw it in place from outside the enclosure, which I cannot. Ideally I could do with a kit that slides into the grooves intended for an optical drive. However, friction alone seems enough to hold it firmly in place!
- Attach SSD into mounting kit.
- Connect SSD SATA power to 4-pin molex using convertor.
- Connect SSD SATA to motherboard with SATA cable.
Install FreeNAS to SSD §
Follow official FreeNAS 11.1 installation guide to install FreeNAS 11.1 to SSD. (Disconnected the pool drives first just to be absolutely certain I install to the right drive, though the install prompt lets you choose the target drive).
Import NAS config into FreeNAS §
Through the FreeNAS web UI, browse to: System -> General, then “Upload Config”. Supply the config that was saved earlier.
Shut down FreeNAS. Reconnect pool drives. Power up FreeNAS.
At this point, the recovery procedure is complete: we have migrated the OS from a dying USB stick to an SSD!
Update from FreeNAS to TrueNAS §
In the FreeNAS web UI, went to: System -> Update. Switched train to TrueNAS and let the system automatically update.
Verify backups still work §
SSH into the NAS, then list all the jails:
The borg-jail
is not used. The fnbbu
(FreeNAS Box Backer-Upper) is the jail that performs the backups to rsync.net. It has not powered up automatically. Let’s start it up:
Now let’s log in to fnbbu
and check that the cron job for the back ups is still configured:
It’s been a while (a few years) since a backup actually took place, so let’s manually kick one off now:
70 minutes later, the backup finishes successfully. Viewing in rsync.net verifies that the backup has taken place. That was painless!