V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
tingfeng1
V2EX  ›  Linux

求助: lvreduce 把虚拟机搞坏了

  •  
  •   tingfeng1 · 7 天前 · 352 次点击

    担心代码数据丢失所以想备份一下虚拟机,发现没空间了,查到这篇文章可以压缩虚拟机磁盘空间: 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.
    ****************************************************************************
    
    
    第 1 条附言  ·  7 天前
    e ,我又没注意提示的消息,少敲了个 “+” 号,已经恢复了

    ```
    lvextend -L +80G /dev/pve/vm-101-disk-1
    Size of logical volume pve/vm-101-disk-1 changed from 256.00 GiB (65536 extents) to 336.00 GiB (86016 extents).
    Logical volume pve/vm-101-disk-1 successfully resized.
    ```
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   4612 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 05:35 · PVG 13:35 · LAX 21:35 · JFK 00:35
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.