Linux Repair lost partition table

Source: Internet
Author: User

First simulate the broken fast partition table

DD If=/dev/zero OF=/DEV/VDB bs=512 count=1

Then use parted to try to fix
Parted/dev/vdb
GNU Parted 2.1
Using/dev/vdb
Welcome to GNU parted! Type ' help ' to view a list of commands.
(parted) Rescue
Error:/dev/vdb:unrecognised disk label

Guess it's msdos. (parted) Mklabel Msdos
and then rescue.

(parted) Rescue
Starting point? 0
End point? 10000
No information on the original partition table, only guess, no gain, try using the Gpart tool

Gpart/dev/vdb

Begin Scan ...
Possible Extended partition at offset (601MB)
Possible partition (Linux ext2), size (4518MB), offset (601MB)
END Scan.

Checking partitions ...
Partition (Linux ext2 filesystem): Primary
Ok.

guessed primary partition table:
Primary partition (1)
type:131 (0x83) (Linux ext2 filesystem)
SIZE:4518MB #s (9253376) s (1231839-10485214)
CHS: (1023/15/63)-(1023/15/63) d (1222/1/1)-(10401/15/62) R

Primary partition (2)
type:000 (0x00) (unused)
SIZE:0MB #s (0) s (0-0)
CHS: (0/0/0)-(0/0/0) d (0/0/0)-(0/0/0) R

Primary partition (3)
type:000 (0x00) (unused)
SIZE:0MB #s (0) s (0-0)
CHS: (0/0/0)-(0/0/0) d (0/0/0)-(0/0/0) R

Primary partition (4)
type:000 (0x00) (unused)
SIZE:0MB #s (0) s (0-0)
CHS: (0/0/0)-(0/0/0) d (0/0/0)-(0/0/0) R
A bit of harvest, so the result of the guess is written to disk
[Email protected] ~]# gpart-w/DEV/VDB/DEV/VDB

Begin Scan ... (Time is long)

1-absolute start Sector (0)
2-absolute sector count (0)
3-partition type (0) (unused)

Here will let you fill in three values, the first one, the second, how can I remember! Select the third, because remember that there is an expansion of the division, wrote the extended
disk/dev/vdb:5368 MB, 5368709120 bytes
Heads, Sectors/track, 10402 cylinders
Units = Cylinders of 1008 * 516096 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk identifier:0x000d0da8

Device Boot Start End Blocks Id System
/DEV/VDB1 1223 10402 4626688-up Linux
/DEV/VDB4 * 1 1 0 0 Empty

Results back to a partition, note vdb1, hanging up, found the data back, dizzy.

Online TestDisk, seemingly not recognized the virtual machine's hard disk, Halo

Finally, try fsck and see if it's okay.
The result is still not, sentenced him a reprieve, told everyone, backup is very important, do not hold a fluke heart clearance!

、——————————————————————————————————————————————————————————————————
Add, later found that in fact gpart very useful, not before, because the disk VDB no partition and data, and then I put vdb divided 4 districts, have data, execute gpart, quickly repaired
[Email protected] ~]# GPART/DEV/VDB

Begin Scan ...
Possible partition (Linux ext2), size (100MB), offset (0MB)
Possible partition (Linux ext2), size (200MB), offset (100MB)
Possible partition (Linux ext2), size (300MB), offset (300MB)
Possible Extended partition at offset (601MB)
Possible partition (Linux ext2), size (4518MB), offset (601MB)
END Scan.

Checking partitions ...
Partition (Linux ext2 filesystem): Primary
Partition (Linux ext2 filesystem): Primary
Partition (Linux ext2 filesystem): Primary
Partition (Linux ext2 filesystem): Primary
Ok.

guessed primary partition table:
Primary partition (1)
type:131 (0x83) (Linux ext2 filesystem)
SIZE:100MB #s (205568) s (63-205630)
CHS: (0/1/1)-(203/15/62) d (0/1/1)-(203/15/62) R

Primary partition (2)
type:131 (0x83) (Linux ext2 filesystem)
SIZE:200MB #s (409602) s (205632-615233)
CHS: (204/0/1)-(610/5/39) d (204/0/1)-(610/5/39) R

Primary partition (3)
type:131 (0x83) (Linux ext2 filesystem)
SIZE:300MB #s (615888) s (615888-1231775)
CHS: (611/0/1)-(1023/15/63) d (611/0/1)-(1221/15/63) R

