Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to reduce physical volume on remote Virtual Machine?

Posted on 2015-02-11
11
Medium Priority
?
67 Views
Last Modified: 2015-03-24
I'd like to reduce the disk size of a remote VM as I've removed 83G logical volume that was not required.  All that I've seen on this indicates the use of LiveCD, I have no physical access and can access VM console via host.

Anyone suggest a low risk method?

pvs:
  PV         VG      Fmt  Attr PSize   PFree
  /dev/vda2  vg_rm01 lvm2 a--  149.51g 83.77g

vgs:
  VG      #PV #LV #SN Attr   VSize   VFree
  vg_rm01   1   2   0 wz--n- 149.51g 83.77g

lvs:
  LV      VG      Attr      LSize  Pool Origin Data%  Move Log Cpy%Sync Convert
  lv_root vg_rm01 -wi-ao--- 50.00g
  lv_swap vg_rm01 -wi-a---- 15.74g
0
Comment
Question by:mickt
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
11 Comments
 
LVL 5

Expert Comment

by:Uni Kitty
ID: 40604579
Is this VMware? One way you could do this is V2V using converter. I used to use this method for lots of reasons and one can be to resize the disk, and since you mention that you do not have "access" to the VM, you can run converter on the running guest.

Check out Andy's article and let us know if you have questions.
http://www.experts-exchange.com/Software/Virtualization/A_17461-HOW-TO-Convert-a-physical-server-or-virtual-server-P2V-V2V-to-Microsoft-Hyper-V-using-Microsoft-Virtual-Machine-Converter-3-1.html?related=28614578
0
 
LVL 16

Expert Comment

by:Joseph Gan
ID: 40604626
Can you show the following outputs:

# lvscan
# vgscan
# pvscan
0
 
LVL 62

Expert Comment

by:gheist
ID: 40604643
You cannot change PV size after LVM has its hands at it.
0
Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

 
LVL 17

Expert Comment

by:gelonida
ID: 40605137
Is it VMware, VirtualBox or another solution?
0
 

Author Comment

by:mickt
ID: 40605142
It is kvm.

Can resize image with qemu-img resize and was hoping I could easily resize PV &VG in lvm.

Could I shutdown VM and attach disk to another VM and reduce then?
0
 

Author Comment

by:mickt
ID: 40605163
In response to request form ganjos:

lvscan
  ACTIVE            '/dev/vg_rm01/lv_root' [50.00 GiB] inherit
  ACTIVE            '/dev/vg_rm01/lv_swap' [15.74 GiB] inherit

vgscan
  Reading all physical volumes.  This may take a while...
  Found volume group "vg_rm01" using metadata type lvm2

pvscan
  PV /dev/vda2   VG vg_rm01   lvm2 [149.51 GiB / 83.77 GiB free]
  Total: 1 [149.51 GiB] / in use: 1 [149.51 GiB] / in no VG: 0 [0   ]
0
 

Accepted Solution

by:
mickt earned 0 total points
ID: 40605292
OK guys, the following worked a treat.  Please advise if you see issues with what I did?

Procedure:

- virsh shutdown <VM>

- virsh attach-disk <VM1> /var/lib/libvirt/images/<VM>.img vdb <- first verify that this disk is available on VM1!
  Disk attached successfully

- - pvresize --setphysicalvolumesize  <NEW_SIZE>G /dev/vdb2
   /dev/vdb2: cannot resize to 30463 extents as later ones are allocated.
   0 physical volume(s) resized / 1 physical volume(s) not resized <- Did not successfully complete.

- pvmove --alloc anywhere /dev/vdb2
   /dev/vdb2: Moved: 0.1%
   ...
   This is slow so be patient
   ...
   /dev/vdb2: Moved: 100.0%

- pvresize --setphysicalvolumesize  <NEW-SIZE>G /dev/vdb2
   Physical volume "/dev/vdb2" changed
   1 physical volume(s) resized / 0 physical volume(s) not resized <- Successful completion

- Can also resize root LV etc. now.

- virsh detach-disk <VM1> /var/lib/libvirt/images/<VM>.img

- qemu-img resize /var/lib/libvirt/images/<VM>.img <NEW_SIZE>G

- virsh start <VM>
   PV, VG & LV show present and correct.  So now it should just be a case of resizing etc.

- resize2fs /dev/mapper/vg_rm01-lv_root

- df -h
  shows correct size
0
 
LVL 62

Expert Comment

by:gheist
ID: 40605299
You cannot resize LVM2 MBR partition. You must add extra LVM2 MBR partition and then remove old one.
0
 

Author Comment

by:mickt
ID: 40605317
Should be ok in my instance?

df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_rm01-lv_root
                       63G  7.9G   52G  14% /
tmpfs                  16G     0   16G   0% /dev/shm
/dev/vda1             485M   37M  423M   9% /boot
0
 

Author Comment

by:mickt
ID: 40607685
I should also have mentioned that cloud-utils-growpart RPM should be installed and linux-rootfs-resize installed.  You can google the latter and may need to edit to include additional OSes as I did.
0
 

Author Closing Comment

by:mickt
ID: 40684218
.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If your vDisk VHD file gets deleted from the image store accidentally or on purpose, you won't be able to remove the vDisk from the PVS console. There is a known workaround that is solid.
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Suggested Courses

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question