如何调整加密的根分区和主分区的大小,为根分区提供更多空间?

如何调整加密的根分区和主分区的大小,为根分区提供更多空间?

我需要扩大我的 / (根)分区,我的 /home 分区上有很多空间,我该怎么做?该驱动器已使用 LUKS 加密。

我的系统是Fedora 20。

我还有另一个话题这里其中提到了 system-config-lvm 但这似乎是一个过时的工具,因为它未安装或位于存储库中。 Gparted 不起作用,因为它不支持 LUKS 加密。

这是:

~]$ sudo fdisk -l 

Disk /dev/sda: 465.8 GiB, 500107862016 bytes, 976773168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 7AE6E531-9898-4C7C-8C35-41B4FDB9374A

Device           Start          End   Size Type
/dev/sda1         2048       411647   200M EFI System
/dev/sda2       411648      1435647   500M Microsoft basic data
/dev/sda3      1435648    976773119 465.1G Microsoft basic data


Disk /dev/mapper/luks-e69b0b4c-a8e0-425f-988d-8c635729503b: 465.1 GiB, 499370688512 bytes, 975333376 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk /dev/mapper/fedora_hostname-swap: 3.8 GiB, 4043309056 bytes, 7897088 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk /dev/mapper/fedora_hostname-root: 50 GiB, 53687091200 bytes, 104857600 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk /dev/mapper/luks-b7af1bce-82c4-4921-aac1-bce701e30256: 50 GiB, 53684994048 bytes, 104853504 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk /dev/mapper/fedora_hostname-home: 411.3 GiB, 441639239680 bytes, 862576640 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

这是:

~]$ df -h
Filesystem                       Size  Used Avail Use% Mounted on
/dev/dm-3                         50G   45G  2.0G  96% /
devtmpfs                         1.9G     0  1.9G   0% /dev
tmpfs                            1.9G   80K  1.9G   1% /dev/shm
tmpfs                            1.9G  9.0M  1.9G   1% /run
tmpfs                            1.9G     0  1.9G   0% /sys/fs/cgroup
tmpfs                            1.9G   20K  1.9G   1% /tmp
/dev/sda2                        477M  131M  317M  30% /boot
/dev/sda1                        200M  9.6M  191M   5% /boot/efi
/dev/mapper/fedora_hostname-home  405G  202G  183G  53% /home

这是:

]$ sudo lvdisplay        
  --- Logical volume ---
  LV Path                /dev/fedora_hostname/swap
  LV Name                swap
  VG Name                fedora_hostname
  LV UUID                qQQRVR-toXX-J0M7-lTH5-d8Lr-AUq3-EHJ6A4
  LV Write Access        read/write
  LV Creation host, time hostname.lan, 2014-03-24 15:51:10 +0000
  LV Status              available
  # open                 2
  LV Size                3.77 GiB
  Current LE             964
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1

  --- Logical volume ---
  LV Path                /dev/fedora_hostname/home
  LV Name                home
  VG Name                fedora_hostname
  LV UUID                In2lRz-16ul-VhH5-SQOE-yqlt-tMB3-5JM7ea
  LV Write Access        read/write
  LV Creation host, time hostname.lan, 2014-03-24 15:51:10 +0000
  LV Status              available
  # open                 1
  LV Size                411.31 GiB
  Current LE             105295
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:4

  --- Logical volume ---
  LV Path                /dev/fedora_hostname/root
  LV Name                root
  VG Name                fedora_hostname
  LV UUID                bBWzcC-nhhd-s8km-MMGi-uGQ0-8yBv-HClQgp
  LV Write Access        read/write
  LV Creation host, time hostname.lan, 2014-03-24 15:51:16 +0000
  LV Status              available
  # open                 1
  LV Size                50.00 GiB
  Current LE             12800
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:2

答案1

答案就在线....

摘录:

因此,步骤如下:

  1. 缩小/home“文件系统”。 (例如,如果是 ext4,则应使用 resize2fs 调整其大小)。

  2. 使用 lvreduce 缩小 /home LVM 分区 (/dev/mapper/fedora_hostname-home) 大小,使其完全包含 /home 缩小的文件系统

  3. 如果收缩后的文件系统小于 /home LVM 分区,您可以再次调整文件系统的大小以完全填满 LVM 逻辑卷。我通常使用这种方法,这样我就不需要精确计算尺寸了! :P

(完成上述每个步骤后,您可以挂载 /home 来查看它是否正确挂载以及数据是否存在。如果没有(例如由于参数错误),您可以恢复该有问题的步骤)。

扩大/分区的步骤如下:

  1. 扩大/LVM分区(/dev/mapper/fedora_hostname-root)以填充可用空间(使用lvextend)

  2. 扩大 / LUKS 分区以填充 /dev/mapper/fedora_hostname-root LVM 分区(使用 cryptsetup resize)

  3. 放大 / 文件系统以填充 / LUKS 分区(例如,如果是 ext2/3/4,则使用 resize2fs)

相关内容