前提:磁盤已做好raid,格式化,分區(qū)缸兔,創(chuàng)建好文件系統(tǒng)(文件系統(tǒng)和需擴(kuò)容目錄一致ext4...xfs)
1. 查看磁盤空間大小旧找,使用df -h 命令
文件系統(tǒng) 容量 已用 可用 已用% 掛載點(diǎn)
/dev/mapper/cl-root? 69G? 29G? 41G? 42% /
devtmpfs? ? ? ? ? ? 1.9G? ? 0? 1.9G? ? 0% /dev
tmpfs? ? ? ? ? ? ? ? 1.9G? ? 0? 1.9G? ? 0% /dev/shm
tmpfs? ? ? ? ? ? ? ? 1.9G? 33M? 1.9G? ? 2% /run
tmpfs? ? ? ? ? ? ? ? 1.9G? ? 0? 1.9G? ? 0% /sys/fs/cgroup
/dev/sda1? ? ? ? ? ? 197M? 154M? 43M? 79% /boot
/dev/mapper/cl-home? 5.0G? 33M? 5.0G? ? 1% /home
tmpfs? ? ? ? ? ? ? ? 379M? ? 0? 379M? ? 0% /run/user/0
2.使用fdisk -l命令查看磁盤信息溺健。當(dāng)看到第一行Disk /dev/sdb: 161.1 GB與實(shí)際df -h顯示內(nèi)容不符時(shí),說(shuō)明增加磁盤成功
root@ubuntu14:/opt# fdisk -l
Disk /dev/sdb: 161.1 GB, 161061273600 bytes
16 heads, 63 sectors/track, 312076 cylinders, total 314572800 sectors
Units = 扇區(qū) of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/Osize (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0001a023
3. 創(chuàng)建物理卷,使用pvcreate /dev/sdb1?
root@ubuntu14:~# pvcreate /dev/vda4
?Physical volume "/dev/vda4"successfully created? ? ? ? ?表示成功
4.查看新建的物理卷和大小鞭缭,使用pvdisplay
root@ubuntu:~# pvdisplay
? --- Physical volume ---
? PV Name? ? ? ? ? ? ? /dev/sda3
? VG Name? ? ? ? ? ? ? ubuntu-vg
? PV Size? ? ? ? ? ? ? 7.63 TiB / not usable 0?
? Allocatable? ? ? ? ? yes (but full)
? PE Size? ? ? ? ? ? ? 4.00 MiB
? Total PE? ? ? ? ? ? ? 1999313
? Free PE? ? ? ? ? ? ? 0
? Allocated PE? ? ? ? ? 1999313
? PV UUID? ? ? ? ? ? ? bpNHUd-W7lC-0cC7-VHJc-8hCQ-WlbJ-so41WI
? "/dev/sdb1" is a new physical volume of "2.00 TiB"
? --- NEW Physical volume ---
? PV Name? ? ? ? ? ? ? /dev/sdb1
? VG Name? ? ? ? ? ? ?
? PV Size? ? ? ? ? ? ? 2.00 TiB
? Allocatable? ? ? ? ? NO
? PE Size? ? ? ? ? ? ? 0?
? Total PE? ? ? ? ? ? ? 0
? Free PE? ? ? ? ? ? ? 0
? Allocated PE? ? ? ? ? 0
? PV UUID? ? ? ? ? ? ? 713lyL-WqZr-g0Sn-IkoG-RdXG-KrAz-lbqgXI
新建的物理卷不在卷組中剖膳,需添加
4. 將添加新的物理卷,加載到ubuntu-vg卷組岭辣,使用vgextend? ubuntu-vg? /dev/vdb1?
root@ubuntu14:~# vgextend? ubuntu-vg? /dev/sdb1
Volume group "ubuntu-vg"successfully extended
再次pvdisplay 查看吱晒,已添加
5. 查看卷組信息,使用vgdisplay命令沦童。
root@ubuntu:~# vgdisplay
? --- Volume group ---
? VG Name? ? ? ? ? ? ? ubuntu-vg
? 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? ? ? ? ? ? ? 9.63 TiB
? PE Size? ? ? ? ? ? ? 4.00 MiB
? Total PE? ? ? ? ? ? ? 2523600
? Alloc PE / Size? ? ? 1999313 / 7.63 TiB
? Free? PE / Size? ? ? 524287 / 2.00 TiB
? VG UUID? ? ? ? ? ? ? dYs1Nx-XAU7-kKCe-vQM0-XDbM-E1n0-tjFjn1
Free? PE / Size? ? ? 524287 / 2.00 TiB ?可擴(kuò)容大小
6.增加ubuntu-vg大小仑濒,增加2000G。? lvresize? -L +2000G? /dev/mapper/ubuntu--vg-root
root@ubuntu14:~#??lvresize? -L +2000G?/dev/mapper/ubuntu--vg-root
?Extending logical volume root to 147.76 GiB
?Logical volume root successfully resized
11. 重新識(shí)別ubuntu--vg大小偷遗,使用resize2fs /dev/mapper/ubuntu--vg-root命令墩瞳。
root@ubuntu14:~# resize2fs /dev/mapper/ubuntu--vg-root
root@ubuntu:~# resize2fs /dev/mapper/ubuntu--vg-root
resize2fs 1.42.9 (4-Feb-2014)
Filesystem at /dev/mapper/ubuntu--vg-root is mounted on /; on-line resizing required
old_desc_blocks = 473, new_desc_blocks = 598
The filesystem on /dev/mapper/ubuntu--vg-root is now 2504580096 blocks long.
ps:如出現(xiàn)以下情況
resize2fs: Bad magic numberinsuper-block 當(dāng)嘗試打開 /dev/mapper/vg_node003-lv_root時(shí) 找不到有效的文件系統(tǒng)超級(jí)塊
則:xfs_growfs /dev/mapper/vg_node003-lv_root
12.查看擴(kuò)容后的大小 ,使用df -h命令