将 LUKS 分区移至左侧并调整其大小

dep*_*pau 7 partitioning gpt luks

我有一个 LUKS 加密分区,它不属于 LVM 卷管理器。它位于硬盘驱动器的末尾,其大小为 250 GB,但我想再添加 50 GB。

我通常会使用 GParted 进行此类操作,但它不允许我对 LUKS 分区执行任何操作,甚至不能移动。

我怎样才能做到这一点而不丢失我的数据?(我没有其他地方可以备份)

这是我的(GUID)分区表:

GPT fdisk (gdisk) version 0.8.8

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.
Disk /dev/sda: 976773168 sectors, 465.8 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): D630E573-66C0-4902-A4A2-A9D56AE54544
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 976773134
Partitions will be aligned on 2048-sector boundaries
Total free space is 262922206 sectors (125.4 GiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048          411647   200.0 MiB   EF00  
   2          411648        63326207   30.0 GiB    8300  Linux filesystem
   3       189155328       273041407   40.0 GiB    AF00  
   4       273041408       304498687   15.0 GiB    8300  
   5       336732160       337141759   200.0 MiB   0700  
   6       337141760       347627519   5.0 GiB     8200  
   8       452485120       976773134   250.0 GiB   8300  Linux filesystem
Run Code Online (Sandbox Code Playgroud)

这就是 GParted 中的样子:

在此输入图像描述

正如你所看到的,我想将 sda6 和 sda8 之间的 50GB 添加到 sda8。

你能帮我向后移动 /dev/sda8 以便我可以扩展其中的加密卷和文件系统吗?

Ste*_*eve 1

9 年前,当这个问题最初被问到时,我确信 Gparted 无法移动 LUKS 分区,但现在可以了。昨天,我成功地调整了两个 LUKS 分区的大小并移动了它们,这两个分区都保护 ext4 文件系统。

我使用的是 Gparted live CD 版本 1.5.0-6-amd64。

我发现的唯一问题是 ext4 文件系统必须从 LUKS 分区的开头启动。

我将使用一个假例子来描述该过程。最初我有一个完整的硬盘,有两个分区:

  • /dev/sda1 (100GB)
  • /dev/sda2 (900GB)

我想将 sda2 缩小 100gb,将 sda1 增加 100gb。过程是:

  1. 启动进入 Gparted live
  2. 解锁sda2 luks分区
  3. 将 LUKS 分区开头的 ext4 sda2 文件系统缩小为 800GB。
  4. 锁定 sda2 luks 分区。
  5. 将luks sda2分区缩小为800GB(此时硬盘末尾有100GB)
  6. 将 sda2 移动到 HDD 的末尾(长操作)。
  7. 将sda1扩展至200GB
  8. 解锁sda1 luks分区
  9. 将 sda1 ext4 文件系统的大小调整为 200GB。

使用 Gparted gui 一切都非常简单。