VMware Fusion上のUbuntu 22.04 ファイルシステム拡張

① VMwareからハードディスクサイズ拡張

② Ubuntuにハードディスクのサイズ変更を認識させる
$ sudo sh -c "echo 1 > /sys/class/block/sda/device/rescan"
$ df
Filesystem 1K-blocks Used Available Use% Mounted on
tmpfs 396144 2120 394024 1% /run
/dev/mapper/vgubuntu-root 36695528 33687336 1111952 97% /
tmpfs 1980708 0 1980708 0% /dev/shm
tmpfs 5120 4 5116 1% /run/lock
/dev/sda2 524252 6220 518032 2% /boot/efi
tmpfs 396140 112 396028 1% /run/user/1000

③ パーティション拡張
$ sudo parted
GNU Parted 3.4
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print free
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sda: 85.9GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number Start End Size File system Name Flags
17.4kB 1049kB 1031kB Free Space
1 1049kB 2097kB 1049kB bios_grub
2 2097kB 540MB 538MB fat32 boot, esp
3 540MB 42.9GB 42.4GB lvm
42.9GB 85.9GB 43.0GB Free Space

(parted) resizepart 3
End? [42.9GB]? 85.9GB
(parted) q
Information: You may need to update /etc/fstab.

④ 物理ボリュームの拡張
$ sudo pvdisplay
--- Physical volume ---
PV Name /dev/sda3
VG Name vgubuntu
PV Size <39.50 GiB / not usable 4.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 10110
Free PE 2
Allocated PE 10108

PV UUID 8aosOg-JAl0-7QfW-ZIom-I2Qr-kiAA-In2MKp

$ sudo pvresize /dev/sda3
Physical volume "/dev/sda3" changed
1 physical volume(s) resized or updated / 0 physical volume(s) not resized
$ sudo pvdisplay
--- Physical volume ---
PV Name /dev/sda3
VG Name vgubuntu
PV Size <79.50 GiB / not usable 3.98 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 20350
Free PE 10242
Allocated PE 10108
PV UUID 8aosOg-JAl0-7QfW-ZIom-I2Qr-kiAA-In2MKp

⑤ Volume Group拡張不要
$ sudo vgdisplay
--- Volume group ---
VG Name vgubuntu
System ID
Format lvm2
Metadata Areas 1
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 1
Act PV 1
VG Size 79.49 GiB
PE Size 4.00 MiB
Total PE 20350
Alloc PE / Size 10108 / 39.48 GiB
Free PE / Size 10242 / <40.01 GiB
VG UUID 4acFCj-UqEe-8mTk-7Wwd-MZLl-ai7h-ihyxQN

⑥ Logical Volume拡張
$ sudo lvdisplay
--- Logical volume ---
LV Path /dev/vgubuntu/root
LV Name root
VG Name vgubuntu
LV UUID 3DOoqa-aHnV-Fb3a-iUEH-hZ1w-fyha-DuMlVV
LV Write Access read/write
LV Creation host, time ubuntu, 2023-12-27 18:52:35 +0900
LV Status available
# open 1
LV Size <35.86 GiB
Current LE 9179
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 252:0

--- Logical volume ---
LV Path /dev/vgubuntu/swap_1
LV Name swap_1
VG Name vgubuntu
LV UUID UabOMI-DMYv-WWks-ZKnO-ySuX-E4fe-ht8Yrh
LV Write Access read/write
LV Creation host, time ubuntu, 2023-12-27 18:52:36 +0900
LV Status available
# open 2
LV Size <3.63 GiB
Current LE 929
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 252:1

$ sudo lvextend -l +100%FREE /dev/vgubuntu/root
Size of logical volume vgubuntu/root changed from <35.86 GiB (9179 extents) to 75.86 GiB (19421 extents).
Logical volume vgubuntu/root successfully resized.

⑦ ファイルシステム拡張
$ sudo resize2fs /dev/vgubuntu/root
resize2fs 1.46.5 (30-Dec-2021)
Filesystem at /dev/vgubuntu/root is mounted on /; on-line resizing required
old_desc_blocks = 5, new_desc_blocks = 10
The filesystem on /dev/vgubuntu/root is now 19887104 (4k) blocks long.

⑧ 確認

$ df -h
Filesystem Size Used Avail Use% Mounted on
tmpfs 387M 2.1M 385M 1% /run
/dev/mapper/vgubuntu-root 75G 33G 39G 46% /
tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
/dev/sda2 512M 6.1M 506M 2% /boot/efi
tmpfs 387M 112K 387M 1% /run/user/1000



コメント

人気の投稿