担心代码数据丢失所以想备份一下虚拟机,发现没空间了,查到这篇文章可以压缩虚拟机磁盘空间: https://mayanpeng.cn/archives/158.html 没注意提示, 敲了一个 yes, 这下数据真的丢了
# lvreduce -L -80G /dev/pve/vm-101-disk-1
WARNING: Reducing active and open logical volume to 176.00 GiB.
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce pve/vm-101-disk-1? [y/n]: y
Size of logical volume pve/vm-101-disk-1 changed from 256.00 GiB (65536 extents) to 176.00 GiB (45056 extents).
Logical volume pve/vm-101-disk-1 successfully resized.
# resize2fs /dev/pve/vm-101-disk-1
resize2fs: Bad magic number in super-block while trying to open /dev/pve/vm-101-disk-1
Couldn't find valid filesystem superblock.
此时感觉不对,想自救一下
# lvextend -L 80G /dev/pve/vm-101-disk-1
New size given (20480 extents) not larger than existing size (45056 extents)
# fsck /dev/pve/vm-101-disk-1
fsck from util-linux 2.38.1
e2fsck 1.47.0 (5-Feb-2023)
ext2fs_open2: Bad magic number in super-block
fsck.ext2: Superblock invalid, trying backup blocks...
fsck.ext2: Bad magic number in super-block while trying to open /dev/mapper/pve-vm--101--disk--1
......, and you might try running e2fsck with an alternate superblock:
e2fsck -b 8193 <device>
or
e2fsck -b 32768 <device>
Found a PMBR partition table in /dev/mapper/pve-vm--101--disk--1
结果都不行,这时在 V2EX 看到大佬发的链接,还是没法启动
vgcfgrestore --force -f pve_00050-1698916710.vg pve
目前是这个状态, 不知道还有没有机会
GPT fdisk (gdisk) version 1.0.9
Warning! Disk size is smaller than the main header indicates! Loading
secondary header from the last sector of the disk! You should use 'v' to
verify disk integrity, and perhaps options on the experts' menu to repair
the disk.
Caution: invalid backup GPT header, but valid main header; regenerating
backup header from main header.
Warning! One or more CRCs don't match. You should repair the disk!
Main header: OK
Backup header: ERROR
Main partition table: OK
Backup partition table: ERROR
Partition table scan:
MBR: protective
BSD: not present
APM: not present
GPT: damaged
****************************************************************************
Caution: Found protective or hybrid MBR and corrupt GPT. Using GPT, but disk
verification and recovery are STRONGLY recommended.
****************************************************************************
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.