Wednesday, December 02, 2009

Recovering your data from clicfs (aka openSUSE Live USB stick)

Today I wanted to recover some of the data I had saved on my openSUSE 11.2 live USB stick, just to find out that it was not really trivial. It actually included reading the manpage of coolo's clicfs, so I'll write it down here to save others the hassle ;)

I assume the normal live USB stick layout (dd'ed the ISO which was treated with isohybrid to the stick, then added a second partition with fdisk, if I plug in the stick it turns up as /dev/sdb1 and /dev/sdb2) for the following.

First, create the mountpoints and mount the "normal" ISO image:
# mkdir /mnt/iso /mnt/root /mnt/clic
# mount /dev/sdb1 /mnt/iso -oro

You'll now find the clicfs container on the mounted ISO fs:
# hexdump -C /mnt/iso/openSUSE-kde-11.2-livecd-kde-read-only.i686-2.8.0 |head -n 1
00000000 43 4c 49 43 30 32 0b 00 00 00 66 73 64 61 74 61 |CLIC02....fsdata|

Second, mount the clicfs:
# clicfs -c /dev/sdb2 /mnt/iso/openSUSE-kde-11.2-livecd-kde-read-only.i686-2.8.0 /mnt/clic/
# ls -l /mnt/clic/
total 0
-rw-r--r-- 1 root root 3891789824 Jan 1 1970 fsdata.ext3

Third, just loop mount the fsdata.ext3 file:
# mount /mnt/clic/fsdata.ext3 /mnt/root/ -oloop

That's it. You can now access all data that you stored on your Live stick under /mnt/root.
If you only want to have the "original" contents of the Live system, without the stuff you saved, then just replace the "-c /dev/sdb2" with "-m 128" which will use a ramdisk for the "write" part of the filesystem instead of the second partition on the stick. (Don't just leave off the "-c ..." without adding "-m", this got me a hanging mount later when I was trying the loop mount. I was able to resolve it with a brave "umount -f /mnt/clic" and then "killall -9 clicfs" though).

To get rid of it, just unmount it in reverse order:
# umount /mnt/root
# umount /mnt/clicfs
# umount /mnt/iso

No comments:

Post a Comment