CentOS 磁盤空間擴容操作方法

CentOS 磁盤空間擴容操作方法

1、使用命令查看磁盤信息,標紅的爲新增的磁盤空間
在這裏插入圖片描述
需掛載的磁盤空間
2、使用fdisk命令,創建新分區
參考:https://blog.51cto.com/12185273/2048111
root@localhost# fdisk /dev/sdb

命令(輸入 m 獲取幫助): m
命令操作
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)

命令(輸入 m 獲取幫助): n #new 新分區
Partition type:
p primary (1 primary, 1 extended, 2 free)
l logical (numbered from 5)
Select (default p): p #選擇主分區
分區號 (1-4,默認爲 3): 1 #分區序號
起始 sector (499712-314572799,默認爲 499712): #分區開始回車默認
將使用默認值 499712
Last sector, +扇區 or +size{K,M,G} (499712-501757,默認爲 501757): +150G #分配分區空間大小

命令(輸入 m 獲取幫助): t #修改分區格式
分區號 (1-5): 4 #修改分區號
Hex code (type L to list codes): 8e #格式選擇8e linux LVM
Changed system type of partition 4 to 8e (Linux LVM)

命令(輸入 m 獲取幫助): p #顯示分區信息

Disk /dev/sdb: 161.1 GB, 161061273600 bytes
16 heads, 63 sectors/track, 312076 cylinders, total 314572800 sectors
Units = 扇區 of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0001a023

設備 啓動 起點 終點 塊數 Id 系統
/dev/vda1 * 2048 499711 248832 83 Linux
/dev/vda2 501758 62912511 31205377 5 擴展
/dev/vda3 499712 501757 1023 83 Linux
/dev/vda4 62912512 314572799 125830144 8e Linux LVM
/dev/vda5 501760 62912511 31205376 8e Linux LVM
Partition table entries are not in disk order
命令(輸入 m 獲取幫助): w #保存信息
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: 設備或資源忙.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.

3、對/dev/sdb1 進行格式化
注意:這裏是sdb1,不是sdb
mkfs.ext4 /dev/sdb1在這裏插入圖片描述看到done表示格式化完成
4、創建物理卷,使用pvcreate /dev/sdb1命令。
並用命令pvdisplay 查看新建的物理卷信息和大小
在這裏插入圖片描述
5、將添加新的物理卷,加載到卷組 centos 中 (114上卷組名 cl)
使用命令:vgextend centos /dev/sdb1
在這裏插入圖片描述
6、增加邏輯卷 /dev/mappercentos-root 大小,增加500M。(114的邏輯卷名/dev/mapper/cl-root,增加150G)
使用lvresize -L +500M /dev/mapper/dev/mapper/centos-root 命令(114上使用命令:lvresize -L +150G /dev/mapper/cl-root)

在這裏插入圖片描述
7、重新識別 /dev/mappercentos-root 大小
使用xfs_growfs /dev/mappercentos-root命令 (114上命令爲:xfs_growfs /dev/mapper/cl-root)
並查看擴容後的大小 ,使用df -h命令在這裏插入圖片描述
當看到/dev/mappercentos-root 已經更新到新的大小時,則表示增加成功

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章