Click for text version
Magnus Wedberg / home

Recover your iSCSI data from a broken Readynas (LIO versions)

The (potential) problem
The Netgear Readynas can be used as an iSCSI target. It can be very nice to turn your NAS into a SAN and get your own native file system on your NAS. However, what to do if you lose your iSCSI configuration info and don't know how to restore it? How to get to the real data?

Learning how it works
The Readynas (at least x86 models) use LIO as their iSCSI daemon of choice. This lovely little piece of code basically stores the data as a raw disk image in a huge file the size of your iSCSI target -- partition info, file system with meta data, actual data and all. The location of this data file is
/<volume>/.iscsi/<targetname>~<LUN number>
In my case, for this example (solely done for amusement and curiosity issues), the file was
This file contains everything we really want. So we should be able to mount the file directly, if we can find a nice mount-raw-disk-image-as-file-system utility. First, use WinSCP to copy the LUN file you want to a local hard drive (of course, Enable Root SSH Access must first be installed).

The Swedish connection
I quickly found this quite beautiful program called OSFMount. This is based on the ImDisk utility made by fellow Swede Olof Lagerkvist. So, use either utility (I used OSFMount) to mount the image as a drive letter. OSFMount even identified the partition inside the image file for me. After mounting, you have the original file system inside the iSCSI container file as a drive letter and you can recover your files. And that is how you do it!

Super bonus boss level (encrypted)
If you want to recover a Truecrypt-encrypted volume (meaning the whole partition is encrypted) from a LIO iSCSI LUN file, you can begin with the method above. However, you won't be able to mount the partition in Truecrypt, as Truecrypt won't even see the "fake disk" device created by OSFMount and thus can't mount it. It cannot mount the iSCSI file either, as that file contains lots of metadata except the actual encrypted blob. Bummer! However, you can easily circumvent this issue. After mounting the image (mount it read only so you don't do something stupid), make a disk image of the entire partition with your fav image tool (I used Roadkil's excellent utility) and save this image somewhere, for example as an "" file. This file will then behave as a perfectly normal Truecrypt file, and mount as usual.

photos articles services about