recovering data from damaged Linux partition

I'm running Windows XP, with an Ubuntu partition that I added. A few days ago, Ubuntu stopped booting. Trying to boot into Ubuntu just takes me into a Grub menu.

When I try to navigate through the command line to c:\ubuntu\disks, I get the message that "c:\ubuntu\disks is corrupt and unreadable. Please run the Chkdsk utility." I can navigate to c:\ anc c:\ubuntu\ through the command line, though when I try to open the C drive in My Computer, I get an error: "Windows cannot find 'RECYCLER\S-7-1-97-100014951-[etc]'.

I don't have a Windows disk or another hard drive, so I've just been trying unsuccessfully to run Chkdsk from the same c drive that's damaged.

When I try to run Chkdsk, I get the error: "The type of the file system is NTFS. Cannot lock current drive. Chkdsk cannot run because the volume is in use by another process. Would you like to schedule this volume to be checked the next time the system restarts? (Y/N)"

When I say Yes and restart, I get the white-letters-on-blue-screen message: "The type of the filesystem is RAW. CHKDSK is not available for RAW drives."

I found a site for Zero Assumption Recovery (ZAR) software, which seems to be able to recover data in cases like this, but I'm wondering if there are free alternatives or any other ideas for fixing the partition or recovering data.

I was getting that error in My Computer before I installed Ubuntu, a few months ago. So it seems to have slowly eaten into the Linux partition. I could try installing Ubuntu again, but there are a few files on that installation I'd like to recover.


Your main problem here is your Wubi filesystem is inaccessible due to NTFS corruption on your windows filesystem. You need a windows installation CD to run chkdsk from. There is no safe way around this. However, if that's not possible, there may be something you can try - but it may make things worse, so if at all possible, obtain a windows install CD from a friend in preference to this.

Boot from an ubuntu CD. When it's up, attach an external hard drive and open a terminal.

If your external hard drive is significantly larger than your internal hard drive, do a full backup first. This will take a long time:

sudo dd if=/dev/[your hard disk device] of=/media/[name of external hard drive]/backup.disk bs=131072

Then:

sudo mkdir /mnt/host
sudo ntfs-3g -o recover /dev/[your windows filesystem device] /mnt/host
cp /mnt/host/ubuntu/disks/root.disk /media/[name of external hard drive]/root.disk
e2fsck -v -f -C0 /media/[name of external hard drive]/root.disk
sudo mkdir /mnt/ubunturoot
sudo mount /media/[name of external hard drive]/root.disk /mnt/ubunturoot -o loop,ro

[your hard disk device] will likely be either sda or hda. [your windows filesystem device] will likely be the hard disk device with 1 at the end; if it isn't, add the contents of /proc/partitions to your question and comment on this answer.

If all goes well, you will have access to your files at /mnt/ubunturoot. If things go wonky, you may lose everything on your hard drive forever. If this happens and you made a backup, you can restore it by flipping the order of if= and of= in the backup command, but at that point you really will need to run chkdsk off an install disk.


Use a Live CD (from Linux) to access your files

Rescue your data. For those of you with no Linux experience, Knoppix will look odd and scary, but it isn't. You'll notice hard drive icons on your desktop. Click on one to browse its contents: your Windows files. To copy your important documents, open up your USB drive (click on the icon) and simply drag and drop them onto it.

When I first tried this, I got a message saying I didn't have permission to write files onto the USB drive.

alt text

If you have that problem, change the permissions by right-clicking on the USB drive, and choosing "Change read/write mode" as shown.

alt text

Then, you can simply drag and drop files from your hard drive to your USB drive, as shown.

alt text

Once you've got all your files onto your USB drive, you can shut down, reset your boot order to where it should be, and go rebuild your PC knowing that you've got your data safe and sound.

A Linux boot CD or DVD like Knoppix is also an awesome way for the curious to muck around in Linux without having to install it. Just pop in the CD, reset your boot order and go.