Recovery Extended Logical partition from MBR to GPT conversion
I had tried to convert my HDD from MBR to GPT, and like an idiot converted every partition separately not
knowing I only had to convert the whole disk at once. I had seen a few tutorials where people were using Parted to convert the MBR. Below is a printout of my partitions before the destruction: Code:
is a overview of each partiton was and usage: sda2 /, sda3 extended , & sda5 /home. Converting sda2 was no problem. I ran into my issues when I got to sda3. I had tried converting (dev/sda3 204.6G extended) from beginning to end (39067646s-650115071s) thinking this would include everything in the (dev/sda5 /home 86.8G logical) partition. What I am left with is 2 partitions. Partition sda2 is fine with no issues, sda3 looks to have absorbed sda5. I can no longer access these files from sda5. I know all my files are still there because I used photorec to dump sda3 to an external sdd, then dd'd a complete copy of sda3 to another hdd. All the files are still on the drive because when I used photorec for recovery, it dumped all files into whole bunch of directories incrementally named "recup_dir...", but for the least they are there. Somewhere in this process it seems as the partitions shifted a bit; Original sda2 / is now sda1 with everything intact. Original partition sda3 is now sda2. When running cfdisk on the sda2, I can see it shows as having a sub-partition of 86.8G which is exactly what my original /home partition was. It lists it as "Free space" however which confuses me a bit. Code:
cfdisk /dev/sda2 Also, taking a look with gdisk it shows as the MBR "protective", and GPT only "present". Not sure if this should like like this Code:
gdisk /dev/sda All in all, what Id like to do ideally, would be to just recover my /home partition with the same folder names and file structure. Once I have accomplished this I plan to format the whole drive and start fresh, it would be a huge loss to not be able to recover all my files. Any and all help would be greatly appreciated. Here is the exact commands I had used while converting: Code:
#COMMANDS USED Code:
#Before conversion |
You can try testdisk, it is designed to recover lost partitions and rebuild the MBR. Rebuilding the MBR would be your only hope.
Best to make an image of the drive, make the image read/write and run testdisk on it first to see what it can do. EDIT: Whatever the case, when it comes to recovering data, it is best to make an image of the drive, then make a copy of the image and try all kinds of things on it, if you feel you screwed it up, make another copy of the original image and keep playing. This way you don't screw up the drive and loose the data for good. |
Sounds like pretty good advice. Better would be to play with the backup you took before you started.
If it were me I'd have a go at losetup with an offset to get at the start of the (old) /home and simply try to mount that so it could be backed up properly. Then let testdisk see what it can find. |
Quote:
@ kasak730: See if you can mount the old /home with command below: Code:
mount -oloop,offset=20002635776 /dev/sda /mnt |
@Brains & @syg00
Sorry for the long response, my brother had passed and my priorities were sidetracked for a bit. You fellas are my heros! Ran cmd provided by Brains, then cd'd into /mnt, and lo and behold /home intact. I will be backing this up to another disk then restarting correctly. Again, thanks a lot! Although, I love to pick your brains to understand where you came up with "20002635776" for the offset number.... If you have time of course. Code:
mount -oloop,offset=20002635776 /dev/sda /mnt |
Real life has a habit of intruding - hope you're handling the important things ok.
As for this issue, simple arithmetic - your "original" listing showed /dev/sda5 starting at sector 39067648; each sector (for these purposes) is 512 bytes. The offset value is in bytes from the start of the device. Glad you got it sorted. |
Quote:
If you have a UEFI system, then it might be best to repartition and get the EFI system partition to a normal size of 200-300MB. But if you're not concerned about that, you can extract the old /home partition to an image file, then paste it into a new /dev/sda2 of same size. Then it's just a matter of editing /etc/fstab to include proper UUID, but it should work, extract the partition to an image with: Code:
dd if=/dev/sda of=/dev/otherdrive/partition.img skip=39067648 count=428955648 Then you would verify it's integrity by mounting it and checking the contents: Code:
mount -o loop /dev/otherdrive/partition.img /mnt Then paste the partition image into the new partition: Code:
dd if=/dev/otherdrive/partition.img of=/dev/sda2 bs=64K EDIT: Forgot to mention, you would have to change the ID of /dev/sda1, typically an EFI partition is hidden, it would need to be changed to 83 Linux, can be done with fdisk. |
Having a bit of an issue backing up the home to an external drive. First I had made a mistake while typing the dd command where I forgot to add the "/" between dev and sdd2 and got the error message below. I had an NTFS filesystem on the 1st partition which I cant see on a Windows based computer. It was 5:20 AM. I stopped using that hdd at once and swapped for another one I had handy until I can resolve first issue, Ill leave this NTFS drive be for the moment.
So, after I swapped the hdd I had tried formatting the first partition on this hdd before dd'ing. I allocated 500 GB to the first partition, and on the rest of the disk is a 2nd partition with some backups. I am still unable to dd with the same error. Code:
[root@ArcoLinux liveuser]# dd if=/dev/sda of=/devsdd2/partition.img skip=39067648 count=428955648 status=progress Then, I had tried mounting /dev/sdd1 to /mnt then dd'ing, but it and I got 22 GB written. This I believe was the size of my / partition. My original /home was 86-97 GB. I have tried to mount for confirmation to no avail. I have tried looking into other post about the "dd: failed to open '/dev/sdd1/partition.img': Not a directory" issue, but I havent found a solution as of yet. Any Ideas? Code:
Also, I forgot to mention; I had also tried writing the .img to the disk without any partition "of=/dev/sdd/part.img" resulting in the same outcome. |
Code:
Model: ATA ST500LT012-9WS14 (scsi) But for imaging sake, it's best to work with the reported numbers for now, after re-writing the partition image, you could run command: resize2fs /dev/sda2 even if mounted which would automatically fill the container (partition) then you'll know the size of the partition, then you can use Gparted to shrink it if desired when it's not mounted. Your last attempt was close: Code:
[root@ArcoLinux]# dd if=/dev/sda of=/mnt/yup/partition.img skip=39067648 count=42895548 Code:
dd if=/dev/sda of=/mnt/yup/partition.img skip=39067648 count=428955648 |
I cant believe I missed that ¨6¨, I have a feeling this is what my issue was. Either way, I have dd running now and I will post as to the outcome.
Update: Looks to have only written 33GB now. Code:
[root@ArcoLinux liveuser]# cd /mnt Im wondering if I should try mounting /home with the offset to /mnt/home then dding to the /mnt/yup/partition.img... Not sure if this will play out as I want... Before I do anything more, I just ran the command to mount sda with the same off set and I am getting errors: Code:
[root@ArcoLinux liveuser]# mkdir /mnt/home |
Hopefully you did the backup the first time you mounted it before playing with this?
Code:
[root@ArcoLinux mnt]# dd if=/dev/sda of=/mnt/yup/partition.img skip=39067648 count=426488955 status=progress Also, dd reported that the external drive's file system is read-only, so it can't write to it. Typically dd needs to be run as root or sudo, and if the external drive's file system is ext4, it's possible only root can write to it. Before running the dd command, try writing to it as root or sudo by simply creating an empty file with command: touch /mnt/yup/test.txt. This should produce a test.txt file which you should be able to see get created if you have a file browser open in that directory or with command: ls /mnt/yup Quote:
You shouldn't have issues writing to an NTFS drive as long as ntfs-3g is installed, no permission issues unless it's a OS partition which most distros won't allow a user to write to that type of partition. |
Yes, I had made 2 backups originally before I started playing with anything. Ill just do what you say and copy/paste it over. Typing on one computer from the screen of another with dyslexia doesnt help much lol. I did see that with dd stating the file system is read-only, but to my surprise it had written a 33GB .img to the drive. Im running dd now without the read-only warning. Ill post back as to the outcome. Thanks again for your help.
Code:
[root@ArcoLinux yup]# dd if=/dev/sda of=/mnt/yup/partition.img skip=39067648 count=428955648 status=progress dd'd out 220GB. Mounted it and everything looks good. Now I have the confirmed image Ill wipe my sda and start fresh then Ill dd the home image back as suggested to a new partition and update the fstab file. Hope this is all for now. Thank a lot for the support. |
All times are GMT -5. The time now is 02:08 AM. |