Linux磁盤擴容分區根目錄

[root@host-172-16-13-33 ~]# lsblk
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sr0              11:0    1 1024M  0 rom  
vda             252:0    0  100G  0 disk 
├─vda1          252:1    0    1G  0 part /boot
└─vda2          252:2    0   99G  0 part 
  ├─centos-root 253:0    0   50G  0 lvm  /
  ├─centos-swap 253:1    0  3.9G  0 lvm  [SWAP]
  └─centos-home 253:2    0 45.1G  0 lvm  /home
vdb             252:16   0  400G  0 disk 
[root@host-172-16-13-33 ~]# fdisk /dev/vdb
歡迎使用 fdisk (util-linux 2.23.2)。

更改將停留在內存中,直到您決定將更改寫入磁盤。
使用寫入命令前請三思。

Device does not contain a recognized partition table
使用磁盤標識符 0x5fd33ee7 創建新的 DOS 磁盤標籤。

命令(輸入 m 獲取幫助):n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): 
Using default response p
分區號 (1-4,默認 1):
起始 扇區 (2048-838860799,默認爲 2048):
將使用默認值 2048
Last 扇區, +扇區 or +size{K,M,G} (2048-838860799,默認爲 838860799):
將使用默認值 838860799
分區 1 已設置爲 Linux 類型,大小設爲 400 GiB

命令(輸入 m 獲取幫助):w
The partition table has been altered!

Calling ioctl() to re-read partition table.
正在同步磁盤。
[root@host-172-16-13-33 ~]# vgs
  VG     #PV #LV #SN Attr   VSize   VFree
  centos   1   3   0 wz--n- <99.00g 4.00m
[root@host-172-16-13-33 ~]# vgextend centos /dev/vdb1
  Physical volume "/dev/vdb1" successfully created.
  Volume group "centos" successfully extended
[root@host-172-16-13-33 ~]# vgs
  VG     #PV #LV #SN Attr   VSize   VFree  
  centos   2   3   0 wz--n- 498.99g 400.00g
[root@host-172-16-13-33 ~]#  lvextend /dev/centos/root -L +400G
  Size of logical volume centos/root changed from 50.00 GiB (12800 extents) to 450.00 GiB (115200 extents).
  Logical volume centos/root successfully resized.
[root@host-172-16-13-33 ~]# xfs_growfs /
meta-data=/dev/mapper/centos-root isize=512    agcount=4, agsize=3276800 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=13107200, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=6400, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 13107200 to 117964800
[root@host-172-16-13-33 ~]# df -lh
文件系統                 容量  已用  可用 已用% 掛載點
/dev/mapper/centos-root  450G  1.3G  449G    1% /
devtmpfs                 1.9G     0  1.9G    0% /dev
tmpfs                    1.9G     0  1.9G    0% /dev/shm
tmpfs                    1.9G   11M  1.9G    1% /run
tmpfs                    1.9G     0  1.9G    0% /sys/fs/cgroup
/dev/vda1               1014M  165M  850M   17% /boot
/dev/mapper/centos-home   46G   33M   46G    1% /home
tmpfs                    378M     0  378M    0% /run/user/0
[root@host-172-16-13-33 ~]# df -lh
文件系統                 容量  已用  可用 已用% 掛載點
/dev/mapper/centos-root  450G  1.3G  449G    1% /
devtmpfs                 1.9G     0  1.9G    0% /dev
tmpfs                    1.9G     0  1.9G    0% /dev/shm
tmpfs                    1.9G   11M  1.9G    1% /run
tmpfs                    1.9G     0  1.9G    0% /sys/fs/cgroup
/dev/vda1               1014M  165M  850M   17% /boot
/dev/mapper/centos-home   46G   33M   46G    1% /home
tmpfs                    378M     0  378M    0% /run/user/0
[root@host-172-16-13-33 ~]#

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