[kvm]ゲストOSのディスク拡張


ゲストOSのディスク拡張するよ!

-ホスト側

ゲストOSを停止

cd /var/lib/libvirt/images/
qemu-img info orecentos6-1.qcow2
qemu-img resize orecentos6-1.qcow2 +500G
qemu-img info orecentos6-1.qcow2

ゲストOSを起動

-ゲストOS側
ゲストOSでfdiskでパーティションを拡張
fdisk -l
fdisk /dev/vda
Command (m for help): p
Disk /dev/vda: 1106.0 GB, 1105954078720 bytes
16 heads, 63 sectors/track, 2142923 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000c8ed1

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *           3        1018      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/vda2            1018     1102669   555232152   83  Linux

Command (m for help): d
Partition number (1-4): 2

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (1-2142923, default 1): 1018
Last cylinder, +cylinders or +size{K,M,G} (1018-2142923, default 2142923): 
Using default value 2142923

Command (m for help): p

Disk /dev/vda: 1106.0 GB, 1105954078720 bytes
16 heads, 63 sectors/track, 2142923 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000c8ed1

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *           3        1018      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/vda2            1018     2142923  1079520168   83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

ゲストOSを再起動

物理ボリューム(PV)を拡張
# pvdisplay
  --- Physical volume ---
  PV Name               /dev/vda2
  VG Name               VolGroup
  PV Size               529.51 GiB / not usable 1.90 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              135554
  Free PE               0
  Allocated PE          135554
  PV UUID               NJPsVy-aVq7-FOyP-hpFh-QVsC-32ff-Ldb0Kz

# pvs
  PV         VG       Fmt  Attr PSize   PFree
  /dev/vda2  VolGroup lvm2 a--  529.51g    0

物理ボリュームを拡張します
pvresize /dev/vda2
  Physical volume "/dev/vda2" changed
  1 physical volume(s) resized / 0 physical volume(s) not resized

物理ボリュームを拡大した後の状態を確認します
# pvdisplay
  --- Physical volume ---
  PV Name               /dev/vda2
  VG Name               VolGroup
  PV Size               1.01 TiB / not usable 1.91 MiB
  Allocatable           yes 
  PE Size               4.00 MiB
  Total PE              263554
  Free PE               128000
  Allocated PE          135554
  PV UUID               NJPsVy-aVq7-FOyP-hpFh-QVsC-32ff-Ldb0Kz

# pvs
  PV         VG       Fmt  Attr PSize PFree  
  /dev/vda2  VolGroup lvm2 a--  1.01t 500.00g

論理ボリューム(LV)を拡張
# lvdisplay
  --- Logical volume ---
  LV Path                /dev/VolGroup/lv_root
  LV Name                lv_root
  VG Name                VolGroup
  LV UUID                ZRqZYR-DScE-qqPo-FiP3-Jobp-fJFJ-eaCSY8
  LV Write Access        read/write
  LV Creation host, time localhost.localdomain, 2015-05-20 14:32:02 +0900
  LV Status              available
  # open                 1
  LV Size                527.54 GiB
  Current LE             135050
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0
   
  --- Logical volume ---
  LV Path                /dev/VolGroup/lv_swap
  LV Name                lv_swap
  VG Name                VolGroup
  LV UUID                kyMDgF-ZAIw-jutv-KCkW-Va9R-0dK9-a9ZOmO
  LV Write Access        read/write
  LV Creation host, time localhost.localdomain, 2015-05-20 14:32:13 +0900
  LV Status              available
  # open                 1
  LV Size                1.97 GiB
  Current LE             504
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1

空いている物理ボリュームを全て割り振ります
# lvextend -l +100%FREE /dev/VolGroup/lv_root
  Size of logical volume VolGroup/lv_root changed from 527.54 GiB (135050 extents) to 1.00 TiB (263050 extents).
  Logical volume lv_root successfully resized

# lvdisplay
  --- Logical volume ---
  LV Path                /dev/VolGroup/lv_root
  LV Name                lv_root
  VG Name                VolGroup
  LV UUID                ZRqZYR-DScE-qqPo-FiP3-Jobp-fJFJ-eaCSY8
  LV Write Access        read/write
  LV Creation host, time localhost.localdomain, 2015-05-20 14:32:02 +0900
  LV Status              available
  # open                 1
  LV Size                1.00 TiB
  Current LE             263050
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0
   
  --- Logical volume ---
  LV Path                /dev/VolGroup/lv_swap
  LV Name                lv_swap
  VG Name                VolGroup
  LV UUID                kyMDgF-ZAIw-jutv-KCkW-Va9R-0dK9-a9ZOmO
  LV Write Access        read/write
  LV Creation host, time localhost.localdomain, 2015-05-20 14:32:13 +0900
  LV Status              available
  # open                 1
  LV Size                1.97 GiB
  Current LE             504
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1

ファイルシステム(XFS)を拡張
# df -h

XFSファイルシステムを拡張します
# xfs_growfs /dev/VolGroup/root

XFSじゃない場合
# df -h
# resize2fs /dev/mapper/VolGroup-lv_root
# df -h

コメント

ドメインサーチ

https://www.makko.biz/whois/?q=bg.bahaiquotesillustrated.info

このブログの人気の投稿

Apacheプロセス増加について

wgetでsitemap作成

ApacheでSSL自己証明書作成(オレオレ証明書)