1、虛擬化平臺虛擬機添加硬碟
系統查看添加的硬碟
[root@yumserver ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 50G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 49G 0 part
├─centos-root 253:0 0 44G 0 lvm /
└─centos-swap 253:1 0 5G 0 lvm [SWAP]
sr0 11:0 1 4.4G 0 rom
|
如果沒有顯示出來新加的硬碟,則執行下面命令
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
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 50G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 49G 0 part
├─centos-root 253:0 0 44G 0 lvm /
└─centos-swap 253:1 0 5G 0 lvm [SWAP]
sdb 8:16 0 50G 0 disk
sr0 11:0 1 4.4G 0 rom
|
2、parted將sdb磁區
[root@yumserver ~]# parted /dev/sdb
GNU Parted 3.1
使用 /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel gpt
(parted) mkpart primary 0% 100%
(parted) p
Model: VMware Virtual disk (scsi)
Disk /dev/sdb: 53.7GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name 標志
1 1049kB 53.7GB 53.7GB primary
(parted) q
資訊: You may need to update /etc/fstab.
[root@yumserver ~]#
|
再次查看,發現主磁區sdb1出現了
[root@yumserver ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 50G 0 disk
├─sda1 8:1 0 500M 0 part /boot
└─sda2 8:2 0 49.5G 0 part
├─centos-root 253:0 0 47.5G 0 lvm /
└─centos-swap 253:1 0 2G 0 lvm [SWAP]
sdb 8:16 0 50G 0 disk
└─sdb1 8:17 0 50G 0 part
sr0 11:0 1 1024M 0 rom
[root@yumserver ~]#
|
3 、查看現有vg,lv,確定擴容
[root@yumserver ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 centos lvm2 a-- <49.51g 0
[root@yumserver ~]# vgs
VG #PV #LV #SN Attr VSize VFree
centos 1 2 0 wz--n- <49.51g 0
[root@yumserver ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root centos -wi-ao---- <47.51g
swap centos -wi-ao---- 2.00g
[root@yumserver ~]#
|
4、分別創建pv,擴容vg,擴容lv,擴容檔案系統
##此處發現不能tab補全命令, yum install -y bash-completion
[root@yumserver ~]# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created.
|
[root@yumserver ~]# vgextend centos /dev/sdb1
Volume group "centos" successfully extended
|
[root@yumserver ~]# lvextend /dev/centos/root -l +100%FREE
Size of logical volume centos/root changed from <47.51 GiB (12162 extents) to 97.50 GiB (24961 extents).
Logical volume centos/root successfully resized.
|
查看檔案系統
[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
檔案系統 容量 已用 可用 已用% 掛載點
devtmpfs 3.9G 0 3.9G 0% /dev
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 3.9G 8.9M 3.9G 1% /run
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/mapper/centos-root 98G 1.4G 97G 2% /
/dev/sda1 497M 143M 354M 29% /boot
tmpfs 783M 0 783M 0% /run/user/0
|
轉載:http://blog.itpub.net/70004783/viewspace-2790155/
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/549201.html
標籤:其他
上一篇:你是不是暴露了?
