1、虚拟化平台虚拟机添加硬盘
系统查看添加的硬盘
[root@yumserver~] #lsblk NAMEMAJ:MINRMSIZEROTYPEMOUNTPOINT sda8:0050G0disk ├─sda18:101G0part /boot └─sda28:2049G0part
├─centos-root253:0044G0lvm/
└─centos-swap253:105G0lvm[SWAP] sr011:014.4G0rom |
如果没有显示出来新加的硬盘,则执行下面命令
echo "---" > /sys/class/scsi_host/host0/scan
echo "---" > /sys/class/scsi_host/host1/scan
echo "---" > /sys/class/scsi_host/host2/scan |
再次查询,发现新添加的sdb已经可以看到了。
[root@yumserver~] #lsblk NAMEMAJ:MINRMSIZEROTYPEMOUNTPOINT sda8:0050G0disk ├─sda18:101G0part /boot └─sda28:2049G0part
├─centos-root253:0044G0lvm/
└─centos-swap253:105G0lvm[SWAP] sdb8:16050G0disk sr011:014.4G0rom |
2、parted将sdb分区
[root@yumserver~] #parted/dev/sdb GNUParted3.1 使用 /dev/sdb WelcometoGNUParted!Type 'help' toviewalistofcommands. (parted)mklabelgpt (parted)mkpartprimary0%100% (parted)p Model:VMwareVirtualdisk(scsi) Disk /dev/sdb :53.7GB Sectorsize(logical /physical ):512B /512B PartitionTable:gpt DiskFlags: NumberStartEndSizeFilesystemName标志
11049kB53.7GB53.7GBprimary (parted)q 信息:Youmayneedtoupdate /etc/fstab . [root@yumserver~] # |
再次查看,发现主分区sdb1出现了
[root@yumserver~] #lsblk NAMEMAJ:MINRMSIZEROTYPEMOUNTPOINT sda8:0050G0disk ├─sda18:10500M0part /boot └─sda28:2049.5G0part
├─centos-root253:0047.5G0lvm/
└─centos-swap253:102G0lvm[SWAP] sdb8:16050G0disk └─sdb18:17050G0part sr011:011024M0rom [root@yumserver~] # |
3、查看现有vg,lv,确定扩容
[root@yumserver~] #pvs
PVVGFmtAttrPSizePFree
/dev/sda2 centoslvm2a--<49.51g0 [root@yumserver~] #vgs
VG #PV#LV#SNAttrVSizeVFree
centos120wz--n-<49.51g0 [root@yumserver~] #lvs
LVVGAttrLSizePoolOriginData%Meta%MoveLogCpy%SyncConvert
rootcentos-wi-ao----<47.51g
swapcentos-wi-ao----2.00g [root@yumserver~] # |
4、分别创建pv,扩容vg,扩容lv,扩容文件系统
##此处发现不能tab补全命令,yum install -y bash-completion
[root@yumserver~] #pvcreate/dev/sdb1
Physicalvolume "/dev/sdb1" successfullycreated. |
[root@yumserver~] #vgextendcentos/dev/sdb1
Volumegroup "centos" successfullyextended |
[root@yumserver~] #lvextend/dev/centos/root-l+100%FREE
Sizeoflogicalvolumecentos /root changedfrom<47.51GiB(12162extents)to97.50GiB(24961extents).
Logicalvolumecentos /root successfullyresized. |
查看文件系统
[root@yumserver~] # df -Th |
xfs 类型,使用 xfs_growfs,此处为xfs
[root@yumserver~] #xfs_growfs/dev/centos/root |
ext 类型,使用 resize2fs
[root@yumserver~] # resize2fs /dev/centos/root |
再次查看,/目录扩容成功
[root@yumserver~] #df-h 文件系统容量已用可用已用%挂载点 devtmpfs3.9G03.9G0% /dev tmpfs3.9G03.9G0% /dev/shm tmpfs3.9G8.9M3.9G1% /run tmpfs3.9G03.9G0% /sys/fs/cgroup /dev/mapper/centos-root 98G1.4G97G2%/ /dev/sda1 497M143M354M29% /boot tmpfs783M0783M0% /run/user/0 |
转载:http://blog.itpub.net/70004783/viewspace-2790155/