1.我這里的新磁盤是sdb
[root@cct ~]# fdisk /dev/sdb
2.劃分磁盤
[root@cct ~]# fdisk /dev/sdb
歡迎使用 fdisk (util-linux 2.23.2)。
更改將停留在內(nèi)存中,直到您決定將更改寫入磁盤块促。
使用寫入命令前請三思磺送。
Device does not contain a recognized partition table
使用磁盤標(biāo)識符 0xc736e68c 創(chuàng)建新的 DOS 磁盤標(biāo)簽崎脉。
命令(輸入 m 獲取幫助):n
Partition type:
? p? primary (0 primary, 0 extended, 4 free)
? e? extended
Select (default p): p
分區(qū)號 (1-4谭跨,默認(rèn) 1):1
起始 扇區(qū) (2048-20971519丽声,默認(rèn)為 2048):
將使用默認(rèn)值 2048
Last 扇區(qū), +扇區(qū) or +size{K,M,G} (2048-20971519蜕衡,默認(rèn)為 20971519):
將使用默認(rèn)值 20971519
分區(qū) 1 已設(shè)置為 Linux 類型壤短,大小設(shè)為 10 GiB
命令(輸入 m 獲取幫助):w
The partition table has been altered!
Calling ioctl() to re-read partition table.
正在同步磁盤。
3.查看磁盤
[root@centos ~]# lsblk
NAME? ? ? ? ? ? MAJ:MIN RM? SIZE RO TYPE MOUNTPOINT
sda? ? ? ? ? ? ? 8:0? ? 0? 20G? 0 disk
├─sda1? ? ? ? ? ? 8:1? ? 0? ? 1G? 0 part /boot
└─sda2? ? ? ? ? ? 8:2? ? 0? 19G? 0 part
? ├─centos-root 253:0? ? 0? 17G? 0 lvm? /
? └─centos-swap 253:1? ? 0? ? 2G? 0 lvm? [SWAP]
sdb? ? ? ? ? ? ? 8:16? 0? 10G? 0 disk
└─sdb1? ? ? ? ? ? 8:17? 0? 10G? 0 part
sr0? ? ? ? ? ? ? 11:0? ? 1? 4.2G? 0 rom?
4.格式化分區(qū)?
可以根據(jù)/etc/fstab判斷根分區(qū)的格式,我的格式為xfs格式
[root@centos ~]mkfs.xfs /dev/sdb1
到此為止慨仿,我們就新建了一個分區(qū)/dev/sdb1
基于LVM擴(kuò)展根分區(qū)
[root@centos ~]# lvs
? LV? VG? ? Attr? ? ? LSize? Pool Origin Data%? Meta%? Move Log Cpy%Sync Convert
? root centos -wi-ao---- <17.00g? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? swap centos -wi-ao----? 2.00g
[root@centos ~]# vgextend centos /dev/sdb1
? Volume group "centos" successfully extended
[root@centos ~]# vgdisplay
? --- Volume group ---
? VG Name? ? ? ? ? ? ? centos
? System ID? ? ? ? ? ?
? Format? ? ? ? ? ? ? ? lvm2
? Metadata Areas? ? ? ? 2
? Metadata Sequence No? 4
? VG Access? ? ? ? ? ? read/write
? VG Status? ? ? ? ? ? resizable
? MAX LV? ? ? ? ? ? ? ? 0
? Cur LV? ? ? ? ? ? ? ? 2
? Open LV? ? ? ? ? ? ? 2
? Max PV? ? ? ? ? ? ? ? 0
? Cur PV? ? ? ? ? ? ? ? 2
? Act PV? ? ? ? ? ? ? ? 2
? VG Size? ? ? ? ? ? ? 28.99 GiB
? PE Size? ? ? ? ? ? ? 4.00 MiB
? Total PE? ? ? ? ? ? ? 7422
? Alloc PE / Size? ? ? 4863 / <19.00 GiB
? Free? PE / Size? ? ? 2559 / <10.00 GiB
? VG UUID? ? ? ? ? ? ? TM6Yvc-JnaA-dOdJ-w2Ru-tXv6-5TeE-wYAUiQ
? [root@centos ~]# lvextend -L +9G /dev/mapper/centos-root
? Size of logical volume centos/root changed from <17.00 GiB (4351 extents) to <26.00 GiB (6655 extents).
? Logical volume centos/root successfully resized.
? ? [root@centos ~]# xfs_growfs /dev/centos/root? ?
一般到這一步?jīng)]什么問題的話就成功了
執(zhí)行 df -h 查看分區(qū)
補(bǔ)充:
xfs_growfs /dev/centos/root久脯,如果是ext4文件系統(tǒng)怎么操作
執(zhí)行resize2fs /dev/centos/root