Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Easy all,

I have a hard drive with 4 partitions setup. boot/swap/root/home

I recently installed windows onto the / partition as i needed it, and now that i'm switching back to linux it's showing /dev/sda4 (the home partition) as being swap space.

blkid shows TYPE="swap" and parted /dev/sda print shows the file system as being linux-swap instead of ext3 like it should be. Obviously I want to keep the data on here, so I'm wondering what could have happened and is there an easy way to retrieve the data from this partition?

Thanks for any help you can provide.

share|improve this question

2 Answers 2

up vote 1 down vote accepted

Without knowing exactly what you did when you installed Windows and then re-installed Linux, I can't imagine why the partition type might have changed (unless the Linux installer ended up using the partition as swap through being misinstructed), but I suspect you might be breaking out the backups.

One thing you can try doing is just mounting the partition as ext3 somewhere:

mount -o ro -t ext3 /dev/sda4 /mnt

If you're really lucky and blkid is being stupid (or whatever corruption is present isn't that huge) it might mount and you can copy the data off. If it complains about a dud superblock, then an fsck with -b set to one of 8193, 16384 or 32768 might recover it. An fsck is probably worth doing anyway before mounting, although in pathological cases it can make more of a mess than would have otherwise occured.

share|improve this answer
    
ugh, (a) that should be with -o ro and (b) running fsck first is a good idea. –  derobert Sep 5 '09 at 6:25
    
@derobert: (a) is a good idea, but I dealt with (b) in my answer. –  womble Sep 5 '09 at 7:09

If you have been running your machine for a while, chances are that the data in your swap partition is mostly gone and not easily recovered. If you have your backups, just get on with life and restore it from the backups. Otherwise, if your data is important, you may need to engage the services of a recovery company.

If you have not actually used that partition yet, you could try mounting it from a live CD and also resetting the partition type to linux type to see if that helps.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.