Method 2
The earlier method was a bit lengthy and needs proper planning and implementation. Now, let’s discuss about using “parted” tool to recover corrupted or deleted partition table details. This method is rather easy and straight farword which doesn’t need so many steps to be performed as we did earlier.
The “parted” tool is a powerful disk utility which can do many functions such as recovery of partition data, resize etc., and also the default utility being used if disk size is greater than 2.2TB. Another powerful feature of “parted” is that it is GPT aware.
Let's replicate the issue: Destroy partition table of ‘/dev/sdb’.
Again, we'd use "dd" command to destroy the partition table details of device "/dev/sdb" now and later recover it using "parted" tool.
Again, we'd use "dd" command to destroy the partition table details of device "/dev/sdb" now and later recover it using "parted" tool.
Let's recover partition table
Step 1: Restore partition table using “parted”
Now, let’s restore the available partition table details using “parted” command. We’d need to run “parted” command with “rescue” and need to define starting and ending points. If a partition is found then ‘parted’ tool would ask for confirmation to add it. Before running ‘rescue’ operation it is necessary to initialize the label as “msdos” as shown here:
Let’s run ‘rescue 0% 100%’ (need to specify beginning and end points) command to restore first partition as shown:
Yes, it is has restored the missing first partition now. Now, let’s run the ‘rescue’ again and this time we know that our starting point should be “633MB” and ending point should be “100%” as we don’t know the end:
Again, the ‘parted’ tool recovered second partition table successfully. As we are not sure if there any further partitions, let’s run ‘rescue’ again and check. There was no further partition details found as shown:
Exit the “parted” command and verify if data can be recovered now.
Step 2: Mount & verify recovered partitions
Let’s check if recovered partitions are shown in “fdisk” command now.
There seems to be some misalignment as reported by fdisk, since this was created by ‘parted’ tool. So, to correct this, delete and re-create using “fdisk” with correct size:
Let’s mount ‘/dev/sdb1’ on ‘/data1’ and check if data is available.
Yes, we got the data back from ‘/dev/sdb1’. Now, let’s try to mount ‘/dev/sdb2’ and verify. In this case it would fail since it is physical volume which needs to be restored using “vgcfgrestore” as we did before. So, let’s run it and verify:
That’s it, we got our data back successfully!
NOTE: In case of XFS file system, the command "xfs_info <mount-point>" could be used to get the file system meta data details such as "Block size", "Block count" etc.,
There are many other open-source tools available such as "testdisk" which could also be used to recover deleted partition details easily.
NOTE: In case of XFS file system, the command "xfs_info <mount-point>" could be used to get the file system meta data details such as "Block size", "Block count" etc.,
There are many other open-source tools available such as "testdisk" which could also be used to recover deleted partition details easily.
1 comment:
Hey, Wow all the posts are very informative for the people who visit this site. Good work! We also have a Website. Please feel free to visit our site. Thank you for sharing.Well written article pmp training near me | pmp training courses online | project management courses in chennai |pmp training class in chennai | pmp training fee
Post a Comment