如何将新驱动器添加到 fedora-root

如何将新驱动器添加到 fedora-root

我正在尝试添加空间/dev/mapper/fedora-root。我可以运行lvextend并成功添加额外的空间,但它似乎并没有真正将其添加为可用。

具体来说,我的网站上有 15G 可用空间,用于/var/www/我需要所有空间的地方。

我在安装 fedora-root 的驱动器上有额外的空间,并且在第二个驱动器上还有额外的 2tb 空间可供使用。但每当我添加空间时,它都会保持在 15G。

以下是一些可能有用的命令的输出:

$ sudo df -h

Filesystem               Size  Used Avail Use% Mounted on
devtmpfs                  24G     0   24G   0% /dev
tmpfs                     24G  8.0K   24G   1% /dev/shm
tmpfs                     24G  1.5M   24G   1% /run
/dev/mapper/fedora-root   15G   14G  1.5G  91% /
tmpfs                     24G  4.0K   24G   1% /tmp
/dev/sda1               1014M  224M  791M  22% /boot
tmpfs                    4.8G     0  4.8G   0% /run/user/1000
tmpfs                    4.8G     0  4.8G   0% /run/user/0

$ sudo vgdisplay -v

  --- Volume group ---
  VG Name               fedora
  System ID
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  12
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               2.08 TiB
  PE Size               4.00 MiB
  Total PE              546110
  Alloc PE / Size       11235 / <43.89 GiB
  Free  PE / Size       534875 / 2.04 TiB
  VG UUID               lgfK0B-loTg-wQlS-dtsR-qWZJ-Hqh6-SkWk55

  --- Logical volume ---
  LV Path                /dev/fedora/swap
  LV Name                swap
  VG Name                fedora
  LV UUID                81zkKH-IeMO-gcoO-O9DX-7w7G-4a1i-lw2dhy
  LV Write Access        read/write
  LV Creation host, time localhost, 2019-11-24 17:33:39 -0500
  LV Status              available
  # open                 2
  LV Size                <23.64 GiB
  Current LE             6051
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1

  --- Logical volume ---
  LV Path                /dev/fedora/root
  LV Name                root
  VG Name                fedora
  LV UUID                e9fRu0-FupO-8e6V-fodF-ZPQ5-alBK-XVutVM
  LV Write Access        read/write
  LV Creation host, time localhost, 2019-11-24 17:33:40 -0500
  LV Status              available
  # open                 1
  LV Size                20.25 GiB
  Current LE             5184
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

  --- Physical volumes ---
  PV Name               /dev/sda2
  PV UUID               AdC6bu-ct2C-dP0k-TRM8-PZ7z-vYDj-tN5jGn
  PV Status             allocatable
  Total PE / Free PE    69439 / 58204

  PV Name               /dev/sdb1
  PV UUID               n6tBpo-ce7D-MCZR-GFKY-BsHW-pcmG-FmM3Wo
  PV Status             allocatable
  Total PE / Free PE    476671 / 476671

$ sudo lvextend -l+288 /dev/mapper/fedora-root

  Size of logical volume fedora/root changed from 20.25 GiB (5184 extents) to <21.38 GiB (5472 extents).
  Logical volume fedora/root successfully resized.

$ sudo fdisk -l

Disk /dev/sda: 272.26 GiB, 292326211584 bytes, 570949632 sectors
Disk model: PERC 6/i
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: 0xdf465195

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


Disk /dev/sdb: 1.84 TiB, 1999307276288 bytes, 3904897024 sectors
Disk model: PERC 6/i
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: 0x8e545053

Device     Boot Start        End    Sectors  Size Id Type
/dev/sdb1        2048 3904897023 3904894976  1.8T 8e Linux LVM


Disk /dev/mapper/fedora-root: 21.38 GiB, 22951231488 bytes, 44826624 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/mapper/fedora-swap: 23.65 GiB, 25379733504 bytes, 49569792 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

再次运行 'sudo df -h' 得到:

    $ sudo df -h
Filesystem               Size  Used Avail Use% Mounted on
devtmpfs                  24G     0   24G   0% /dev
tmpfs                     24G  8.0K   24G   1% /dev/shm
tmpfs                     24G  1.5M   24G   1% /run
/dev/mapper/fedora-root   15G   14G  1.5G  91% /
tmpfs                     24G  4.0K   24G   1% /tmp
/dev/sda1               1014M  224M  791M  22% /boot
tmpfs                    4.8G     0  4.8G   0% /run/user/1000
tmpfs                    4.8G     0  4.8G   0% /run/user/0

编辑: $ sudo lsblk -f

NAME            FSTYPE      LABEL UUID                                   FSAVAIL FSUSE% MOUNTPOINT
sda
├─sda1          xfs               59ff08c1-39e5-4cdd-87a8-d51d7aead2e5      791M    22% /boot
└─sda2          LVM2_member       AdC6bu-ct2C-dP0k-TRM8-PZ7z-vYDj-tN5jGn
  ├─fedora-root xfs               cd4163ba-8b53-48db-bd30-32802f4bd3a0      1.4G    91% /
  └─fedora-swap swap              2de89191-34eb-4439-81a8-2f879d917821                  [SWAP]
sdb
└─sdb1          LVM2_member       n6tBpo-ce7D-MCZR-GFKY-BsHW-pcmG-FmM3Wo

答案1

要使空间可用,您需要使用该xfs_growfs命令,因为逻辑卷上的文件系统是xfs

xfs_growfs /

如果它是 ext2、ext3 或 ext4,那么您将resize2fs与该名称一起使用。

编辑:它似乎在 Fedora、RHEL 8 和 CentOS 8 的最新版本中进行了更改。使用 lv/block 设备可以在 RHEL 7 和 CentOS 7 中使用,但您需要使用操作系统的挂载点,因为它正在使用该实用程序的更高版本。

相关内容