리눅스 파티션 확장

리눅스 파티션 확장

LVM

디스크 상태 확인

lsblk
sda                         8:0    0  500G  0 disk 
├─sda1                      8:1    0    1M  0 part 
├─sda2                      8:2    0    2G  0 part /boot
└─sda3                      8:3    0  498G  0 part 
  └─ubuntu--vg-ubuntu--lv 252:0    0  100G  0 lvm  /
fdisk -l
Disk model: QEMU HARDDISK   
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: FFABA628-7776-4285-933C-3E1BA8C6DD9D

Device       Start        End    Sectors  Size Type
/dev/sda1     2048       4095       2048    1M BIOS boot
/dev/sda2     4096    4198399    4194304    2G Linux filesystem
/dev/sda3  4198400 1048573951 1044375552  498G Linux filesystem


Disk /dev/mapper/ubuntu--vg-ubuntu--lv: 100 GiB, 107374182400 bytes, 209715200 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
vgdisplay
  --- Volume group ---
  VG Name               ubuntu-vg
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  2
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               <498.00 GiB
  PE Size               4.00 MiB
  Total PE              127487
  Alloc PE / Size       25600 / 100.00 GiB
  Free  PE / Size       101887 / <398.00 GiB
  VG UUID               w6SS0n-Omzo-cgRz-OkYi-t3A3-UIl6-X7ZcJ3

LVM 볼륨 확장

남은 크기 할당

lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv

특정 크기 할당

lvextend -L +50G /dev/mapper/ubuntu--vg-ubuntu--lv

파일 시스템 확장

resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv

적용확인

df -h
Filesystem                         Size  Used Avail Use% Mounted on
tmpfs                              5.1G  1.2M  5.1G   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv  490G   77G  392G  17% /
tmpfs                               26G     0   26G   0% /dev/shm
tmpfs                              5.0M     0  5.0M   0% /run/lock
/dev/sda2                          2.0G   95M  1.7G   6% /boot
tmpfs                              5.1G   20K  5.1G   1% /run/user/1000