0.在不重啟服務器的前提下找到新加的磁盤
--查看主機總線號
ls /sys/class/scsi_host/
--根據查詢結果生成刷新磁盤語句
echo "- - -" > /sys/class/scsi_host/host0/scan
echo "- - -" > /sys/class/scsi_host/host1/scan
echo "- - -" > /sys/class/scsi_host/host2/scan
。。。
echo "- - -" > /sys/class/scsi_host/host30/scan -- 一定寫到上一查詢語句查詢到的最后的總線號
--再次查看是否能看到新磁盤
fdisk -l
1.給新磁盤分區
fdisk /dev/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.
##輸入p查看磁盤當前的分區
Command (m for help): p
Disk /dev/sdl: 5368 MB, 5368709120 bytes, 10485760 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xbd2e29cb
##如下空行表示目前該磁盤未創建分區
Device Boot Start End Blocks Id System
##輸入n創建分區
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
##輸入p表示創建主分區(需注意一個物理磁盤若都為主分區的話,最多創建四個分區,可在創建第四個分區時指定為擴展分區)
Select (default p): p
##輸入分區序號,默認為最小序號
Partition number (1-4, default 1):
##輸入分區的開始扇區,默認為磁盤未使用空間的最小扇區
First sector (2048-10485759, default 2048): 如不知道填什么,就按回車
Using default value 2048
##輸入分區的結束扇區,默認為連續空間的最大扇區
Last sector, +sectors or +size{K,M,G} (2048-10485759, default 10485759): 如不知道填什么,就按回車
Using default value 10485759
Partition 1 of type Linux and of size 5 GiB is set
##分區完畢后輸入w進行分區保存
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
2.查看新分區是否成功
fdisk -l /dev/sdb
3.創建物理卷
pvcreate /dev/sdb1
4.查看組空間
pvdisplay
找到服務器原有的組名稱 vg_opc
5.將創建的物理卷/dev/sdb1加到指定的組空間中 vg_opc
vgextend vg_opc /dev/sdb1
6.再次查看組空間
pvdisplay
新的分區應該屬於歷史的中已存的VG
7.查看卷組空間情況 vgdisplay
查看是否有新空間
8.擴展指定卷的空間
先df -h查出卷名
lvresize -L +2G /dev/mapper/vg_opc-vg_root
9.使擴展分區有效
resize2fs /dev/mapper/vg_opc-vg_root
10.驗證空間是否加上
df -h