LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-29-2017, 12:57 PM   #1
fanoflq
Member
 
Registered: Nov 2015
Posts: 397

Rep: Reputation: Disabled
kvm : cloned image size is MUCH smaller!


I cloned a VM in KVM using this command:
Code:
# virt-clone --original centos7-1024ram-minimal \
           --auto-clone  \
	--name centos7-1024ram-minimal-clone0
And when I looked at resulting image size, it is MUCH MUCH smaller!
But it runs fine.
Code:
root@server /var/lib/libvirt/images # ls -alh
total 38G
drwx--x--x 2 root         root 4.0K Mar 28 12:55 .
drwxr-xr-x 7 root         root 4.0K Mar 28 16:15 ..
-rw------- 1 libvirt-qemu kvm  1.5G Mar 29 11:44 centos7-1024ram-minimal-clone0.qcow2
-rw------- 1 root         root 2.2G Mar 20 12:52 centos7-1024ram-minimal-clone.qcow2
-rw------- 1 root         root  15G Mar 14 10:07 centos7-1024ram-minimal.qcow2
Why is the image 10X smaller?
How to make its clone the same image size as original?

Thank you.

Last edited by fanoflq; 03-29-2017 at 01:40 PM.
 
Old 03-29-2017, 02:24 PM   #2
Madhu Desai
Member
 
Registered: Mar 2013
Distribution: Rocky, Fedora, Ubuntu
Posts: 541

Rep: Reputation: 153Reputation: 153
Quote:
Originally Posted by fanoflq View Post
I cloned a VM in KVM using this command:
Code:
# virt-clone --original centos7-1024ram-minimal \
           --auto-clone  \
	--name centos7-1024ram-minimal-clone0
And when I looked at resulting image size, it is MUCH MUCH smaller!
But it runs fine.
Code:
root@server /var/lib/libvirt/images # ls -alh
total 38G
drwx--x--x 2 root         root 4.0K Mar 28 12:55 .
drwxr-xr-x 7 root         root 4.0K Mar 28 16:15 ..
-rw------- 1 libvirt-qemu kvm  1.5G Mar 29 11:44 centos7-1024ram-minimal-clone0.qcow2
-rw------- 1 root         root 2.2G Mar 20 12:52 centos7-1024ram-minimal-clone.qcow2
-rw------- 1 root         root  15G Mar 14 10:07 centos7-1024ram-minimal.qcow2
Why is the image 10X smaller?
How to make its clone the same image size as original?

Thank you.
What's the output of this command?
Code:
virsh snapshot-list centos7-1024ram-minimal
 
Old 03-29-2017, 02:26 PM   #3
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,776

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Quote:
Originally Posted by fanoflq View Post
Code:
# virt-clone --original centos7-1024ram-minimal \
           --auto-clone  \
	--name centos7-1024ram-minimal-clone0
And when I looked at resulting image size, it is MUCH MUCH smaller!
But it runs fine.
Code:
root@server /var/lib/libvirt/images # ls -alh
total 38G
drwx--x--x 2 root         root 4.0K Mar 28 12:55 .
drwxr-xr-x 7 root         root 4.0K Mar 28 16:15 ..
-rw------- 1 libvirt-qemu kvm  1.5G Mar 29 11:44 centos7-1024ram-minimal-clone0.qcow2
-rw------- 1 root         root 2.2G Mar 20 12:52 centos7-1024ram-minimal-clone.qcow2
-rw------- 1 root         root  15G Mar 14 10:07 centos7-1024ram-minimal.qcow2
My guess is that the original image was built with "Allocate entire disk now" checked for its 15GB image file. When the clone was made, only the space actually used was copied. If you run "qemu-img info" on that file, you'll see that its virtual size is 15GB, and it will grow up to that size as space is needed.
 
1 members found this post helpful.
Old 03-29-2017, 02:48 PM   #4
fanoflq
Member
 
Registered: Nov 2015
Posts: 397

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by rknichols View Post
My guess is that the original image was built with "Allocate entire disk now" checked for its 15GB image file. When the clone was made, only the space actually used was copied. If you run "qemu-img info" on that file, you'll see that its virtual size is 15GB, and it will grow up to that size as space is needed.

Code:
# qemu-img info centos7-1024ram-minimal-clone0.qcow2
image: centos7-1024ram-minimal-clone0.qcow2
file format: qcow2
virtual size: 14G (15032385536 bytes)
disk size: 1.4G
cluster_size: 65536
Format specific information:
    compat: 1.1
    lazy refcounts: true
    refcount bits: 16
    corrupt: false
or this:
Quote:
# virsh domstats centos7-1024ram-minimal-clone0 | egrep -i "capacity|physical"
block.0.capacity=15032385536
block.0.physical=1528897536
Thanks.

Last edited by fanoflq; 03-29-2017 at 02:56 PM.
 
Old 03-29-2017, 02:50 PM   #5
fanoflq
Member
 
Registered: Nov 2015
Posts: 397

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by mddnix View Post
What's the output of this command?
Code:
virsh snapshot-list centos7-1024ram-minimal

I got nothing!

Code:
# virsh snapshot-list centos7-1024ram-minimal
 Name                 Creation Time             State
------------------------------------------------------------

# virsh snapshot-list centos7-1024ram-minimal-clone0
 Name                 Creation Time             State
------------------------------------------------------------
#
 
Old 03-29-2017, 03:20 PM   #6
Madhu Desai
Member
 
Registered: Mar 2013
Distribution: Rocky, Fedora, Ubuntu
Posts: 541

Rep: Reputation: 153Reputation: 153
@fanoflq, rknichols is indicating at centos7-1024ram-minimal.qcow2 volume. You need to check for this volume. Check whether block.0.capacity and block.0.physical are same for centos7-1024ram-minimal.
 
Old 03-29-2017, 03:24 PM   #7
fanoflq
Member
 
Registered: Nov 2015
Posts: 397

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by mddnix View Post
@fanoflq, rknichols is indicating at centos7-1024ram-minimal.qcow2 volume. You need to check for this volume. Check whether block.0.capacity and block.0.physical are same for centos7-1024ram-minimal.

Code:
# virsh domstats centos7-1024ram-minimal | egrep -i "capacity|physical"
  block.0.capacity=15032385536
  block.0.physical=15034941440
Same....almost
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
firewalld help: trying to forward https from kvm host to kvm guest on same port GaWdLy Linux - Networking 4 07-15-2016 02:27 PM
[SOLVED] "No KVM, No qemu-kvm" Available error while trying to install KVM on CentOS 6.3 sriramdas Linux - Virtualization and Cloud 5 01-01-2013 10:46 AM
[SOLVED] Centos 6 and KVM - how to setup bridged networking in KVM in a -Class B- environment? rylan76 Linux - Virtualization and Cloud 7 11-07-2012 06:46 AM
[Debian/Qemu/KVM] Why qemu --enable-kvm works but not kvm directly? gb2312 Linux - Virtualization and Cloud 2 03-21-2011 02:05 PM
LXer: Install Oracle 11gR2 on SL6 KVM at KVM-QEMU Instance on SL 6 (alpha 3) LXer Syndicated Linux News 2 01-01-2011 06:42 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:47 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration