Solved

Increase hard disk size of QEmu/KVM image

Posted on 2010-09-12
6
2,893 Views
Last Modified: 2012-05-10
Hi experts,

I have Ubuntu 10.04 Server (no gui) install with the default KVM server stuff that came on the install disk. I have created a virtual Ubuntu server with vmbuilder with a 4gb qcow2 image. I am wondering now how I can resize this virtual drive to 16gb.

Have tried a few things but none of them are working, Any ideas?
0
Comment
Question by:mstrelan
  • 4
  • 2
6 Comments
 
LVL 6

Accepted Solution

by:
Jelcin earned 500 total points
ID: 33660237
1. Convert the qcow image to raw format. (qemu-img convert yourqcow2image -O raw yourrawimage)
2. Extend the raw format image using dd (see my example below)
3. Convert the raw image back to qcow format (qemu-img convert yourrawimage -O qcow2 yourqcow2image)
4. Boot up qemu with the new qcow2 image under for example gparted live cd and resize the partition.
6. Reboot qemu with the resized qcow2 image and the Linux on it.

dd if=/dev/zero of=hdd.img seek=N obs=1MB count=0
N is new size to resize hdd.img in MB

And don't forget to backup your qcow2 image before you start!!!
0
 
LVL 10

Author Comment

by:mstrelan
ID: 33660846
Thanks Jelcin, I was hoping this would be the answer as this is what I have been trying, but now hopefully you can help me with it.

How do I boot up qemu with the gparted live cd? Also can I use gparted over ssh or do I need physical access to the server?
0
 
LVL 6

Expert Comment

by:Jelcin
ID: 33660911
sudo qemu -daemonize -boot d -m 512 -hda /home/user/qemu/debian_stable.img -cdrom /home/user/qemu/gparted-live-0.6.2-8.iso -net nic,vlan=0, macaddr=52:54:00:12:34:56 -net tap, vlan=0, ifname=tap0

That's how i start my qemu VM. For you it is important to give qemu "-boot d" for CD-ROM (c would be hdd) and "-cdrom /path/to/gparted" for the path to CD-ROM image.


0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 10

Author Comment

by:mstrelan
ID: 33661284
Thanks, I will give it a go in the next 10-18 hours and report back.
0
 
LVL 10

Author Comment

by:mstrelan
ID: 33667652
When I try to start using qemu I get "Could not initialize SDL - exiting". From what I have read this is because I'm accessing the server via SSH, rather than a Windowed environment such as Gnome or KDE.

Do I need to install Gnome and then physically access the server to achieve this or can I partition the drive without a GUI? I read that I can simply run e2fsck followed by resize2fs, but I can't do this because the drive is already mounted when I access it over ssh.
0
 
LVL 10

Author Comment

by:mstrelan
ID: 33669300
Oh I finally got it! I needed to install a vnc server, then add -vnc :1 to the command above. Then I can access it via vnc on my desktop!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Create your own, high-performance VM backup appliance by installing NAKIVO Backup & Replication directly onto a Synology NAS!
Last article we focus in how to VMware: How to create and use VMs TAGs – Part 1 so before follow this article and perform the next tasks, you should read the first article how to create the TAG before using them in Veeam Backup Jobs.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

911 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now