虛機qemu磁盤lvm擴容

參考:https://www.cnblogs.com/superlinux/p/11923739.html

           http://blog.chinaunix.net/uid-29847640-id-5752497.html


剛建不久的日誌服務器管理頁面打不開了,進入linux發現要目錄已沒有空間了,操作好命令都沒反應,只得進行磁盤擴容操作。


root@NAIC-CVK10:/local_space# qemu-img info rzfwq2


root@NAIC-CVK10:/local_space# virsh list --all


root@NAIC-CVK10:/local_space# virsh stop rzfwq2


root@NAIC-CVK10:/local_space# qemu-img resize rzfwq2 +30G

Image resized.

root@NAIC-CVK10:/local_space# qemu-img info rzfwq2

image: rzfwq2

file format: qcow2

virtual size: 130G (139586437120 bytes)

disk size: 91G

cluster_size: 262144

Format specific information:

    compat: 1.1

    lazy refcounts: false

    refcount bits: 16

    corrupt: false


[root@logserver2 ~]# fdisk /dev/vda

Command (m for help): p

Disk /dev/vda: 139.6 GB, 139586437120 bytes

16 heads, 63 sectors/track, 270466 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: 0x000b3f08

   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      208051   104344576   8e  Linux LVM

Partition 2 does not end on cylinder boundary.

Command (m for help): n

Command action

   e   extended

   p   primary partition (1-4)

p

Partition number (1-4): 3

First cylinder (1-270466, default 1): 208051

Last cylinder, +cylinders or +size{K,M,G} (208051-270466, default 270466): 

Using default value 270466

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): w

The partition table has been altered!


Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: 設備或資源忙.

The kernel still uses the old table. The new table will be used at

the next reboot or after you run partprobe(8) or kpartx(8)



[root@logserver2 ~]# vgs

  VG       #PV #LV #SN Attr   VSize   VFree  

  VolGroup   2   2   0 wz--n- 129.50g  30.00g

  data_vg    1   1   0 wz--n-   1.56t 600.00g


[root@logserver2 ~]# vgextend VolGroup /dev/vda3

  Volume group "VolGroup" successfully extended

You have mail in /var/spool/mail/root


[root@logserver2 ~]# lvs

  LV      VG       Attr       LSize    Pool Origin Data%  Move Log Cpy%Sync Convert

  lv_root VolGroup -wi-ao----   91.70g                                             

  lv_swap VolGroup -wi-ao----    7.81g                                             

  log_lv  data_vg  -wi-ao---- 1000.00g                                             


[root@logserver2 ~]# vgdisplay

   --- Volume group ---

  VG Name               VolGroup

  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               129.50 GiB

  PE Size               4.00 MiB

  Total PE              33153

  Alloc PE / Size       25474 / 99.51 GiB

  Free  PE / Size       7679 / 30.00 GiB

  VG UUID               7soJlX-Cc0t-P3Ul-ZCKI-foxN-nzXO-Quksg2

   

[root@logserver2 ~]# lvextend -r -l +7679 /dev/mapper/VolGroup-lv_root 

  Extending logical volume lv_root to 121.69 GiB

  Logical volume lv_root successfully resized

resize2fs 1.41.12 (17-May-2010)

Filesystem at /dev/mapper/VolGroup-lv_root is mounted on /; on-line resizing required

old desc_blocks = 6, new_desc_blocks = 8

Performing an on-line resize of /dev/mapper/VolGroup-lv_root to 31900672 (4k) blocks.

The filesystem on /dev/mapper/VolGroup-lv_root is now 31900672 blocks long.


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章