Primary partition (4)
type:131 (0x83) (Linux ext2 filesystem)
SIZE:4518MB #s (9253376) s (1231839-10485214)
CHS: (1023/15/63)-(1023/15/63) d (1222/1/1)-(10401/15/62) R

[Email protected] ~]# gpart-w/DEV/VDB/DEV/VDB

Begin Scan ...
Possible partition (Linux ext2), size (100MB), offset (0MB)
Possible partition (Linux ext2), size (200MB), offset (100MB)
Possible partition (Linux ext2), size (300MB), offset (300MB)
Possible Extended partition at offset (601MB)
Possible partition (Linux ext2), size (4518MB), offset (601MB)
END Scan.

Checking partitions ...
Partition (Linux ext2 filesystem): Primary
Partition (Linux ext2 filesystem): Primary
Partition (Linux ext2 filesystem): Primary
Partition (Linux ext2 filesystem): Primary
Ok.

guessed primary partition table:
Primary partition (1)
type:131 (0x83) (Linux ext2 filesystem)
SIZE:100MB #s (205568) s (63-205630)
CHS: (0/1/1)-(203/15/62) d (0/1/1)-(203/15/62) R

Primary partition (2)
type:131 (0x83) (Linux ext2 filesystem)
SIZE:200MB #s (409602) s (205632-615233)
CHS: (204/0/1)-(610/5/39) d (204/0/1)-(610/5/39) R

Primary partition (3)
type:131 (0x83) (Linux ext2 filesystem)
SIZE:300MB #s (615888) s (615888-1231775)
CHS: (611/0/1)-(1023/15/63) d (611/0/1)-(1221/15/63) R

Primary partition (4)
type:131 (0x83) (Linux ext2 filesystem)
SIZE:4518MB #s (9253376) s (1231839-10485214)
CHS: (1023/15/63)-(1023/15/63) d (1222/1/1)-(10401/15/62) R

Edit This table (y,n): n

Activate which partition (1..4, Q to quit): 1234
Activate which partition (1..4, Q to quit): 1..4
Write this partition table (y,n): Y



    • Warning:partition table written, you should reboot now.

[Email protected] ~]# fdisk-l

disk/dev/vda:32.2 GB, 32212254720 bytes
Heads, Sectors/track, 62415 cylinders
Units = Cylinders of 1008 * 516096 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk IDENTIFIER:0X00014CD2

Device Boot Start End Blocks Id System
/DEV/VDA1 * 3 1018 512000 Linux
Partition 1 does not end on cylinder boundary.
/dev/vda2 1018 5179 2097152, Linux Swap/solaris
Partition 2 does not end on cylinder boundary.
/dev/vda3 5179 62416 28847104-up Linux
Partition 3 does not end on cylinder boundary.

disk/dev/vdb:5368 MB, 5368709120 bytes
Heads, Sectors/track, 10402 cylinders
Units = Cylinders of 1008 * 516096 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk identifier:0x00000000

Device Boot Start End Blocks Id System
/DEV/VDB1 * 1 204 102784 Linux
Partition 1 does not end on cylinder boundary.
/DEV/VDB2 205 611 204801-up Linux
Partition 2 does not end on cylinder boundary.
/DEV/VDB3 612 1222 307944-up Linux
/DEV/VDB4 1223 10402 4626688-up Linux
[Email protected] ~]# MOUNT/DEV/VDB
VDB vdb1 vdb2 vdb3 VDB4
[Email protected] ~]# mount/dev/vdb1/mnt/1/
[Email protected] ~]# mount/dev/vdb2/mnt/2/
[Email protected] ~]# mount/dev/vdb3/mnt/3/
[Email protected] ~]# mount/dev/vdb5/mnt/4/
Mount:you must specify the filesystem type
[Email protected] ~]# mount/dev/vdb4/mnt/4/
[Email protected] ~]# df-h
Filesystem Size used Avail use% mounted on
/dev/vda3 27G 6.0G 20G 24%/
Tmpfs 4.0G 72K 4.0G 1%/DEV/SHM
/DEV/VDA1 477M 33M 419M 8%/boot
/DEV/VDB1 98M 5.6M 87M 7%/MNT/1
/DEV/VDB2 194M 5.6M 179M 4%/MNT/2
/DEV/VDB3 292M 11M 267M 4%/MNT/3
/DEV/VDB4 4.4G 137M 4.0G 4%/MNT/4


Linux Repair lost partition table

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.