LinuxサーバのLVM領域が枯渇した場合の容量増設手順

Linux

VMware ESXiの仮想サーバがHDD容量不足になったので増やします。

ここではLVMで構築されているLinuxを前提に利用できる領域を増やします。

[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

VMware ESXにて該当するHDDの容量を増やすためにはスナップショットが有効だと増やせません。そのため、今までのスナップショットを全て破棄する必要があります。後には引けません。

[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

HDDの総容量が増えていることを確認が確認できました。

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.

ココで再起動します。

# 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

以上で終了です。

タイトルとURLをコピーしました