Have just wiped a partition on a running system.
I have, stupidly, just managed to wipe my home partition, which is stored on a software RAID5 (md0) of three disks, in gparted. Is there any way to recover from this, or do I have to reformat and put my data back?
I'm currently copying hidden config files etc across just in case but I wondered if there is a way to recover things? Yes, I know, I'm am idiot and should be more careful. |
How exactly did you "wioe" it?
testdisk can be very useful for recovering deleted partitions. |
Sorry, yes, I mean I deleted the partition in gparted, but the data is still there.. It's ext3 if that matters.
|
theoretically you may have a chance, because maybe only the partition entry had been deleted. Based on other partitions and disk geometry you may restore it and mount it again.
This is only an example: http://www.easeus.com/partition-recovery/ You may need to boot from a recovery disk containing the software. |
... and committed the change?
but not rebooted yet? Presumably you are on a live cd? (gparted shouldn't delete a mounted partition) Install testdisk and see if it will find / re-instate the deleted partition. note: I've never used it on raid and have no idea if it will work. |
Yes, comitted but not rebooted. Nope, not on a live CD, but gparted definately shows /devmd0 as unallocated.
Not sure how to use testdisk, but am trying it now. Any tips? |
type 'testdisk' then follow the prompts. :)
|
I take it the partition type is Intel (it was partitioned)?
I'm not sure what I'm supposed to expect. It said somethng about partition endblock not found, or similar, now I'm doing a quick search which seems to be searching the whole drive. |
As mentioned, testdisk will scan and repair disk partitions. If you deleted or altered the partitioning, but didn't format the new partitions, you only need to restore the partition table, which is just a table of numbers.
Before running I'd recommend using "fdisk -l -b512 /dev/sdb" and writing down or saving the results, so you have a backup of the partitions which are good. Could you give us an idea how many partitions were on /dev/sdb and which one got whacked? It is also possible to attach a loop device inside the disk, at an offset. E.G. the first partition probably starts at 2048*512 bytes. So it is possible to recover the partition table manually using losetup, file & df if testdisk doesn't succeed. |
I spent too much time on my last response and didn't see your last post.
What is the offset of the partition you found? If you run "sudo /sbin/losetup -fs /dev/sdb -o <offset>" you can attach a loop device to the beginning of the partion. Then mount the loop device. Using "sudo file -s /dev/loop#" you can check that there is a filesystem there. Then "df --block-size=512 /dev/loop#" can tell you how many blocks are in the filesystem, which also tells you where the partition ends, by adding the size to the start. |
There was only one partition and it's not listed with fdisk -l /dev/md0
testdisk is still looking and I think it will take some time... |
OK, now I'm confused. I decided to give up with testdisk because it wasn't finding anything and I have a backup so I rebooted.
Everything is fine: Code:
# cat /proc/mdstat Code:
fdisk -l /dev/md0 |
The drives making up the raid volume were reassembled, but you still need to restore the partition.
Since there was only one partition on the volume, that should make things easy. Simply repartition it with fdisk, select the ID (e.g. 83 for Linux). The filesystem should still be there if you didn't reformat. Alternately, attach a loop device. Then check for a filesystem. The partition probably starts at 2048. Although for older versions of linux (and XP) the first partition started at sector 63. Code:
#assume filesystem starts are block. Use 512 byte sectors to avoid rounding errors. |
Thanks, I'll have a look at that in the morning.
What I don't understand is why everything seems to be working fine, with /dev/md0 mounted on /home and no apparent ill effects after a reboot? If things are working why do I need to do anything else? I'm trying to work out what's going on here for future reference if nothing else. |
OK, the md0 device has a file system on it isn't a drive image.
Having used gparted on it confused me. |
All times are GMT -5. The time now is 10:36 AM. |