- 始めに VM を shutdown します
$ie-virsh shutdown <vmname>
-
VM 領域の拡張をします。(シス管が行います)
-
VM を起動します
$ie-virsh start <vmname>
ここから VM 内での作業になります
- パーティションの作成
//rootに入ります。
ie-user@ubuntu:~$ sudo -s
//df -hでディスク容量を確認します。
//この時点で変更はありません。
ie-user@ubuntu:~$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 462M 0 462M 0% /dev
tmpfs 99M 676K 98M 1% /run
/dev/mapper/ubuntu--vg-root 8.3G 2.6G 5.3G 33% /
tmpfs 491M 0 491M 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 491M 0 491M 0% /sys/fs/cgroup
/dev/sda1 472M 132M 316M 30% /boot
tmpfs 99M 0 99M 0% /run/user/1000
//fdiskコマンドでパーティションテーブルを確認します。
// /dev/sdaが増えていることが確認できます。
root@ubuntu:/home/ie-user# fdisk -l
Disk /dev/sda: 60 GiB, 64424509440 bytes, 125829120 sectors
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: dos
Disk identifier: 0xe86766b0
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 999423 997376 487M 83 Linux
/dev/sda2 1001470 20969471 19968002 9.5G 5 Extended
/dev/sda5 1001472 20969471 19968000 9.5G 8e Linux LVM
Disk /dev/mapper/ubuntu--vg-root: 8.51 GiB, 9126805504 bytes, 17825792 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
Disk /dev/mapper/ubuntu--vg-swap_1: 1020 MiB, 1069547520 bytes, 2088960 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
//fdiskコマンドでパーティションテーブルを設定します。
root@ubuntu:/home/ie-user# fdisk /dev/sda
Welcome to fdisk (util-linux 2.34).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
//pを入力します。
Command (m for help): p
Disk /dev/sda: 60 GiB, 64424509440 bytes, 125829120 sectors
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: dos
Disk identifier: 0xe86766b0
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 999423 997376 487M 83 Linux
/dev/sda2 1001470 20969471 19968002 9.5G 5 Extended
/dev/sda5 1001472 20969471 19968000 9.5G 8e Linux LVM
//nを入力します。 パーティションを新規作成します。
Command (m for help): n
Partition type
p primary (1 primary, 1 extended, 2 free)
l logical (numbered from 5)
//pを入力します。
Select (default p): p
//3を選択します。 sda3を新規で作成します。
Partition number (3,4, default 3): 3
//開始セクターを入力します。 sda5の"End"に+1した値(今回の場合は20969471+1)を入力します。 default値でも問題ないです。
First sector (20969472-125829119, default 20969472):
//終了セクターを入力します。 default値を入力してください。 そのままenterを押すとdefault値になります。
Last sector, +/-sectors or +/-size{K,M,G,T,P} (20969472-125829119, default 125829119):
Created a new partition 3 of type 'Linux' and of size 50 GiB.
//pを入力します。 sda3が増えていることが確認できると思います。
Command (m for help): p
Disk /dev/sda: 60 GiB, 64424509440 bytes, 125829120 sectors
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: dos
Disk identifier: 0xe86766b0
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 999423 997376 487M 83 Linux
/dev/sda2 1001470 20969471 19968002 9.5G 5 Extended
/dev/sda3 20969472 125829119 104859648 50G 83 Linux
/dev/sda5 1001472 20969471 19968000 9.5G 8e Linux LVM
Partition table entries are not in disk order.
//tを入力します。 パーティションタイプをLVMに設定します。
Command (m for help): t
//3を入力します。
Partition number (1-3,5, default 5): 3
//Lを入力すると、Hex codeが見れます。 8eがLinux LVMであることを確認します。
Hex code (type L to list all codes): L
0 Empty 24 NEC DOS 81 Minix / old Lin bf Solaris
1 FAT12 27 Hidden NTFS Win 82 Linux swap / So c1 DRDOS/sec (FAT-
2 XENIX root 39 Plan 9 83 Linux c4 DRDOS/sec (FAT-
3 XENIX usr 3c PartitionMagic 84 OS/2 hidden or c6 DRDOS/sec (FAT-
4 FAT16 <32M 40 Venix 80286 85 Linux extended c7 Syrinx
5 Extended 41 PPC PReP Boot 86 NTFS volume set da Non-FS data
6 FAT16 42 SFS 87 NTFS volume set db CP/M / CTOS / .
7 HPFS/NTFS/exFAT 4d QNX4.x 88 Linux plaintext de Dell Utility
8 AIX 4e QNX4.x 2nd part 8e Linux LVM df BootIt
9 AIX bootable 4f QNX4.x 3rd part 93 Amoeba e1 DOS access
a OS/2 Boot Manag 50 OnTrack DM 94 Amoeba BBT e3 DOS R/O
b W95 FAT32 51 OnTrack DM6 Aux 9f BSD/OS e4 SpeedStor
c W95 FAT32 (LBA) 52 CP/M a0 IBM Thinkpad hi ea Rufus alignment
e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a5 FreeBSD eb BeOS fs
f W95 Ext'd (LBA) 54 OnTrackDM6 a6 OpenBSD ee GPT
10 OPUS 55 EZ-Drive a7 NeXTSTEP ef EFI (FAT-12/16/
11 Hidden FAT12 56 Golden Bow a8 Darwin UFS f0 Linux/PA-RISC b
12 Compaq diagnost 5c Priam Edisk a9 NetBSD f1 SpeedStor
14 Hidden FAT16 <3 61 SpeedStor ab Darwin boot f4 SpeedStor
16 Hidden FAT16 63 GNU HURD or Sys af HFS / HFS+ f2 DOS secondary
17 Hidden HPFS/NTF 64 Novell Netware b7 BSDI fs fb VMware VMFS
18 AST SmartSleep 65 Novell Netware b8 BSDI swap fc VMware VMKCORE
1b Hidden W95 FAT3 70 DiskSecure Mult bb Boot Wizard hid fd Linux raid auto
1c Hidden W95 FAT3 75 PC/IX bc Acronis FAT32 L fe LANstep
1e Hidden W95 FAT1 80 Old Minix be Solaris boot ff BBT
//8eを入力します。
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'.
//pを入力します。 sda3がLinux LVMに変更されていることを確認します。
Command (m for help): p
Disk /dev/sda: 60 GiB, 64424509440 bytes, 125829120 sectors
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: dos
Disk identifier: 0xe86766b0
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 999423 997376 487M 83 Linux
/dev/sda2 1001470 20969471 19968002 9.5G 5 Extended
/dev/sda3 20969472 125829119 104859648 50G 8e Linux LVM
/dev/sda5 1001472 20969471 19968000 9.5G 8e Linux LVM
Partition table entries are not in disk order.
//wを入力して変更を反映します。
Command (m for help): w
The partition table has been altered.
Syncing disks.
- 物理ボリューム、論理ボリュームの追加
//物理ボリュームに追加する。
// 先程追加した/dev/sda3を物理ボリュームに追加します。
root@ubuntu:/home/ie-user# pvcreate /dev/sda3
WARNING: PV /dev/sda5 in VG ubuntu-vg is using an old PV header, modify the VG to update.
Physical volume "/dev/sda3" successfully created.
// 物理ボリュームを確認。
// 物理ボリュームに/dev/sda3が追加されているか確認。
root@ubuntu:/home/ie-user# pvdisplay
WARNING: PV /dev/sda5 in VG ubuntu-vg is using an old PV header, modify the VG to update.
--- Physical volume ---
PV Name /dev/sda5
VG Name ubuntu-vg
PV Size 9.52 GiB / not usable 2.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 2437
Free PE 6
Allocated PE 2431
PV UUID IcOWc1-20W7-7nAY-Xl1n-NsUW-wcE4-AIStq6
"/dev/sda3" is a new physical volume of "50.00 GiB"
--- NEW Physical volume ---
PV Name /dev/sda3
VG Name
PV Size 50.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID aBse1p-SSle-Xgbr-WnYU-sS9F-ajwP-azlrDS
// VG(ボリュームグループ)名を取得
// VG Name = 「ubuntu-vg」と確認できます。
root@ubuntu:/home/ie-user# vgdisplay
WARNING: PV /dev/sda5 in VG ubuntu-vg is using an old PV header, modify the VG to update.
--- Volume group ---
VG Name ubuntu-vg
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
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 <9.52 GiB
PE Size 4.00 MiB
Total PE 2437
Alloc PE / Size 2431 / <9.50 GiB
Free PE / Size 6 / 24.00 MiB
VG UUID z431yb-jO4t-TgLb-s4Bd-tYAo-B0At-g0IaBF
// VG(ボリュームグループ)を拡張
// ボリュームグループ「ubuntu-vg」に/dev/sda3を追加します
root@ubuntu:/home/ie-user# vgextend ubuntu-vg /dev/sda3
WARNING: PV /dev/sda5 in VG ubuntu-vg is using an old PV header, modify the VG to update.
WARNING: PV /dev/sda5 in VG ubuntu-vg is using an old PV header, modify the VG to update.
WARNING: updating PV header on /dev/sda5 for VG ubuntu-vg.
Volume group "ubuntu-vg" successfully extended
root@ubuntu:/home/ie-user# vgdisplay
--- Volume group ---
VG Name ubuntu-vg
System ID
Format lvm2
Metadata Areas 2
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 2
Act PV 2
VG Size <59.52 GiB
PE Size 4.00 MiB
Total PE 15237
Alloc PE / Size 2431 / <9.50 GiB
Free PE / Size 12806 / 50.02 GiB
VG UUID z431yb-jO4t-TgLb-s4Bd-tYAo-B0At-g0IaBF
// 論理ボリュームパスを確認
// 論理ボリュームパスはLV Path = "/dev/ubuntu-vg/root"と確認できました。
root@ubuntu:/home/ie-user# lvdisplay
--- Logical volume ---
LV Path /dev/ubuntu-vg/root
LV Name root
VG Name ubuntu-vg
LV UUID jZ9JTi-Wv0W-JyKW-3ohl-FzaF-pL25-nxfWFS
LV Write Access read/write
LV Creation host, time ubuntu, 2016-10-17 15:09:41 +0900
LV Status available
# open 1
LV Size 8.50 GiB
Current LE 2176
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Logical volume ---
LV Path /dev/ubuntu-vg/swap_1
LV Name swap_1
VG Name ubuntu-vg
LV UUID hPrQY7-GdZ6-sJtc-Y7JJ-Ismu-flJ1-ooZtI2
LV Write Access read/write
LV Creation host, time ubuntu, 2016-10-17 15:09:41 +0900
LV Status available
# open 2
LV Size 1020.00 MiB
Current LE 255
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
// 論理ボリュームの拡張
// 既存の論理ボリュームに拡張した物理ボリュームを追加で割り当てます。
// 「-l +100%FREE」でボリュームグループの空きを全て割り当ててくれます。
root@ubuntu:/home/ie-user# lvextend -l +100%FREE /dev/ubuntu-vg/root
Size of logical volume ubuntu-vg/root changed from 8.50 GiB (2176 extents) to 58.52 GiB (14982 extents).
Logical volume ubuntu-vg/root successfully resized.
// 最後にファイルシステムの拡張を行う。
root@ubuntu:/home/ie-user# resize2fs /dev/ubuntu-vg/root
resize2fs 1.45.5 (07-Jan-2020)
Filesystem at /dev/ubuntu-vg/root is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 4
The filesystem on /dev/ubuntu-vg/root is now 15341568 (4k) blocks long.
// df -hコマンドで容量が増えていることを確認。めでたし、めでたし。
root@ubuntu:/home/ie-user# df -h
Filesystem Size Used Avail Use% Mounted on
udev 462M 0 462M 0% /dev
tmpfs 99M 680K 98M 1% /run
/dev/mapper/ubuntu--vg-root 58G 2.6G 53G 5% /
tmpfs 491M 0 491M 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 491M 0 491M 0% /sys/fs/cgroup
/dev/sda1 472M 132M 316M 30% /boot
tmpfs 99M 0 99M 0% /run/user/1000