投稿日:2010年6月10日(この記事を読むのに必要な時間: 約 7分25秒)
VMware ESXiの仮想サーバがHDD容量不足になったので増やす。
LVMで構築されているLinuxを前提としている。
(大抵の最近のLinuxはこれだから大丈夫でしょ)
[bash]
[root@localhost ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
39486856 2709764 34738924 8% /
/dev/sda1 101086 19284 76583 21% /boot
tmpfs 255292 0 255292 0% /dev/shm
[root@localhost ~]# fdisk -l /dev/sda
Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 5221 41833260 8e Linux LVM
[/bash]
VMware ESXにて該当するHDDの容量を増やす。
スナップショットが有効だと増やせない。
増やしたい場合は、今までのスナップショットを全て破棄する必要がある。
[bash] [root@localhost ~]# fdisk -l /dev/sda Disk /dev/sda: 64.4 GB, 64424509440 bytes 255 heads, 63 sectors/track, 7832 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 * 1 13 104391 83 Linux /dev/sda2 14 5221 41833260 8e Linux LVM [/bash]
HDDの総容量が増えていることを確認。
[bash] Command (m for help): p Disk /dev/sda: 64.4 GB, 64424509440 bytes 255 heads, 63 sectors/track, 7832 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 * 1 13 104391 83 Linux /dev/sda2 14 5221 41833260 8e Linux LVM Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 3 First cylinder (5222-7832, default 5222): Using default value 5222 Last cylinder or +size or +sizeM or +sizeK (5222-7832, default 7832): Using default value 7832 Command (m for help): p Disk /dev/sda: 64.4 GB, 64424509440 bytes 255 heads, 63 sectors/track, 7832 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 * 1 13 104391 83 Linux /dev/sda2 14 5221 41833260 8e Linux LVM /dev/sda3 5222 7832 20972857+ 83 Linux Command (m for help): t Partition number (1-4): 3 Hex code (type L to list codes): 8e Changed system type of partition 3 to 8e (Linux LVM) Command (m for help): p Disk /dev/sda: 64.4 GB, 64424509440 bytes 255 heads, 63 sectors/track, 7832 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 * 1 13 104391 83 Linux /dev/sda2 14 5221 41833260 8e Linux LVM /dev/sda3 5222 7832 20972857+ 8e Linux LVM Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16: Device or resource busy. The kernel still uses the old table. The new table will be used at the next reboot. Syncing disks. [/bash]
ココで再起動
[bash]
# pvcreate /dev/sda3
# vgextend VolGroup00 /dev/sda3
# lvextend -L +20G /dev/VolGroup00/LogVol00
# resize2fs -p /dev/VolGroup00/LogVol00
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
58G 2.6G 52G 5% /
/dev/sda1 99M 19M 75M 21% /boot
tmpfs 250M 0 250M 0% /dev/shm
[/bash]
以上で終了。
