如何安装/恢复我的加密逻辑卷?

如何安装/恢复我的加密逻辑卷?

我在第一个回复的末尾进行了一些编辑。

不幸的是,我在运行 debian10 的旧 LVM 安装中遇到了一些问题。

我已经安装了 Debian 11 和 Debian 10。在这样做时,我的 Debian 10 LVM 似乎已损坏(我无法再从它启动),而且我现在不知道如何安装它。 Debian 10 是使用安装程序安装的。它是加密安装的,位于跨两个驱动器的 LVM 内。在启动 initramfs 时,我必须输入密码才能解密 lvm。

我的目标是将 NVME 驱动器(存储 Debian 10 和 lvm 的位置)中的一些数据保存到新连接的 SATA 驱动器(我的新 Debian 11 安装在该驱动器上运行)。

我的主要问题是:如何从 NVME 挂载逻辑卷(等和主目录)?

我已经阅读了一些建议,但这让我越来越困惑,我不想在事情变得更糟之前在数据驱动器上犯更多错误。

一个非常简单的解决方案似乎是https://superuser.com/questions/116617/how-to-mount-an-lvm-volume但我不知道现在是否可以在这里使用它,以及它是否会以某种方式损坏底层卷/卷组。

另一个提示来自这里您可以在不访问 /etc/lvm/ 的情况下恢复 lvm 元数据吗?使用sudo strings /dev/nvme0n1p6 | less,但输出没有帮助。它只显示 lvm 是 luks 加密的:

