已经很晚了,我凭借自己的无限智慧,不小心在错误的 SSH 会话中输入了一个命令,导致我的一台服务器崩溃。
核爆前
root@host ~ # fdisk -l
Disk /dev/nvme0n1: 953.9 GiB, 1024209543168 bytes, 2000409264 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 /dev/nvme1n1: 477 GiB, 512110190592 bytes, 1000215216 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
Disklabel type: dos
Disk identifier: 0xce4852fe
Device Boot Start End Sectors Size Id Type
/dev/nvme1n1p1 2048 1050623 1048576 512M 83 Linux
/dev/nvme1n1p2 1050624 1000213167 999162544 476.4G 8e Linux LVM
Disk /dev/nvme2n1: 477 GiB, 512110190592 bytes, 1000215216 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 /dev/mapper/vg0-swap: 100 GiB, 107374182400 bytes, 209715200 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 /dev/mapper/vg0-root: 1.8 TiB, 1940507328512 bytes, 3790053376 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
我不应该做的命令
fdisk -u /dev/nvme1n1p2
我选择了选项
n
p
1
t
8e
p
w
核爆之后
root@host ~ # fdisk -l /dev/nvme1n1p2
Disk /dev/nvme1n1p2: 476.4 GiB, 511571222528 bytes, 999162544 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
Disklabel type: dos
Disk identifier: 0xd4c9e29b
Device Boot Start End Sectors Size Id Type
/dev/nvme1n1p2p1 2048 999162543 999160496 476.4G 8e Linux LVM
root@rescue ~ # pvs
WARNING: Device for PV FbVZOZ-zxwZ-S32P-3L6U-BzkT-fkJ2-UmTDMz not found or rejected by a filter.
PV VG Fmt Attr PSize PFree
/dev/nvme0n1 vg0 lvm2 a-- 953.87g 0
/dev/nvme2n1 vg0 lvm2 a-- 476.94g 0
[unknown] vg0 lvm2 a-m 476.43g 0
服务器将无法再启动,我目前处于救援系统中。
我如何将此驱动器重新添加到 LVM?其上的数据现在丢失了吗?
答案1
好的,我做了更多的搜索,并做了以下事情来解决我的问题,并且我的所有数据都恢复了(据我所知)。
在我的救援系统上我做了:
pvcreate --uuid "FbVZOZ-zxwZ-S32P-3L6U-BzkT-fkJ2-UmTDMz" --restorefile /etc/lvm/archive/vg0_00000-741612506.vg /dev/nvme1n1p2
然后重新启动