centos7.X 系统VPS 扩展硬盘
 

[root@cloud ~]# df -hal
文件系统 容量 已用 可用 已用%% 挂载点
/dev/mapper/vg_cloud-lv_root
7.5G 7.5G 0 100% /
proc 0 0 0 - /proc
sysfs 0 0 0 - /sys
devpts 0 0 0 - /dev/pts
tmpfs 494M 0 494M 0% /dev/shm
/dev/sda1 485M 33M 427M 8% /boot
none 0 0 0 - /proc/sys/fs/binfmt_misc
sunrpc 0 0 0 - /var/lib/nfs/rpc_pipefs


[root@cloud wwwroot]# fdisk -l

Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00051f5f

Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 1306 9972736 8e Linux LVM

Disk /dev/sdb: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/vg_cloud-lv_root: 8128 MB, 8128561152 bytes
255 heads, 63 sectors/track, 988 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/vg_cloud-lv_swap: 2080 MB, 2080374784 bytes
255 heads, 63 sectors/track, 252 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000




[root@cloud ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklable
Building a new DOS disklabel with disk identifier 0x3c59d1a9.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): n #新建分区
Command action
e extended
p primary partition (1-4)
p #设置为主分区
Partition number (1-4): 1 #主分区号
First cylinder (1-2610, default 1):1 #开始扇区(直接默认回车)
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610):2610
Using default value 2610 #结束扇区(直接默认回车)
Command (m for help): t #指定分区类型
Selected partition 1 #选择1号分区
Hex code (type L to list codes): 8e #8e为LVM
Changed system type of partition 1 to 8e (Linux LVM)

Command (m for help): w #保存
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@cloud ~]# reboot

======================================================
重启中
======================================================

[root@cloud ~]# vgs
VG #PV #LV #SN Attr VSize VFree
vg_cloud 1 2 0 wz--n- 9.51g 0

[root@cloud ~]# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created

[root@cloud ~]# vgextend centos /dev/sdb1
Volume group "centos" successfully extended

[root@cloud ~]# lvextend -l +100%FREE /dev/centos/root
#等待完成
[root@cloud ~]# xfs_growfs /dev/centos/root
#等待完成,添加成功