虚拟机磁盘空间不够,添加新磁盘后需要如何操作?下面介绍详细的执行方法(纯技术,命令介绍自行查询):
1、分区格式化
[root@test ~]# fdisk /dev/sdc
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-19581, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-19581, default 19581):
Using default value 19581
Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
2、创建LVM
###创建PV
pvcreate /dev/sdc1
Physical volume "/dev/sdc1" successfully created
###创建VG
vgcreate VG01 /dev/sdc1
Volume group "VG01" successfully created
###创建LV
lvcreate -l +100%FREE -n lvData VG01
Logical volume "lvData" created
###格式化LV
mkfs.ext4 /dev/VG01/lvData
mkfs -t xfs /dev/VG01/lvData
3、删除LVM
lvremove /dev/VGdata01/lvData
Do you really want to remove active logical volume lvData? [y/n]: y
Logical volume "lvData" successfully removed
vgremove VGdata01
Volume group "VGdata01" successfully removed
pvremove /dev/sdc1
Labels on physical volume "/dev/sdc1" successfully wiped
4、扩容LVM
pvresize /dev/sda2
pvcreate /dev/hdd1
vgextend VG01 /dev/hdd1 #扩展VG01
lvextend –L 1G /dev/VG01/lvData #扩展LV
lvextend -l +100%FREE /devVG01/lvData
resize2fs /dev/VG01/lv_data
xfs_growfs /dev/VG01/lv_data ##xfs格式分区