一、扩展VMWare硬盘空间
关闭Vmware 的 Linux系统,这样,才能在VMWare菜单中设置:
VM -> Settings... -> Hardware -> Hard Disk -> Utilities -> Expand
输入你想要扩展到多少G。
二、对新增加的硬盘进行分区、格式化
查看挂载点
# df -Th
[root@localhost ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/centos-root xfs 15G .2G 14G % /
devtmpfs devtmpfs .9G .9G % /dev
tmpfs tmpfs .9G .9G % /dev/shm
tmpfs tmpfs .9G 8.6M .9G % /run
tmpfs tmpfs .9G .9G % /sys/fs/cgroup
/dev/sda1 xfs 197M 110M 88M % /boot
tmpfs tmpfs 378M 378M % /run/user/
查看硬盘信息
# lsblk
[root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda : 150G disk
├─sda1 : 200M part /boot
└─sda2 : 17G part
├─centos-root : 15G lvm /
└─centos-swap : 2G lvm [SWAP]
sr0 : 4G rom
查看逻辑卷
# lvs
[root@localhost ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root centos -wi-ao---- .00g
swap centos -wi-ao---- .00g
对扩容的硬盘进行分区
# fdisk /dev/sda
Welcome to fdisk (util-linux 2.23.). Changes will remain in memory only, until you decide to write them.
Be careful before using the write command. Command (m for help): n
Partition type:
p primary ( primary, extended, free)
e extended
Select (default p): p
Partition number (,, default ):
First sector (-, default ):
Using default value
Last sector, +sectors or +size{K,M,G} (-, default ): +100G
Partition of type Linux and of size GiB is set Command (m for help): p Disk /dev/sda: 161.1 GB, bytes, sectors
Units = sectors of * = bytes
Sector size (logical/physical): bytes / bytes
I/O size (minimum/optimal): bytes / bytes
Disk label type: dos
Disk identifier: 0x00007397 Device Boot Start End Blocks Id System
/dev/sda1 * Linux
/dev/sda2 8e Linux LVM
/dev/sda3 Linux Command (m for help): t
Partition number (-, default ):
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM' Command (m for help): p Disk /dev/sda: 161.1 GB, bytes, sectors
Units = sectors of * = bytes
Sector size (logical/physical): bytes / bytes
I/O size (minimum/optimal): bytes / bytes
Disk label type: dos
Disk identifier: 0x00007397 Device Boot Start End Blocks Id System
/dev/sda1 * Linux
/dev/sda2 8e Linux LVM
/dev/sda3 8e Linux LVM Command (m for help): w
The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
需要重启才能生效
#reboot
重启后查看硬盘信息
# lsblk
[root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda : 150G disk
├─sda1 : 200M part /boot
├─sda2 : 17G part
│ ├─centos-root : 15G lvm /
│ └─centos-swap : 2G lvm [SWAP]
└─sda3 8:3 0 100G 0 part
sr0 : 4G rom
分区格式化
# mkfs -t ext4 /dev/sda3
[root@localhost ~]# mkfs -t ext4 /dev/sda3
mke2fs 1.42. (-Dec-)
Filesystem label=
OS type: Linux
Block size= (log=)
Fragment size= (log=)
Stride= blocks, Stripe width= blocks
inodes, blocks
blocks (5.00%) reserved for the super user
First data block=
Maximum filesystem blocks=
block groups
blocks per group, fragments per group
inodes per group
Superblock backups stored on blocks:
, , , , , , , , ,
, , , , Allocating group tables: done
Writing inode tables: done
Creating journal ( blocks): done
Writing superblocks and filesystem accounting information: done
创建物理卷
#pvcreate /dev/sda3
[root@localhost ~]# pvcreate /dev/sda3
WARNING: xfs signature detected on /dev/sda3 at offset . Wipe it? [y/n]: y
Wiping xfs signature on /dev/sda3.
Physical volume "/dev/sda3" successfully created
加入根分区的逻辑卷组
# vgextend centos /dev/sda3
[root@localhost ~]# vgextend centos /dev/sda3
Volume group "centos" successfully extended
查看确认
[root@localhost ~]# vgdisplay
--- Volume group ---
VG Name centos
System ID
Format lvm2
Metadata Areas
Metadata Sequence No
VG Access read/write
VG Status resizable
MAX LV
Cur LV
Open LV
Max PV
Cur PV
Act PV
VG Size 117.00 GiB
PE Size 4.00 MiB
Total PE
Alloc PE / Size / 17.00 GiB
Free PE / Size / 100.00 GiB
VG UUID a27Boi-C0ue-9PCo-1rPZ-BsjW-9IRg-Woh4uX
扩容
# lvextend -L +100G /dev/centos/root
[root@localhost ~]# lvextend -L +100G /dev/centos/root
Size of logical volume centos/root changed from 15.00 GiB ( extents) to 115.00 GiB ( extents).
Logical volume root successfully resized.
操作生效
# xfs_growfs /dev/centos/root
[root@localhost ~]# xfs_growfs /dev/centos/root
meta-data=/dev/mapper/centos-root isize= agcount=, agsize= blks
= sectsz= attr=, projid32bit=
= crc= finobt=
data = bsize= blocks=, imaxpct=
= sunit= swidth= blks
naming =version bsize= ascii-ci= ftype=
log =internal bsize= blocks=, version=
= sectsz= sunit= blks, lazy-count=
realtime =none extsz= blocks=, rtextents=
data blocks changed from to
查看是否成功扩容
# df -Th
[root@localhost ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/centos-root xfs 115G .2G 114G % /
devtmpfs devtmpfs .9G .9G % /dev
tmpfs tmpfs .9G .9G % /dev/shm
tmpfs tmpfs .9G 8.6M .9G % /run
tmpfs tmpfs .9G .9G % /sys/fs/cgroup
/dev/sda1 xfs 197M 110M 88M % /boot
tmpfs tmpfs 378M 378M % /run/user/
# vgdisplay
[root@localhost ~]# vgdisplay
--- Volume group ---
VG Name centos
System ID
Format lvm2
Metadata Areas
Metadata Sequence No
VG Access read/write
VG Status resizable
MAX LV
Cur LV
Open LV
Max PV
Cur PV
Act PV
VG Size 117.00 GiB
PE Size 4.00 MiB
Total PE
Alloc PE / Size / 117.00 GiB
Free PE / Size /
VG UUID a27Boi-C0ue-9PCo-1rPZ-BsjW-9IRg-Woh4uX
参考博客:
Linux中VMware虚拟机增加磁盘空间的扩容操作
https://www.cnblogs.com/matengfei123/p/7986259.html
给VMware下的Linux扩展磁盘空间(以CentOS6.5为例)
https://www.cnblogs.com/shijiaoyun/p/6207699.html
end