Lvm
拙劣的加密分區縮小後如何修復 LVM PV 大小
我今天顯然搞砸了。
我必須調整加密根分區的大小,以便為 Windows 雙啟動騰出空間。我遵循了 arch wiki 的說明,因為即使我使用的是 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
是我的加密交換分區,它是這個 cryptdisk 的一部分。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: dm-devel@redhat.com [ 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
交換分區受到影響,這沒關係,對吧?我應該在這裡按照哪些步驟來解決問題?謝謝你的幫助。
感謝@frostchutz,我通過
parted
將 /dev/nvme0n1p3 擴展 2048 個扇區來解決這個問題。