vmware安装centos7磁盘扩容
虚拟机设置中点击扩展,并增加磁盘

进入虚拟机后:
1. 找到未使用的磁盘
df -hT,目前是1T的空间
文件系统 类型 容量 已用 可用 已用% 挂载点devtmpfs devtmpfs 7.8G 0 7.8G 0% /devtmpfs tmpfs 7.8G 0 7.8G 0% /dev/shmtmpfs tmpfs 7.8G 8.9M 7.8G 1% /runtmpfs tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup/dev/mapper/centos-root xfs 965G 85G 881G 9% //dev/sda1 xfs 1014M 188M 827M 19% /boot/dev/mapper/centos-home xfs 50G 33M 50G 1% /hometmpfs tmpfs 1.6G 0 1.6G 0% /run/user/0 |
fdisk -l
磁盘是2T的容量
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
磁盘 /dev/sda:2199.0 GB, 2199023255552 字节,4294967296 个扇区Units = 扇区 of 1 * 512 = 512 bytes扇区大小(逻辑/物理):512 字节 / 512 字节I/O 大小(最小/最佳):512 字节 / 512 字节磁盘标签类型:dos磁盘标识符:0x000b948d 设备 Boot Start End Blocks Id System/dev/sda1 * 2048 2099199 1048576 83 Linux/dev/sda2 2099200 2147483647 1072692224 8e Linux LVM磁盘 /dev/mapper/centos-root:1036.3 GB, 1036286689280 字节,2023997440 个扇区Units = 扇区 of 1 * 512 = 512 bytes扇区大小(逻辑/物理):512 字节 / 512 字节I/O 大小(最小/最佳):512 字节 / 512 字节磁盘 /dev/mapper/centos-swap:8455 MB, 8455716864 字节,16515072 个扇区Units = 扇区 of 1 * 512 = 512 bytes扇区大小(逻辑/物理):512 字节 / 512 字节I/O 大小(最小/最佳):512 字节 / 512 字节磁盘 /dev/mapper/centos-home:53.7 GB, 53687091200 字节,104857600 个扇区Units = 扇区 of 1 * 512 = 512 bytes扇区大小(逻辑/物理):512 字节 / 512 字节I/O 大小(最小/最佳):512 字节 / 512 字节 |
2. 新建分区
fdisk /dev/sda
然后输入m->n->p->回车->回车->回车->w
然后重起机器 reboot
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
WARNING: The size of this disk is 2.2 TB (2199023255552 bytes).DOS partition table format can not be used on drives for volumeslarger than (2199023255040 bytes) for 512-byte sectors. Use parted(1) and GUIDpartition table format (GPT).欢迎使用 fdisk (util-linux 2.23.2)。更改将停留在内存中,直到您决定将更改写入磁盘。使用写入命令前请三思。命令(输入 m 获取帮助):m命令操作 a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition g create a new empty GPT partition table G create an IRIX (SGI) partition table l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only)命令(输入 m 获取帮助):nPartition type: p primary (2 primary, 0 extended, 2 free) e extendedSelect (default p): p分区号 (3,4,默认 3):起始 扇区 (2147483648-4294967295,默认为 2147483648):将使用默认值 2147483648Last 扇区, +扇区 or +size{K,M,G} (2147483648-4294967294,默认为 4294967294):将使用默认值 4294967294分区 3 已设置为 Linux 类型,大小设为 1024 GiB命令(输入 m 获取帮助):wThe partition table has been altered!Calling ioctl() to re-read partition table.WARNING: Re-reading the partition table failed with error 16: 设备或资源忙.The kernel still uses the old table. The new table will be used atthe next reboot or after you run partprobe(8) or kpartx(8)正在同步磁盘。 |
可以看到,新的分区号是3
3. 对分区进行格式化,格式化后的文件系统也是xfs格式
fdisk -l,可以看到新的分区号是3
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
磁盘 /dev/sda:2199.0 GB, 2199023255552 字节,4294967296 个扇区Units = 扇区 of 1 * 512 = 512 bytes扇区大小(逻辑/物理):512 字节 / 512 字节I/O 大小(最小/最佳):512 字节 / 512 字节磁盘标签类型:dos磁盘标识符:0x000b948d 设备 Boot Start End Blocks Id System/dev/sda1 * 2048 2099199 1048576 83 Linux/dev/sda2 2099200 2147483647 1072692224 8e Linux LVM/dev/sda3 2147483648 4294967294 1073741823+ 83 Linux磁盘 /dev/mapper/centos-root:1036.3 GB, 1036286689280 字节,2023997440 个扇区Units = 扇区 of 1 * 512 = 512 bytes扇区大小(逻辑/物理):512 字节 / 512 字节I/O 大小(最小/最佳):512 字节 / 512 字节磁盘 /dev/mapper/centos-swap:8455 MB, 8455716864 字节,16515072 个扇区Units = 扇区 of 1 * 512 = 512 bytes扇区大小(逻辑/物理):512 字节 / 512 字节I/O 大小(最小/最佳):512 字节 / 512 字节磁盘 /dev/mapper/centos-home:53.7 GB, 53687091200 字节,104857600 个扇区Units = 扇区 of 1 * 512 = 512 bytes扇区大小(逻辑/物理):512 字节 / 512 字节I/O 大小(最小/最佳):512 字节 / 512 字节 |
对/dev/sda3进行格式化
mkfs.xfs /dev/sda3
|
1
2
3
4
5
6
7
8
9
|
meta-data=/dev/sda3 isize=512 agcount=4, agsize=67108864 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0, sparse=0data = bsize=4096 blocks=268435455, imaxpct=25 = sunit=0 swidth=0 blksnaming =version 2 bsize=4096 ascii-ci=0 ftype=1log =internal log bsize=4096 blocks=131071, version=2 = sectsz=512 sunit=0 blks, lazy-count=1realtime =none extsz=4096 blocks=0, rtextents=0 |
4. 创建pv
pvcreate /dev/sda3
然后输入y
|
1
2
3
|
WARNING: xfs signature detected on /dev/sda3 at offset 0. Wipe it? [y/n]: y Wiping xfs signature on /dev/sda3. Physical volume "/dev/sda3" successfully created. |
5. 处理逻辑卷
vgs
|
1
2
|
VG #PV #LV #SN Attr VSize VFreecentos 1 3 0 wz--n- <1023.00g 4.00m |
vgextend centos /dev/sda3
|
1
|
Volume group "centos" successfully extended |
vgs
|
1
2
|
VG #PV #LV #SN Attr VSize VFreecentos 2 3 0 wz--n- <2.00t 1.00t |
可以看到由原来的1023G变成了2T。其中1T是空闲的
df -h
查看要扩容的文件系统的位置 ,这是是/dev/mapper/centos-root
|
1
2
3
4
5
6
7
8
9
|
文件系统 容量 已用 可用 已用% 挂载点devtmpfs 7.8G 0 7.8G 0% /devtmpfs 7.8G 0 7.8G 0% /dev/shmtmpfs 7.8G 8.9M 7.8G 1% /runtmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup/dev/mapper/centos-root 965G 85G 881G 9% //dev/sda1 1014M 188M 827M 19% /boot/dev/mapper/centos-home 50G 33M 50G 1% /hometmpfs 1.6G 0 1.6G 0% /run/user/0 |
lvextend -l +100%free /dev/mapper/centos-root
|
1
2
|
Size of logical volume centos/root changed from <965.12 GiB (247070 extents) to 1.94 TiB (509214 extents).Logical volume centos/root successfully resized. |
6. 扩容,调整分区
xfs_growfs /dev/mapper/centos-root
|
1
2
3
4
5
6
7
8
9
10
|
meta-data=/dev/mapper/centos-root isize=512 agcount=4, agsize=63249920 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0 spinodes=0data = bsize=4096 blocks=252999680, imaxpct=25 = sunit=0 swidth=0 blksnaming =version 2 bsize=4096 ascii-ci=0 ftype=1log =internal bsize=4096 blocks=123535, version=2 = sectsz=512 sunit=0 blks, lazy-count=1realtime =none extsz=4096 blocks=0, rtextents=0data blocks changed from 252999680 to 521435136 |
df -h
扩容成功
|
1
2
3
4
5
6
7
8
9
|
文件系统 容量 已用 可用 已用% 挂载点devtmpfs 7.8G 0 7.8G 0% /devtmpfs 7.8G 0 7.8G 0% /dev/shmtmpfs 7.8G 8.9M 7.8G 1% /runtmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup/dev/mapper/centos-root 2.0T 85G 1.9T 5% //dev/sda1 1014M 188M 827M 19% /boot/dev/mapper/centos-home 50G 33M 50G 1% /hometmpfs 1.6G 0 1.6G 0% /run/user/0 |
有疑问加w,dreamingmymoon

浙公网安备 33010602011771号