在加密分区缩小失败后如何修复 LVM PV 大小

在加密分区缩小失败后如何修复 LVM PV 大小

我今天显然搞砸了。

我必须调整加密根分区的大小,以便为 Windows 双启动腾出空间。我按照以下指示进行操作拱门维基因为即使我使用的是 debian,它似乎也符合我的需求。在某些时候我不得不使用,pvmove因为缩小根分区后,可用空间位于我的根分区和交换分区之间。我认为一切都很顺利,但我显然在某些时候弄乱了我的扇区/字节/东西计算。现在机器是从实时 debian USB 密钥启动的,这是我认为相关 shell 命令的输出。

user@debian:~$ sudo lsblk
NAME          MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
loop0           7:0    0   2.3G  1 loop  /usr/lib/live/mount/rootfs/filesystem.s
sda             8:0    0   3.6T  0 disk  
sdb             8:16   1 114.6G  0 disk  
sdc             8:32   1  28.9G  0 disk  
├─sdc1          8:33   1   2.5G  0 part  /usr/lib/live/mount/medium
└─sdc2          8:34   1   2.6M  0 part  
nvme0n1       259:0    0   3.6T  0 disk  
├─nvme0n1p1   259:1    0   512M  0 part  
├─nvme0n1p2   259:2    0   488M  0 part  
└─nvme0n1p3   259:3    0   3.5T  0 part  
  └─cryptdisk 253:0    0   3.5T  0 crypt  # this is where the "fun" happens

所以,我成功地为 Windows 释放了 100G,到目前为止看起来还不错。但...

user@debian:~$ sudo cryptsetup luksOpen /dev/nvme0n1p3 cryptdisk
Enter passphrase for /dev/nvme0n1p3: 
user@debian:~$ sudo vgchange -a y licorne-vg
  WARNING: Device /dev/mapper/cryptdisk has size of 7602233344 sectors which is smaller than corresponding PV size of 7602235392 sectors. Was device resized?
  WARNING: One or more devices used as PVs in VG licorne-vg have changed sizes.
  device-mapper: reload ioctl on  (253:2) failed: Invalid argument
  1 logical volume(s) in volume group "licorne-vg" now active
user@debian:~$ sudo lsblk
NAME                   MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
loop0                    7:0    0   2.3G  1 loop  /usr/lib/live/mount/rootfs/filesystem.squashfs
sda                      8:0    0   3.6T  0 disk  
sdb                      8:16   1 114.6G  0 disk  
sdc                      8:32   1  28.9G  0 disk  
├─sdc1                   8:33   1   2.5G  0 part  /usr/lib/live/mount/medium
└─sdc2                   8:34   1   2.6M  0 part  
nvme0n1                259:0    0   3.6T  0 disk  
├─nvme0n1p1            259:1    0   512M  0 part  
├─nvme0n1p2            259:2    0   488M  0 part  
└─nvme0n1p3            259:3    0   3.5T  0 part  
  └─cryptdisk          253:0    0   3.5T  0 crypt 
    └─licorne--vg-root 253:1    0   3.5T  0 lvm   

恐慌加剧......253:2是我的加密交换分区,它是这个加密磁盘的一部分。

user@debian:~$ sudo pvdisplay /dev/mapper/cryptdisk
  WARNING: Device /dev/mapper/cryptdisk has size of 7602233344 sectors which is smaller than corresponding PV size of 7602235392 sectors. Was device resized?
  WARNING: One or more devices used as PVs in VG licorne-vg have changed sizes.
  --- Physical volume ---
  PV Name               /dev/mapper/cryptdisk
  VG Name               licorne-vg
  PV Size               3.54 TiB / not usable 0   
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              928007
  Free PE               0
  Allocated PE          928007
  PV UUID               x5fLwB-qnhM-qc4x-y28f-FdDM-pFGI-9I6SYh
   
user@debian:~$ sudo lvs
  WARNING: Device /dev/mapper/cryptdisk has size of 7602233344 sectors which is smaller than corresponding PV size of 7602235392 sectors. Was device resized?
  WARNING: One or more devices used as PVs in VG licorne-vg have changed sizes.
  LV     VG         Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root   licorne-vg -wi-a-----  <3.54t                                                    
  swap_1 licorne-vg -wi------- 976.00m

user@debian:~$ sudo dmesg | grep device-mapper
[   99.652244] device-mapper: uevent: version 1.0.3
[   99.652317] device-mapper: ioctl: 4.43.0-ioctl (2020-10-01) initialised: [email protected]
[  100.537014] device-mapper: table: 253:2: dm-0 too small for target: start=7600236544, len=1998848, dev_size=7602233344
[  100.537016] device-mapper: core: Cannot calculate initial queue limits
[  100.537027] device-mapper: ioctl: unable to set up device queue for new table.
[ 1451.395603] device-mapper: table: 253:2: dm-0 too small for target: start=7600236544, len=1998848, dev_size=7602233344
[ 1451.395605] device-mapper: core: Cannot calculate initial queue limits
[ 1451.395956] device-mapper: ioctl: unable to set up device queue for new table.
                                                    

此 LVM/LUKS 设置是否处于可恢复状态?我思考licorne--vg-root只有交换分区受到影响,这没关系,对吧?我应该按照什么步骤来修复问题?感谢您的帮助。

答案1

感谢@frostchutz,我通过使用parted将 /dev/nvme0n1p3 扩展 2048 个扇区解决了这个问题。

相关内容