Linux

在 vsphere 上的 debian7.0 上擴展 ext4 分區

  • June 29, 2013

當我發現 8GB 不足時,我分配了 15GB 的精簡配置。現在 debian guest 無法辨識大小的變化。

root@debian7-x64:~# lvdisplay
--- Logical volume ---
LV Path                /dev/debian7-x64/root
LV Name                root
VG Name                debian7-x64
LV UUID                EU6mg0-XTXC-ci3D-bQJi-7XN6-r8Hp-SYxcj0
LV Write Access        read/write
LV Creation host, time debian7-x64, 2013-06-25 12:02:49 +0530
LV Status              available
# open                 1
LV Size                7.39 GiB
Current LE             1892
Segments               1
Allocation             inherit
Read ahead sectors     auto
- currently set to     256
Block device           254:0

--- Logical volume ---
LV Path                /dev/debian7-x64/swap_1
LV Name                swap_1
VG Name                debian7-x64
LV UUID                xDNtoz-tJUq-M5D6-GGCN-gzcD-fwUv-fYYDR1
LV Write Access        read/write
LV Creation host, time debian7-x64, 2013-06-25 12:02:49 +0530
LV Status              available
# open                 2
LV Size                376.00 MiB
Current LE             94
Segments               1
Allocation             inherit
Read ahead sectors     auto
- currently set to     256
Block device           254:1

root@debian7-x64:~# pvdisplay
--- Physical volume ---
PV Name               /dev/sda5
VG Name               debian7-x64
PV Size               7.76 GiB / not usable 2.00 MiB
Allocatable           yes (but full)
PE Size               4.00 MiB
Total PE              1986
Free PE               0
Allocated PE          1986
PV UUID               SehkzH-Gq8Y-jI2f-27Tb-uv1Z-tR1R-5OnTxR

root@debian7-x64:~# sfdisk -s
/dev/sda:  15728640
/dev/mapper/debian7--x64-root:   7749632
/dev/mapper/debian7--x64-swap_1:    385024
total: 23863296 blocks

幫我擴展這個分區。重啟沒問題。我沒有任何現場CD。

環境:debian 7,帶lvm,在vsphere,e​​xt4分區。可以在需要時提供更多詳細資訊。

步驟是:

  1. 調整物理卷的大小:
# pvresize /dev/sda5
  1. 調整邏輯卷的大小:
# lvresize -L+2GB /dev/mapper/debian7--x64-root
  1. 調整文件系統的大小:
resize2fs /dev/mapper/debian7--x64-root

引用自:https://serverfault.com/questions/518599