리눅스
VMware ESXi에서 VM 디스크 용량을 확장하고 우분투에서 루트 XFS 볼륨을 확장하는 방법
변군이글루
2025. 9. 15. 13:12
반응형
VMware ESXi에서 VM 디스크 용량을 확장하고 우분투에서 루트 XFS 볼륨을 확장하는 방법
테스트 환경
$ lsb_release -d
Description: Ubuntu 22.04.3 LTS
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 40G 0 disk
└─sda3 8:3 0 39G 0 part
└─vg0-lv--0 253:0 0 39G 0 lvm /
VMware ESXi에서 VM 디스크 확장
1. vSphere Client 접속 → VM 선택
2. Edit Settings → Hard disk → 원하는 크기만큼 확장 (예: 40GB → 100GB 추가해서 140GB로)
VM에서 디스크 인식 확인
더보기
---
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 40G 0 disk
├─sda1 8:1 0 1M 0 part
├─sda2 8:2 0 1G 0 part /boot
└─sda3 8:3 0 39G 0 part
└─vg0-lv--0 253:0 0 39G 0 lvm /
sr0 11:0 1 1.4G 0 rom
$ fdisk -l /dev/sda
Disk /dev/sda: 40 GiB, 42949672960 bytes, 83886080 sectors
Disk model: Virtual disk
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: B82C4EB4-52E6-4EB9-9EB5-90234AB2A086
Device Start End Sectors Size Type
/dev/sda1 2048 4095 2048 1M BIOS boot
/dev/sda2 4096 2101247 2097152 1G Linux filesystem
/dev/sda3 2101248 83884031 81782784 39G Linux filesystem
OS가 새 용량을 못 보이면 rescan
echo 1 | sudo tee /sys/class/block/sda/device/rescan
현재 디스크 확인
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 140G 0 disk
├─sda1 8:1 0 1M 0 part
├─sda2 8:2 0 1G 0 part /boot
└─sda3 8:3 0 39G 0 part
└─vg0-lv--0 253:0 0 39G 0 lvm /
sr0 11:0 1 1.4G 0 rom
$ fdisk -l /dev/sda
GPT PMBR size mismatch (83886079 != 293601279) will be corrected by write.
The backup GPT table is not on the end of the device.
Disk /dev/sda: 140 GiB, 150323855360 bytes, 293601280 sectors
Disk model: Virtual disk
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: B82C4EB4-52E6-4EB9-9EB5-90234AB2A086
Device Start End Sectors Size Type
/dev/sda1 2048 4095 2048 1M BIOS boot
/dev/sda2 4096 2101247 2097152 1G Linux filesystem
/dev/sda3 2101248 83884031 81782784 39G Linux filesystem
parted로 GPT 테이블 재생성
- 파티션 툴로 GPT 테이블을 새 디스크 크기에 맞게 업데이트
parted /dev/sda
(parted) print
(parted) fix
(parted) quit
$ sudo parted /dev/sda
GNU Parted 3.4
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
Warning: Not all of the space available to /dev/sda appears to be used, you can fix the GPT to use all of the space (an extra 209715200 blocks) or continue with
the current setting?
Fix/Ignore? Fix
Model: VMware Virtual disk (scsi)
Disk /dev/sda: 150GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 2097kB 1049kB bios_grub
2 2097kB 1076MB 1074MB xfs
3 1076MB 42.9GB 41.9GB
---
lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 140G 0 disk
├─sda1 8:1 0 1M 0 part
├─sda2 8:2 0 1G 0 part /boot
└─sda3 8:3 0 39G 0 part
└─vg0-lv--0 253:0 0 39G 0 lvm /
sr0 11:0 1 1.4G 0 rom
fdisk -l /dev/sda
Disk /dev/sda: 140 GiB, 150323855360 bytes, 293601280 sectors
Disk model: Virtual disk
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: B82C4EB4-52E6-4EB9-9EB5-90234AB2A086
Device Start End Sectors Size Type
/dev/sda1 2048 4095 2048 1M BIOS boot
/dev/sda2 4096 2101247 2097152 1G Linux filesystem
/dev/sda3 2101248 83884031 81782784 39G Linux filesystem
growpart 설치
더보기
---
cloud-guest-utils 패키지 설치
sudo apt install -y cloud-guest-utils
---
728x90
파티션 확장(growpart)
- 3은 /dev/sda3 → LVM PV 파티션 번호
growpart /dev/sda 3
CHANGED: partition=3 start=2101248 old: size=81782784 end=83884032 new: size=291499999 end=293601247
PV(Physical Volume) 확장
PV 크기 확인
pvdisplay
--- Physical volume ---
PV Name /dev/sda3
VG Name vg0
PV Size <139.00 GiB / not usable 16.50 KiB
Allocatable yes
PE Size 4.00 MiB
Total PE 35583
Free PE 25600
Allocated PE 9983
PV UUID dEHB35-CcsZ-ckHs-911H-6NR9-rtud-ZH2ESA
pvresize /dev/sda3
Physical volume "/dev/sda3" changed
1 physical volume(s) resized or updated / 0 physical volume(s) not resized
LV(Logical Volume) 확장
루트 LV 이름 확인
lvdisplay
--- Logical volume ---
LV Path /dev/vg0/lv-0
LV Name lv-0
VG Name vg0
LV UUID 7QsAeb-IWoZ-Ecy1-6fWU-45jW-1r5T-6olYUJ
LV Write Access read/write
LV Creation host, time ubuntu-server, 2023-11-29 13:58:38 +0900
LV Status available
# open 1
LV Size <39.00 GiB
Current LE 9983
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
루트 LV 확장(남은 공간 전부 루트 볼륨에 할당)
lvextend -l +100%FREE /dev/vg0/lv-0
Size of logical volume vg0/lv-0 changed from <39.00 GiB (9983 extents) to <139.00 GiB (35583 extents).
Logical volume vg0/lv-0 successfully resized.
$ lvdisplay
--- Logical volume ---
LV Path /dev/vg0/lv-0
LV Name lv-0
VG Name vg0
LV UUID 7QsAeb-IWoZ-Ecy1-6fWU-45jW-1r5T-6olYUJ
LV Write Access read/write
LV Creation host, time ubuntu-server, 2023-11-29 13:58:38 +0900
LV Status available
# open 1
LV Size <139.00 GiB
Current LE 35583
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
XFS 파일시스템 확장
xfs_growfs /
meta-data=/dev/mapper/vg0-lv--0 isize=512 agcount=4, agsize=2555648 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1 bigtime=0 inobtcount=0
data = bsize=4096 blocks=10222592, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=4991, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 10222592 to 36436992
확인
df -Th | grep -v tmpfs
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/vg0-lv--0 xfs 139G 40G 100G 29% /
/dev/sda2 xfs 1014M 293M 722M 29% /boot
728x90
반응형