I have several RAID5 NAS devices at home that are built upon the excellent FreeNAS. One of the catches to using FreeNAS is that you must dedicate an entire drive to the operating system. This means if you have say 3 1.5TB drives, you have to allocate (and therefore lose) 1.5TB of disk space to host a couple of hundred meg of operating system. That’s obviously crazy and so the alternative is to simply boot off of USB. I’ve been running this way for years and it’s been fantastic. I got to thinking recently though – what happens if my USB key that I’m booting from fails? I manually periodically backup the configuration so I can restore that but that only works once I’ve gone through all the trouble of rebuilding a new FreeNAS installation. Wouldn’t it be easier if I could just clone the USB key and be done with it?
In my quest to do just this I discovered an excellent free piece of software called ImageUSB from Passmark. The software performed bit for bit duplication of a USB drive. It’s primary use case appears to be for mass duplication of USB drives (say to hand out at trade shows) but it has one feature in particular we want to take advantage of and that is the ability to save an image of a USB drive to a file. Here’s how:
- Download ImageUSB from http://www.osforensics.com/tools/write-usb-images.html
- Notably, this software does not require installation and it’s a single standalone executable (yeah!)
- Make sure the USB key you wish to copy is already inserted into your machine and run the application
- In this case, you see that I have an 8GB USB Key with an Unknown File System. This is because the key contains a FreeBSD bootable image
- Select the USB drive, select Create from UFD (USB Flash Drive) and select an output file. Then press Create Image
- That’s it. Congratulations you now have a backup of your FreeNAS USB Boot Drive (or WinPE image or anything else)
To complete a restore, simply insert a new USB key, launch the application and choose Write to UFD, select the file you made above and press Write to UFD. It’s beautiful in its simplicity.
seemed like a great idea. For some reason i cannot get the imageusb software to see the usb. I tried it on two separate machines, and multiple usb ports. did you have to do anything specific to get your machine to see the usb drive?
I don’t recall doing anything unusual. It’s worth noting that I used an 8GB USB key that was already formatted FAT32. It’s possible that your key may be formatted NTFS or some other format that the imageUSB software doesn’t understand. You may also be using a large key (>32GB) that your operating system (or a mix of the imageUSB software running on your OS) doesn’t understand. I’d try using the windows “diskpart” command to “clean” the USB drive first and then try relaunching the software. Be careful though! If you run the clean operation on the wrong drive, you will be very, very unhappy! Good luck!
Your solution looks interesting and i also want to backup my FreeNAS USB in-case one fails, i can replace it with another.
But in your solution, i see that i can only use the software on Windows and i would have to remove the USB from currently running system. Is there any other live option you have looked at?
I’m afraid I’m not aware of any means of making a backup of a FreeNAS key while it is running. A few ideas to come to mind. First and foremost, my understanding is that the entire OS is loaded into memory on boot and the key shouldn’t be required unless any configuration chnages are made. So in theory you should be able to just pull out the key, make a backup and stick it back in and the FreeNAS instance shouldn’t be any the wiser. But I have not tested this and so I’d recommend experimenting with a virtual machine first if possible. If this is not an option, you can do the next best thing and simply make a new FreeNAS key and then take a backup of your configuration and copy it onto the key. Then if you need to restore, you’d boot off off the new key and import the new configuration. But really, I think the best option is to schedule an outage window and get a copy of your existing production key. That’s my 2 cents anyway. Good luck!
If this works as advertised, it would be the best of all worlds. But I have to ask, have you tested a restored USB stick in your Freenas server to confirm this method works as expected?
Hi Ralph. Yes I have completed multiple end to end restores to new USB keys and it works exactly as expected.
FreeNAS will continue running being none the wiser if you pull the USB stick out. I just completed copying my original boot stick while I left my FreeNAS running, was able to access files on it without incident and my VMs all seem to be as happy as can be. My only concern is I just realized my original USB drive was 16GB and the one I purchased to replace it is only 8GB not sure it’ll work but I am about to find out.
I stand corrected, took about 20 minutes but it did finally loose connectivity all around………
considering that win7 does not recognize the usb format thus it will not even mount the drive it is impossible to complete this task because this plugin will not detect any drive presence. I am using an 8gig usb stick.
I’m not sure what you mean by the task being impossible. Windows cannot read the FreeBSD file system, this is true. But it doesn’t need to. What the freeware tool mentioned does is makea bit for bit clone of the original disk. It doesn’t know or what what those bits are for. If your computer is not seeing the USB drive at all, that would suggest that the issue is somewhere else. With the USB drive connected, if you open disk management (start/run/diskmgmt.msc), do you see the 8GB drive? It may have an unknown file system which is fine. But if you don’t see it at all, that would suggest an issue with either the drive or the computer.
What Andre is saying is true. Windows won’t mount the USB stick so there is no drive letter to select ( at least with FreeNas 9.3 that has GRUB in it).
Under Linux or FreeBSD the dd application can be used.
Ahh, I see what was meant now. Yes this process will not make the USB key readable by Windows — but that doesn’t mean the process doesn’t work. Think of it this way:
1) Insert USB key with Freenas Image on it
2) Use Tool to make .IMG file of USB Key
3) Copy .IMG file to USB drive using tool
4) Try to read the usb drive. It will FAIL and ask if you want to format. Ignore this, the process was successful.
5) You know this by inserting the new USB drive into your FreeNAS box and watch it boot successfully
My gosh Robbie you don’t see.
1) Insert USB key with Freenas Image on it
2) Use Tool to make .IMG file of USB Key
#2 is impossible since Windows doesn’t even see the drive.
Have you had a look in disk management? it might be the usb stick is using the same letter as another drive or at least you might get a more information to why you are not seeing it?
Just trying out now, could see freenas USB fine, will see how I get on with the rest, Thanks Robbie
Worked!!! thanks Robbie
Only one issue I had was once swapping for the copy once it had booted up trying to access the freenas I got an error: ‘freenas is not accessible you might not have permission to use this network resource’
Turn out to be a straight forward fix,
just restart computers on the network.
Thanks very much for sharing info.
I’m glad I run into your page, it worked out perfectly! Thanks!!!
there is an option (think 11) on command line on freenas to backup over the network. Havent tested but this could be done while nas is up
The problem with using the built-in backup option is that it requires an SSH connection to another server to store the backup, and does a backup of the FreeNAS configuration and (optionally) the data on the NAS. If your USB boot drive fails, you have to reinstall FreeNAS to the new USB boot drive, then do a restore from your SSH location. However, if you did not originally back up the data to the SSH server when you backed up the config info, then when you do a restore, the process will apparently restore your ZFS NAS configuration with NO DATA. It says so in the documentation.
Cloning the original USB boot drive is the better way to go, and I’ll give these instructions a try.
I was able to get this to work with an 8g stick, but when I used it on a 16g stick, ImageUSB created a file larger than the drive and would not put the image on an identical drive. I get the error Image is larger than target.