如何在有多个分区的 Centos7 中扩大特定分区

如何在有多个分区的 Centos7 中扩大特定分区

我的/home目录很快就用完了磁盘空间,所以我想将其从 32GB 扩展到 64GB。

[me@centos7 ~]$ df -h
Filesystem               Size  Used Avail Use% Mounted on
devtmpfs                 7.8G     0  7.8G   0% /dev
tmpfs                    7.8G     0  7.8G   0% /dev/shm
tmpfs                    7.8G  9.3M  7.8G   1% /run
tmpfs                    7.8G     0  7.8G   0% /sys/fs/cgroup
/dev/mapper/centos-root   29G   18G   11G  64% /
/dev/sdb                  32G   19G   11G  64% /home     <------ this one
/dev/sdd                  32G  2.0G   28G   7% /u02
/dev/sdc                  32G  8.7G   22G  30% /u01
/dev/sda1                497M  343M  155M  69% /boot
tmpfs                    1.6G   12K  1.6G   1% /run/user/42
tmpfs                    1.6G     0  1.6G   0% /run/user/1001

我的机器是 VirtualBox 中的 CentOS 7 虚拟机,它有几个快照:

具有多个快照的虚拟机

该机器有4个分区:

四个分区

最初,SATA 端口 1(home.vdi)只有 32GB,但我能够通过虚拟媒体管理器将其更改为 64GB:

虚拟媒体管理器

将虚拟大小更改为 64GB 后,df输出与上文相同。以下是输出lsblk

[me@centos7 ~]$ lsblk
NAME                         MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                            8:0    0   32G  0 disk
├─sda1                         8:1    0  500M  0 part /boot
└─sda2                         8:2    0 31.5G  0 part
  ├─centos-root              253:0    0 28.3G  0 lvm  /
  └─centos-swap              253:1    0  3.2G  0 lvm  [SWAP]
sdb                            8:16   0   32G  0 disk /home
sdc                            8:32   0   32G  0 disk /u01
sdd                            8:48   0   32G  0 disk /u02
sr0                           11:0    1 58.3M  0 rom
loop0                          7:0    0  100G  0 loop
└─docker-253:0-67412413-pool 253:2    0  100G  0 dm
loop1                          7:1    0    2G  0 loop
└─docker-253:0-67412413-pool 253:2    0  100G  0 dm

这是、、和fdisk的打印输出:/dev/sda/dev/sdb/dev/sdc/dev/sdd

[me@centos7 ~]$ sudo fdisk /dev/sda
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): p

Disk /dev/sda: 34.4 GB, 34359738368 bytes, 67108864 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 label type: dos
Disk identifier: 0x00024fc7

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048    67108863    33041408   8e  Linux LVM

Command (m for help): q

[me@centos7 ~]$ sudo fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x898c2f25.

Command (m for help): p

Disk /dev/sdb: 34.4 GB, 34359738368 bytes, 67108864 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 label type: dos
Disk identifier: 0x898c2f25

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): q

[me@centos7 ~]$ sudo fdisk /dev/sdc
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x44d41ba0.

Command (m for help): p

Disk /dev/sdc: 34.4 GB, 34359738368 bytes, 67108864 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 label type: dos
Disk identifier: 0x44d41ba0

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): q

[me@centos7 ~]$ sudo fdisk /dev/sdd
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x620f9140.

Command (m for help): p

Disk /dev/sdd: 34.4 GB, 34359738368 bytes, 67108864 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 label type: dos
Disk identifier: 0x620f9140

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): q

我的操作系统详细信息是:

[me@centos7 ~]$ uname -a
Linux centos7 3.10.0-1160.31.1.el7.x86_64 #1 SMP Thu Jun 10 13:32:12 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

我看到了这些指示但我不知道如何将它们应用于我的情况,或者它们是否适用于我的情况。我需要执行哪些具体步骤或命令选项才能/home获得 64GB 空间?谢谢。

相关内容