我设法在错误的磁盘上运行fdisk。 但是我能够保存terminal会话的日志。
事故发生前的Fdisk:
~$ sudo fdisk -l /dev/sda Disk /dev/sda: 320.1 GB, 320072933376 bytes 255 heads, 63 sectors/track, 38913 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x72fc82e8 Device Boot Start End Blocks Id System /dev/sda1 * 1 36473 292969341 8e Linux LVM /dev/sda2 36474 38913 19599300 b W95 FAT32
后来在日志中我发现:
$ sudo fdisk -u /dev/sda WARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c'). Command (m for help): p Disk /dev/sda: 320.1 GB, 320072933376 bytes 255 heads, 63 sectors/track, 38913 cylinders, total 625142448 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x72fc82e8 Device Boot Start End Blocks Id System /dev/sda1 64 550000000 274999968+ 83 Linux /dev/sda2 550000001 625142447 37571223+ 83 Linux Command (m for help): t Partition number (1-4): 1 Hex code (type L to list codes): 8e Changed system type of partition 1 to 8e (Linux LVM) Command (m for help): p Disk /dev/sda: 320.1 GB, 320072933376 bytes 255 heads, 63 sectors/track, 38913 cylinders, total 625142448 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x72fc82e8 Device Boot Start End Blocks Id System /dev/sda1 64 550000000 274999968+ 8e Linux LVM /dev/sda2 550000001 625142447 37571223+ 83 Linux Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16: Das Gerät oder die Ressource ist belegt. The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8) Syncing disks.
系统运行良好。 我分配了/ dev / sdb,正如我想的那样,最后在/ dev / sdb上运行kpartx。 我想这就是为什么在重新启动之前,sda上的卷performance正确。
我注意到这个错误,并试图恢复/ dev / sda上的分区表
但是我没有设法恢复原来的分区表。 为/ dev / sda1显示的块数始终为292969348,因此与原始值相比为+7。 我记得在分区sdb之前升级fdisk,也许是因为更新的版本?
不过我认为这个系统是安全的,因为我不介意fat32分区没有被使用。 重新启动后,lvmfind物理卷,但没有卷组。 我已经定义了一个只包含sda1的卷组和一些逻辑卷。
当前系统状态:
~# fdisk -c -l /dev/sda Disk /dev/sda: 320.1 GB, 320072933376 bytes 255 heads, 63 sectors/track, 38913 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x72fc82e8 Device Boot Start End Blocks Id System /dev/sda1 * 1 36473 292968348+ 8e Linux LVM /dev/sda2 36474 38913 19599300 b W95 FAT32 ~# pvdisplay "/dev/sda1" is a new physical volume of "279,40 GiB" --- NEW Physical volume --- PV Name /dev/sda1 VG Name PV Size 279,40 GiB Allocatable NO PE Size 0 Total PE 0 Free PE 0 Allocated PE 0 PV UUID ur3J4Y-cwvC-lji2-RPk0-39xb-ltzW-ogN4Sd ~# vgscan Reading all physical volumes. This may take a while... No volume groups found ~# pvck -v /dev/sda1 Scanning /dev/sda1 Found label on /dev/sda1, sector 1, type=LVM2 001 Found text metadata area: offset=4096, size=192512 Found LVM2 metadata record at offset=168448, size=28160, offset2=0 size2=0 Found LVM2 metadata record at offset=67584, size=100864, offset2=0 size2=0
为什么我不能用确切的块数来恢复原始分区表? 为什么lvm找不到任何卷组? 我现在有什么select? 多个lvm元数据可以解救吗? 我将如何使用它们?
你应该打破你的分区表的备份,并把它放回原处。 或者运行一个分区恢复工具(谷歌的第一个命中“恢复分区Linux”看起来很有趣)。 但是我会坚持使用分区表备份。
我不能保证所有的数据都会返回,但您可以尝试重新创buildLVM元数据。 无论如何,在HPUX上,这根本不会触及数据区域,但是您需要了解有关如何创buildLVM的信息。
同样,我已经在HP / UX LVM系统上使用了这种types的进程,并且可能会有效。
如果这是一个启动/启动磁盘,您可能需要重新grub您的磁盘。
但是如果你不想丢失任何数据,请务必在尝试我的build议之前备份磁盘。
从输出中恢复分区表是成功的关键。 请注意在原始和恢复分区表之间的上述terminal转储中的细微差别:尽pipe柱面值匹配,但实际的扇区计数不会。
最后检测并正确恢复了分区信息的testing盘提供了额外的帮助。 在恢复过程中,我发现备份中出现以下白点: