由于虚拟机创建是磁盘分配太小,想扩展根目录大小
默认磁盘根分区格式为LVM
虚拟机扩充磁盘
两种方式,拓展原来的磁盘或者新加磁盘
拓展原来磁盘
添加新磁盘
一直下一步就行
对磁盘分区
fdisk /dev/sdb
n → p → 3->+20480M->回车
t->3->8e->w
[root@localhost ~]# fdisk /dev/sdb (对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 0x1d8e6d7e.
Command (m for help): n (新建分区)
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1): 1 (新建主分区1)
First sector (2048-6291455, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-6291455, default 6291455):
Using default value 6291455
Partition 1 of type Linux and of size 3 GiB is set
Command (m for help): t (修改分区格式为lvm)
Selected partition 1
Hex code (type L to list all codes): 8e (8e为lvm格式标志)
Changed type of partition 'Linux' to 'Linux LVM'
Command (m for help): w (保存)
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
拓展大小
查看磁盘情况
[root@localhost ~]# fdisk -l
创建物理卷
[root@localhost ~]# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created.
更新分区信息
[root@localhost ~]# partprobe /dev/sdb
查看lvm的逻辑卷信息
[root@localhost ~]# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name centos (磁盘组信息)
PV Size <19.00 GiB / not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 4863
Free PE 0
Allocated PE 4863
PV UUID QcuftQ-voFx-HA8e-EGKW-2y0k-REbA-1pHjxF
"/dev/sdb1" is a new physical volume of "<3.00 GiB"
--- NEW Physical volume ---
PV Name /dev/sdb1
VG Name (新建磁盘信息)
PV Size <3.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID 88IgmA-T5sa-kmJw-gSSm-Gz8X-xTuq-wzycwa
将刚创建的物理卷/dev/sdb1添加到卷组中
[root@localhost ~]# vgextend centos /dev/sdb1
Volume group "centos" successfully extended
查看
[root@localhost ~]# pvdisplay
拓展
将卷组的3GB扩展给根所在的逻辑卷
[root@redhat6-3 ~]# lvextend -L +3G/dev/mapper/centos-root
更新信息
xfs文件系统使用下面命令
xfs_growfs /dev/mapper/centos-root
查看系统情况
[root@localhost ~]# df -h