3
3
3ton2015-01-19 13:58:20
LVM
3ton, 2015-01-19 13:58:20

How to reduce (replace) the disk of a virtual machine (KVM + LVM)?

At the time of installing the virtual machine, I had the imprudence to use a rather large partition, now there are problems with the lack of space for other machines, as well as with creating a volume backup and archiving it for transfer to another machine.

I created a volume in the host machine, then set it as a disk for a virtual machine, during installation I specify to use it as a disk (in the guest system it is not LVM) on which the installer himself marks the partitions and installs the system.

[email protected]: /# fdisk -l

Disk /dev/vda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders, total 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00059cf1

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048    40894463    20446208   83  Linux
/dev/vda2        40896510    41940991      522241    5  Extended
/dev/vda5        40896512    41940991      522240   82  Linux swap / Solaris

(this is the data of a test machine for 20 gigs on which I will train, but this is done so that later I can use it in a production machine with a partition of 200 gigs)
Now it became necessary to reduce this volume by 2 times, but in my case 1 volume in the host system != 1 partition in guest system, so you have to solve problems with changing the size of the root partition in the guest system, and only after reducing the LVM volume itself.

As a solution to the issue, I would also like to create a new volume of the size I need with the transfer of the system to it and then delete the old large LVM volume, if of course this is possible.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Valentine, 2015-01-21
@ProFfeSsoRr

In vain you did not make additional disks on the host directly, but partitioned them inside. Now you have the easiest way to solve the problem - "on the forehead", make the second screw, which will become new, cling to the virtual machine, copy all the files to it (this stage is from the LiveCD for the system disk), so with all partitions, well, on the system then write grub through chroot (well, or how is your virtual machine boot organized? If the kernel arrives at the host, then grub is not needed), and you will correct /etc/fstab. And in the future, create screws on the host and immediately slip them into the virtual machine, it will be easier;)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question