I backed up and zero outed mbr and kept back up on same disk
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I backed up and zero outed mbr and kept back up on same disk
I took backup of mbr by
Code:
dd if=/dev/sda of=mbr-backup bs=512 count=1
then zero outed it
Code:
dd if=/dev/zero of=/dev/sda bs = 512 count=1
Problem here is i forgot to copy the the backup in pendrive.So i want to detect my partition (ext4) on which the mbr-backup is present so that i can restore it.
I tried testDisk:
It detects partition table type as EFI GPT
when i analyse it shows the archlinux partition but does not list the files saying .. Can't open filesystem. Filesystem seems damaged.
Your file system is gone dude, you did a data dump to the drive. Your best option here is to do a fixmbr from a windows recovery disc to rebuild a new MBR.
Since the OP only zeroed out the MBR the file-system is untouched. The fun thing is that Testdisk should be able to recover the disk, since you have made a backup copy of the MBR. Did you make a deep scan with Testdisk?
I see where I went wrong here, I completely overlooked the byte size and count arguments. Without those two arguments then I would be correct as the entire /dev/sda disk would have been overwritten but only the first 512byte block wouldve been over outputted to by the dd command here.
Again, sorry to the OP not sure why I didnt see that the first time through, been a long day heh
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195
Rep:
Isn't it possible to just create a partition starting at the beginning of the disk with a length which is approximately the same as it was? 99 chances out of 100 you get the beginning of the partition right and you can mount the file system. Of course it would produce errors when checking the fs, but maybe you are able to get the mbr image file.
Should be possible, if you can figure out if the partition should begin at sector 63 (partitioned by older Windows versions and older versions of Linux) or sector 2048. And of course assuming that the partition with the MBR copy on it was the first partition in the disk.
I tried testDisk:
It detects partition table type as EFI GPT
This likely means all the old presumptions about partition location are invalid.
I'm mildly surprised the OP could actually zap the dummy MBR that gpt uses for compatibility. "dd" is kinda stupid that way - it does what its told to do.
If testdisk won't find your files, you might have to resort to a scraper like photorec or foremost. Ugly, very ugly.
If the disk was, at some time in the past, partitioned with GPT, then there would be a backup GPT at the very end of the disk. If you've zeroed out the MBR and its primary partition table, testdisk is going to see that old backup GPT and think that was how the disk was last partitioned.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.