LABELONE
LVM2 001s1TKbLcSK8egOQIexp0yoIYg8jHSpbwC
 LVM2 x[5A%r0N*>
sha256
Jz?73404056-2fb5-4d7f-b1eb-8cff2273a211
{"keyslots":{"0":{"type":"luks2","key_size":64,"af":{"type":"luks1","stripes":4000,"hash":"sha512"},"area":{"type":"raw","offset":"32768","size":"258048","encryption":"aes-xts-plain64","key_size":64},"kdf":{"type":"argon2i","time":9,"memory":1048576,"cpus":4,"salt":
OUTPUT Truncated

如果您需要任何进一步的信息,请在评论中告诉我。

感谢你们对我的帮助。

pvscan 
  WARNING: Couldn't find device with uuid ovqLHE-HeCP-MabL-UYaZ-zKGk-dSeM-G0HP0I.
  WARNING: Couldn't find device with uuid RxI6g8-Fp87-j7O4-N055-arL3-0l1E-CIIvo2.
  WARNING: VG lvm-crypt is missing PV ovqLHE-HeCP-MabL-UYaZ-zKGk-dSeM-G0HP0I (last written to /dev/mapper/nvme0n1p8_crypt).
  WARNING: VG lvm-crypt is missing PV RxI6g8-Fp87-j7O4-N055-arL3-0l1E-CIIvo2 (last written to /dev/mapper/nvme0n1p6_crypt).
  PV [unknown]                VG lvm-crypt       lvm2 [86,50 GiB / 0    free]
  PV [unknown]                VG lvm-crypt       lvm2 [400,60 GiB / 0    free]
  PV /dev/mapper/sda1-crypt   VG lvm-crypt       lvm2 [931,49 GiB / <397,07 GiB free]
  PV /dev/nvme0n1p6                              lvm2 [400,62 GiB]
  PV /dev/nvme0n1p9                              lvm2 [<86,52 GiB]
  Total: 5 [1,86 TiB] / in use: 3 [<1,39 TiB] / in no VG: 2 [<487,14 GiB]

pvdisplay 
  WARNING: Couldn't find device with uuid ovqLHE-HeCP-MabL-UYaZ-zKGk-dSeM-G0HP0I.
  WARNING: Couldn't find device with uuid RxI6g8-Fp87-j7O4-N055-arL3-0l1E-CIIvo2.
  WARNING: VG lvm-crypt is missing PV ovqLHE-HeCP-MabL-UYaZ-zKGk-dSeM-G0HP0I (last written to /dev/mapper/nvme0n1p8_crypt).
  WARNING: VG lvm-crypt is missing PV RxI6g8-Fp87-j7O4-N055-arL3-0l1E-CIIvo2 (last written to /dev/mapper/nvme0n1p6_crypt).
  --- Physical volume ---
  PV Name               [unknown]
  VG Name               lvm-crypt
  PV Size               86,50 GiB / not usable 2,00 MiB
  Allocatable           yes (but full)
  PE Size               4,00 MiB
  Total PE              22144
  Free PE               0
  Allocated PE          22144
  PV UUID               ovqLHE-HeCP-MabL-UYaZ-zKGk-dSeM-G0HP0I
   
  --- Physical volume ---
  PV Name               [unknown]
  VG Name               lvm-crypt
  PV Size               <400,61 GiB / not usable 4,00 MiB
  Allocatable           yes (but full)
  PE Size               4,00 MiB
  Total PE              102554
  Free PE               0
  Allocated PE          102554
  PV UUID               RxI6g8-Fp87-j7O4-N055-arL3-0l1E-CIIvo2
   
  --- Physical volume ---
  PV Name               /dev/mapper/sda1-crypt
  VG Name               lvm-crypt
  PV Size               <931,50 GiB / not usable 4,00 MiB
  Allocatable           yes 
  PE Size               4,00 MiB
  Total PE              238462
  Free PE               101649
  Allocated PE          136813
  PV UUID               s4UhPf-B5u1-d73L-DKcy-FR93-KvMa-kNrQJ6
   
  "/dev/nvme0n1p6" is a new physical volume of "400,62 GiB"
  --- NEW Physical volume ---
  PV Name               /dev/nvme0n1p6
  VG Name               
  PV Size               400,62 GiB
  Allocatable           NO
  PE Size               0   
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               s1TKbL-cSK8-egOQ-Iexp-0yoI-Yg8j-HSpbwC
   
  "/dev/nvme0n1p9" is a new physical volume of "<86,52 GiB"
  --- NEW Physical volume ---
  PV Name               /dev/nvme0n1p9
  VG Name               
  PV Size               <86,52 GiB
  Allocatable           NO
  PE Size               0   
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               8Lk9H1-Tveo-JCko-nfgd-EDrL-KJVq-cA01lR

lvmdiskscan 
  /dev/nvme0n1                                          [     931,51 GiB] 
  /dev/mapper/sdd5-crypt                                [    <840,49 GiB] 
  /dev/nvme0n1p1                                        [     450,00 MiB] 
  /dev/sda1                                             [     931,51 GiB] 
  /dev/mapper/sdd6-crypt                                [     498,03 GiB] 
  /dev/nvme0n1p2                                        [     100,00 MiB] 
  /dev/mapper/sdc1-crypt                                [    <447,11 GiB] 
  /dev/nvme0n1p3                                        [      16,00 MiB] 
  /dev/mapper/sda1-crypt                                [    <931,50 GiB] LVM physical volume
  /dev/nvme0n1p4                                        [     <54,17 GiB] 
  /dev/mapper/luks-cb25c253-2141-40b5-83ae-a2c1c0980496 [    <465,75 GiB] 
  /dev/nvme0n1p5                                        [    <206,72 GiB] 
  /dev/nvme0n1p6                                        [     400,62 GiB] LVM physical volume
  /dev/nvme0n1p7                                        [     500,00 MiB] 
  /dev/nvme0n1p8                                        [       1,86 GiB] 
  /dev/nvme0n1p9                                        [     <86,52 GiB] LVM physical volume
  /dev/nvme0n1p10                                       [      86,91 GiB] 
  /dev/nvme0n1p11                                       [     532,00 MiB] 
  /dev/nvme1n1                                          [    <953,87 GiB] 
  /dev/nvme1n1p1                                        [     856,21 GiB] 
  /dev/sdb                                              [      12,73 TiB] 
  /dev/sdc1                                             [     447,12 GiB] 
  /dev/sdd1                                             [     487,00 MiB] 
  /dev/sdd2                                             [     488,00 MiB] 
  /dev/sdd3                                             [     122,00 MiB] 
  /dev/sdd4                                             [     931,32 GiB] 
  /dev/sdd5                                             [     840,50 GiB] 
  /dev/sdd6                                             [    <498,05 GiB] 
  /dev/sde1                                             [     465,76 GiB] 
  4 disks
  22 partitions
  1 LVM physical volume whole disk
  2 LVM physical volumes

lvdisplay 
  WARNING: Couldn't find device with uuid ovqLHE-HeCP-MabL-UYaZ-zKGk-dSeM-G0HP0I.
  WARNING: Couldn't find device with uuid RxI6g8-Fp87-j7O4-N055-arL3-0l1E-CIIvo2.
  WARNING: VG lvm-crypt is missing PV ovqLHE-HeCP-MabL-UYaZ-zKGk-dSeM-G0HP0I (last written to /dev/mapper/nvme0n1p8_crypt).
  WARNING: VG lvm-crypt is missing PV RxI6g8-Fp87-j7O4-N055-arL3-0l1E-CIIvo2 (last written to /dev/mapper/nvme0n1p6_crypt).
  --- Logical volume ---
  LV Path                /dev/lvm-crypt/wurzel
  LV Name                wurzel
  VG Name                lvm-crypt
  LV UUID                sYo29d-sbzF-w6Bm-0E3W-LxNK-fr9i-jDnqOu
  LV Write Access        read/write
  LV Creation host, time r7deb, 2020-09-10 11:33:51 +0200
  LV Status              NOT available
  LV Size                30,73 GiB
  Current LE             7867
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
   
  --- Logical volume ---
  LV Path                /dev/lvm-crypt/home
  LV Name                home
  VG Name                lvm-crypt
  LV UUID                WdZkeA-uAQX-ryhu-11Xb-1Qp9-v3ld-FVIoej
  LV Write Access        read/write
  LV Creation host, time r7deb, 2020-09-10 11:33:58 +0200
  LV Status              NOT available
  LV Size                195,31 GiB
  Current LE             50000
  Segments               4
  Allocation             inherit
  Read ahead sectors     auto
   
  --- Logical volume ---
  LV Path                /dev/lvm-crypt/var
  LV Name                var
  VG Name                lvm-crypt
  LV UUID                TQav8N-UWZB-6ST1-JMBa-dnCp-A79j-9SdPDD
  LV Write Access        read/write
  LV Creation host, time r7deb, 2020-09-10 11:34:07 +0200
  LV Status              NOT available
  LV Size                18,62 GiB
  Current LE             4768
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
   
  --- Logical volume ---
  LV Path                /dev/lvm-crypt/temp
  LV Name                temp
  VG Name                lvm-crypt
  LV UUID                YBsh1S-1QJI-yIc1-071S-Mqgr-QCoV-7ktV0g
  LV Write Access        read/write
  LV Creation host, time r7deb, 2020-09-10 11:34:16 +0200
  LV Status              NOT available
  LV Size                <1,86 GiB
  Current LE             476
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
   
  --- Logical volume ---
  LV Path                /dev/lvm-crypt/vms
  LV Name                vms
  VG Name                lvm-crypt
  LV UUID                MYuXdV-QuC8-YToG-v2gU-PmlJ-fAEz-AME3Ba
  LV Write Access        read/write
  LV Creation host, time r7deb, 2020-11-11 10:31:26 +0100
  LV Status              NOT available
  LV Size                540,62 GiB
  Current LE             138400
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
   
  --- Logical volume ---
  LV Path                /dev/lvm-crypt/buero
  LV Name                buero
  VG Name                lvm-crypt
  LV UUID                8sxSOg-gCfc-Dqb5-jTPg-nJGo-qklD-MaM4vV
  LV Write Access        read/write
  LV Creation host, time r7deb, 2022-06-19 08:35:01 +0200
  LV Status              NOT available
  LV Size                <117,19 GiB
  Current LE             30000
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
   
  --- Logical volume ---
  LV Path                /dev/lvm-crypt/buero2
  LV Name                buero2
  VG Name                lvm-crypt
  LV UUID                r3ZqOD-6dqr-esJZ-jqg9-qzoS-7k1o-sRMf8P
  LV Write Access        read/write
  LV Creation host, time r7deb, 2022-06-19 08:37:31 +0200
  LV Status              NOT available
  LV Size                <117,19 GiB
  Current LE             30000
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto

vgscan -v
  WARNING: Couldn't find device with uuid ovqLHE-HeCP-MabL-UYaZ-zKGk-dSeM-G0HP0I.
  WARNING: Couldn't find device with uuid RxI6g8-Fp87-j7O4-N055-arL3-0l1E-CIIvo2.
  WARNING: VG lvm-crypt is missing PV ovqLHE-HeCP-MabL-UYaZ-zKGk-dSeM-G0HP0I (last written to /dev/mapper/nvme0n1p8_crypt).
  WARNING: VG lvm-crypt is missing PV RxI6g8-Fp87-j7O4-N055-arL3-0l1E-CIIvo2 (last written to /dev/mapper/nvme0n1p6_crypt).
  Found volume group "lvm-crypt" using metadata type lvm2
vgdisplay -v
  WARNING: Couldn't find device with uuid ovqLHE-HeCP-MabL-UYaZ-zKGk-dSeM-G0HP0I.
  WARNING: Couldn't find device with uuid RxI6g8-Fp87-j7O4-N055-arL3-0l1E-CIIvo2.
  WARNING: VG lvm-crypt is missing PV ovqLHE-HeCP-MabL-UYaZ-zKGk-dSeM-G0HP0I (last written to /dev/mapper/nvme0n1p8_crypt).
  WARNING: VG lvm-crypt is missing PV RxI6g8-Fp87-j7O4-N055-arL3-0l1E-CIIvo2 (last written to /dev/mapper/nvme0n1p6_crypt).
  --- Volume group ---
  VG Name               lvm-crypt
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  37
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                7
  Open LV               0
  Max PV                0
  Cur PV                3
  Act PV                1
  VG Size               <1,39 TiB
  PE Size               4,00 MiB
  Total PE              363160
  Alloc PE / Size       261511 / <1021,53 GiB
  Free  PE / Size       101649 / <397,07 GiB
  VG UUID               hBHElE-V8b3-bBWF-Om2J-LH8u-0D7R-Nh8vdw
   
  --- Logical volume ---
  LV Path                /dev/lvm-crypt/wurzel
  LV Name                wurzel
  VG Name                lvm-crypt
  LV UUID                sYo29d-sbzF-w6Bm-0E3W-LxNK-fr9i-jDnqOu
  LV Write Access        read/write
  LV Creation host, time r7deb, 2020-09-10 11:33:51 +0200
  LV Status              NOT available
  LV Size                30,73 GiB
  Current LE             7867
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
   
  --- Logical volume ---
  LV Path                /dev/lvm-crypt/home
  LV Name                home
  VG Name                lvm-crypt
  LV UUID                WdZkeA-uAQX-ryhu-11Xb-1Qp9-v3ld-FVIoej
  LV Write Access        read/write
  LV Creation host, time r7deb, 2020-09-10 11:33:58 +0200
  LV Status              NOT available
  LV Size                195,31 GiB
  Current LE             50000
  Segments               4
  Allocation             inherit
  Read ahead sectors     auto
   
  --- Logical volume ---
  LV Path                /dev/lvm-crypt/var
  LV Name                var
  VG Name                lvm-crypt
  LV UUID                TQav8N-UWZB-6ST1-JMBa-dnCp-A79j-9SdPDD
  LV Write Access        read/write
  LV Creation host, time r7deb, 2020-09-10 11:34:07 +0200
  LV Status              NOT available
  LV Size                18,62 GiB
  Current LE             4768
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
   
  --- Logical volume ---
  LV Path                /dev/lvm-crypt/temp
  LV Name                temp
  VG Name                lvm-crypt
  LV UUID                YBsh1S-1QJI-yIc1-071S-Mqgr-QCoV-7ktV0g
  LV Write Access        read/write
  LV Creation host, time r7deb, 2020-09-10 11:34:16 +0200
  LV Status              NOT available
  LV Size                <1,86 GiB
  Current LE             476
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
   
  --- Logical volume ---
  LV Path                /dev/lvm-crypt/vms
  LV Name                vms
  VG Name                lvm-crypt
  LV UUID                MYuXdV-QuC8-YToG-v2gU-PmlJ-fAEz-AME3Ba
  LV Write Access        read/write
  LV Creation host, time r7deb, 2020-11-11 10:31:26 +0100
  LV Status              NOT available
  LV Size                540,62 GiB
  Current LE             138400
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
   
  --- Logical volume ---
  LV Path                /dev/lvm-crypt/buero
  LV Name                buero
  VG Name                lvm-crypt
  LV UUID                8sxSOg-gCfc-Dqb5-jTPg-nJGo-qklD-MaM4vV
  LV Write Access        read/write
  LV Creation host, time r7deb, 2022-06-19 08:35:01 +0200
  LV Status              NOT available
  LV Size                <117,19 GiB
  Current LE             30000
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
   
  --- Logical volume ---
  LV Path                /dev/lvm-crypt/buero2
  LV Name                buero2
  VG Name                lvm-crypt
  LV UUID                r3ZqOD-6dqr-esJZ-jqg9-qzoS-7k1o-sRMf8P
  LV Write Access        read/write
  LV Creation host, time r7deb, 2022-06-19 08:37:31 +0200
  LV Status              NOT available
  LV Size                <117,19 GiB
  Current LE             30000
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
   
  --- Physical volumes ---
  PV Name               [unknown]     
  PV UUID               ovqLHE-HeCP-MabL-UYaZ-zKGk-dSeM-G0HP0I
  PV Status             allocatable
  Total PE / Free PE    22144 / 0
   
  PV Name               [unknown]     
  PV UUID               RxI6g8-Fp87-j7O4-N055-arL3-0l1E-CIIvo2
  PV Status             allocatable
  Total PE / Free PE    102554 / 0
   
  PV Name               /dev/mapper/sda1-crypt     
  PV UUID               s4UhPf-B5u1-d73L-DKcy-FR93-KvMa-kNrQJ6
  PV Status             allocatable
  Total PE / Free PE    238462 / 101649

lsblk -o NAME,SIZE,TYPE,UUID
NAME                                            SIZE TYPE  UUID
sda                                           931,5G disk  
└─sda1                                        931,5G part  50353f7f-7bc8-4100-85e2-56db32895c11
  └─sda1-crypt                                931,5G crypt s4UhPf-B5u1-d73L-DKcy-FR93-KvMa-kNrQJ6
sdb                                            12,7T disk  a7bbc558-c28c-4df6-992d-8ce16a961147
sdc                                           447,1G disk  
└─sdc1                                        447,1G part  c1971d93-afc1-4f0c-875a-4280c5a275fd
  └─sdc1-crypt                                447,1G crypt 06cd919c-024c-4987-9e78-41551292ed60
sdd                                             3,6T disk  
├─sdd1                                          487M part  
├─sdd2                                          488M part  727C-2D0A
├─sdd3                                          122M part  
├─sdd4                                        931,3G part  786749de-fa3c-4c2c-ac40-23b6ddd6e76e
├─sdd5                                        840,5G part  0fe82dcd-1d1d-4c4b-9f90-91c4cfd6ec07
│ └─sdd5-crypt                                840,5G crypt ad53f0e9-5e4f-48c9-ba2f-2ca3af949ea2
└─sdd6                                          498G part  38bafe27-5b78-48ea-980c-de636514df14
  └─sdd6-crypt                                  498G crypt eb0a33c9-bd6c-4c38-ae31-4667ba3cff24
sde                                           465,8G disk  
└─sde1                                        465,8G part  cb25c253-2141-40b5-83ae-a2c1c0980496
  └─luks-cb25c253-2141-40b5-83ae-a2c1c0980496 465,7G crypt b7aef9a8-41d8-4d11-975f-9f77645434a2
sr0                                            1024M rom   
nvme0n1                                       931,5G disk  
├─nvme0n1p1                                     450M part  D09495E59495CDFA
├─nvme0n1p2                                     100M part  7096-4C77
├─nvme0n1p3                                      16M part  
├─nvme0n1p4                                    54,2G part  C2A82FF0A82FE221
├─nvme0n1p5                                   206,7G part  04BFD1325C7FA67C
├─nvme0n1p6                                   400,6G part  s1TKbL-cSK8-egOQ-Iexp-0yoI-Yg8j-HSpbwC
├─nvme0n1p7                                     500M part  A5A2-6853
├─nvme0n1p8                                     1,9G part  41aadaed-4741-42a1-b17b-128c9fcf6188
├─nvme0n1p9                                    86,5G part  8Lk9H1-Tveo-JCko-nfgd-EDrL-KJVq-cA01lR
├─nvme0n1p10                                   86,9G part  c6c45bc2-a657-4dbb-83b2-b8ef4b3930b9
└─nvme0n1p11                                    532M part  A63AA7D23AA79E35
nvme1n1                                       953,9G disk  
└─nvme1n1p1                                   856,2G part  68BEA6DCBEA6A1D4

编辑1:

到目前为止很糟糕。我尝试了一些方法,对我来说,UUID 似乎已更改或标头已损坏。

我找到了旧的 debian 10 /boot/ 分区,并且能够启动到 initramfs。在这里,我能够通过几年前设置的繁忙盒子登录(以便能够远程登录并远程解锁驱动器以启动系统。)所以我确实登录并找到了该crypttab文件。关于其内容,它期望不同的 UUID。

cat /cryptroot/crypttab3 
nvme0n1p8_crypt UUID=1697ec4a-b30b-4642-b4f3-6ba94afc40ec none luks,discard
nvme0n1p6_crypt UUID=73404056-2fb5-4d7f-b1eb-8cff2273a211 /FIXME-initramfs-rootmnt/root/luks.keys.d/nvme0n1p6.luks.key luks,discard,initramfs
crypt_pv_SamsungQVO UUID=50353f7f-7bc8-4100-85e2-56db32895c11 /FIXME-initramfs-rootmnt/root/luks.keys.d/SamsungQVO_S4CZNG0M301660E.luks.key luks,discard,initramfs
kingston_crypt UUID=c1971d93-afc1-4f0c-875a-4280c5a275fd /FIXME-initramfs-rootmnt/root/luks.keys.d/KINGSTON_SHFS37A480G_50026B7269007A6C.luks.key luks,discard,initramfs

我尝试使用手动将它们调整到适当的分区vi,但找不到有效的 LUKS 分区。

在启动 Debian 11 时尝试解密驱动器时出现相同的结果。它说这不是有效的 LUKS 分区。

因此,此时我可能会放弃认为分区标头已损坏(这确实很可疑 - 我的意思是同时有两个损坏的 luks 标头),或者 LVM 需要先设置卷组,然后才能使用 LUKS 解锁分区/卷。我想这里就是后者,但我已经没有想法了。

如果您没有更好的建议,我将尝试将 UUID 更改为我在旧 /boot/ 分区中找到的 initramfs 内的 crypttab 文件中记录的 UUID。

希望 LVM 能够以这种方式把事情做好。

相关内容