如何减少 LVM 分区的大小并创建另一个分区?

如何减少 LVM 分区的大小并创建另一个分区?

我的磁盘上有standard parition一个lvm partition/dev/sda

[root@server1 ~]# fdisk -l
Disk /dev/sda: 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
Disklabel type: dos
Disk identifier: 0x3ab97747

Device     Boot   Start      End  Sectors Size Id Type
/dev/sda1  *       2048  2099199  2097152   1G 83 Linux
/dev/sda2       2099200 20971519 18872320   9G 8e Linux LVM

我的总磁盘空间为 10G,我想减少大小/dev/sda2并创建另一个标准分区/dev/sda3

[root@server1 ~]# df -h
Filesystem             Size  Used Avail Use% Mounted on
devtmpfs               462M     0  462M   0% /dev
tmpfs                  490M     0  490M   0% /dev/shm
tmpfs                  490M  7.6M  483M   2% /run
tmpfs                  490M     0  490M   0% /sys/fs/cgroup
/dev/mapper/rhel-root  8.0G  4.2G  3.9G  52% /
/dev/sda1             1014M  210M  805M  21% /boot
tmpfs                   98M  1.2M   97M   2% /run/user/42
tmpfs                   98M  4.6M   94M   5% /run/user/1000
[root@server1 ~]#

[root@server1 ~]# vgdisplay -v
  --- Volume group ---
  VG Name               rhel
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  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               <9.00 GiB
  PE Size               4.00 MiB
  Total PE              2303
  Alloc PE / Size       2303 / <9.00 GiB
  Free  PE / Size       0 / 0
  VG UUID               ScT2gM-r4Vl-7FVv-cyoh-6FJq-fcNU-Z7Wobk

  --- Logical volume ---
  LV Path                /dev/rhel/swap
  LV Name                swap
  VG Name                rhel
  LV UUID                jLX6Kp-KV68-vH9V-MCG0-quZK-grC2-PguTOC
  LV Write Access        read/write
  LV Creation host, time server1, 2020-07-17 23:47:10 -0500
  LV Status              available
  # open                 2
  LV Size                1.00 GiB
  Current LE             256
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:1

  --- Logical volume ---
  LV Path                /dev/rhel/root
  LV Name                root
  VG Name                rhel
  LV UUID                F3uUAt-QgLv-YZ62-k8wb-lxPn-UYa8-gQz8Pe
  LV Write Access        read/write
  LV Creation host, time server1, 2020-07-17 23:47:11 -0500
  LV Status              available
  # open                 1
  LV Size                <8.00 GiB
  Current LE             2047
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:0

  --- Physical volumes ---
  PV Name               /dev/sda2
  PV UUID               020htj-f95F-i3O5-Dh3j-4yWc-EbU0-yYKkFY
  PV Status             allocatable
  Total PE / Free PE    2303 / 0

我尝试过使用lvreduce但得到:

[root@server1 ~]# lvreduce /dev/sda2
  No command with matching syntax recognised.  Run 'lvreduce --help' for more information.
  Correct command syntax is:
  lvreduce -L|--size [-]Size[m|UNIT] LV

由于这只是一个测试服务器,我可以接受丢失一些数据,但不会让我无法运行 Linux 命令

相关内容