使用硬件 RAID 将未分配的 LVM 空间分区为新的物理分区

使用硬件 RAID 将未分配的 LVM 空间分区为新的物理分区

我是 Linux 和分区方面的新手,如果这个问题之前已经回答过,我提前道歉;我在网上广泛搜索答案,在没有找到答案后,我决定发布一个问题。好了,下面是问题描述:

在具有硬件 RAID 的服务器上运行 Ubuntu Server 14.10 裸机,该 RAID 在 BIOS 中配置。在安装过程中,我使用默认分区,最终将大部分空间分配给 /root。我做的第一件事是调整根分区的大小,将 /swap 移动到与 /root 相邻的位置,成功缩小 pv 和 vg,这要感谢网站上的几篇帖子。现在我无法找到将新释放的空间用作新分区的方法。以下是详细信息

 ~# fdisk --list

Disk /dev/sda: 1.6 TiB, 1796997120000 bytes, 3509760000 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x0f179d27

Device     Boot  Start        End    Sectors  Size Id Type
/dev/sda1  *      2048     499711     497664  243M 83 Linux
/dev/sda2       501758 3509757951 3509256194  1.6T  5 Extended
/dev/sda5       501760 3509757951 3509256192  1.6T 8e Linux LVM

Disk /dev/mapper/bce--os--cpy--vg-root: 10 GiB, 10737418240 bytes, 20971520 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/sdd: 7.5 GiB, 8004304896 bytes, 15633408 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000

Device     Boot Start      End  Sectors  Size Id Type
/dev/sdd1  *        2 15633407 15633406  7.5G  c W95 FAT32 (LBA)

Disk /dev/mapper/bce--os--cpy--vg-swap_1: 64 GiB, 68719476736 bytes, 134217728 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

使用 GParted 时,它显示 sda5 是 sda2 的子集,这让我相信这里的 sda2 是我的 RAID。Gparted 仅有助于可视化磁盘,除此之外我无法使用它,我的理解是它不支持 LVM。此外,我无法使用 system-config-lvm 包,因为据我所知它已被弃用。

以下是 vgdisplay、pvdisplay 和 lvdisplay 的详细信息

~# vgdisplay
  --- Volume group ---
  VG Name               bce-os-cpy-vg
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  7
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               75.00 GiB
  PE Size               4.00 MiB
  Total PE              19199
  Alloc PE / Size       18944 / 74.00 GiB
  Free  PE / Size       255 / 1020.00 MiB
  VG UUID               dO1C4A-WdnE-KdSf-U1Cs-9iOP-fg4P-KwSGFd

~# pvdisplay -m
  --- Physical volume ---
  PV Name               /dev/sda5
  VG Name               bce-os-cpy-vg
  PV Size               75.00 GiB / not usable 3.00 MiB
  Allocatable           yes
  PE Size               4.00 MiB
  Total PE              19199
  Free PE               255
  Allocated PE          18944
  PV UUID               SNkWK0-tkXG-Akza-qoDs-BcT3-3MEk-L53L0B

  --- Physical Segments ---
  Physical extent 0 to 2559:
    Logical volume  /dev/bce-os-cpy-vg/root
    Logical extents 0 to 2559
  Physical extent 2560 to 18943:
    Logical volume  /dev/bce-os-cpy-vg/swap_1
    Logical extents 0 to 16383
  Physical extent 18944 to 19198:
    FREE

~# lvdisplay -m
  --- Logical volume ---
  LV Path                /dev/bce-os-cpy-vg/root
  LV Name                root
  VG Name                bce-os-cpy-vg
  LV UUID                8u1Eqf-6FPF-DXzh-vBds-cUyq-c1Fm-ewuhxk
  LV Write Access        read/write
  LV Creation host, time bce-os-cpy, 2015-03-10 23:13:58 -0400
  LV Status              available
  # open                 1
  LV Size                10.00 GiB
  Current LE             2560
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           252:0

  --- Segments ---
  Logical extent 0 to 2559:
    Type        linear
    Physical volume /dev/sda5
    Physical extents    0 to 2559


  --- Logical volume ---
  LV Path                /dev/bce-os-cpy-vg/swap_1
  LV Name                swap_1
  VG Name                bce-os-cpy-vg
  LV UUID                H7wmEp-Aw90-aWV1-aGrd-2yMr-ZBkH-sS1Zty
  LV Write Access        read/write
  LV Creation host, time debian, 2015-03-23 18:38:31 -0400
  LV Status              available
  # open                 2
  LV Size                64.00 GiB
  Current LE             16384
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           252:1

  --- Segments ---
  Logical extent 0 to 16383:
    Type        linear
    Physical volume /dev/sda5
    Physical extents    2560 to 18943

这是 vgs、pvs 和 lvs 输出

~# vgs
  VG            #PV #LV #SN Attr   VSize  VFree
  bce-os-cpy-vg   1   2   0 wz--n- 75.00g 1020.00m
root@bce-os-cpu:~# pvs
  PV         VG            Fmt  Attr PSize  PFree
  /dev/sda5  bce-os-cpy-vg lvm2 a--  75.00g 1020.00m
root@bce-os-cpu:~# lvs
  LV     VG            Attr      LSize  Pool Origin Data%  Move Log Copy%  Convert
  root   bce-os-cpy-vg -wi-ao--- 10.00g
  swap_1 bce-os-cpy-vg -wi-ao--- 64.00g

文件系统

~# cat /etc/fstab
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
/dev/mapper/bce--os--cpy--vg-root /               ext4    errors=remount-ro 0       1
# /boot was on /dev/sda1 during installation
UUID=e24ff838-71c8-42b1-a381-d89c6daf3be1 /boot           ext2    defaults        0       2
/dev/mapper/bce--os--cpy--vg-swap_1 none            swap    sw              0       0

因此,正如您所看到的,磁盘大小为 1.6T,如 fdisk 输出中所示,在成功(我认为)缩小 vg、pv 和 lv 后,我只使用了 75G,我想使用释放的空间(如何找到它?)来创建一个新的分区。

答案1

sda是您的硬件 raid。 sda5是的子集,sda2因为sda2是您的扩展分区,并且sda5是逻辑分区。如果您想为新分区释放空间,只需使用 livecd 中的 gparted 缩小 sda5 即可。

相关内容