Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Increase hard disk size of QEmu/KVM image

Posted on 2010-09-12
6
Medium Priority
?
2,976 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 2000 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
Threat Trends for MSPs to Watch

See the findings.
Despite its humble beginnings, phishing has come a long way since those first crudely constructed emails. Today, phishing sites can appear and disappear in the length of a coffee break, and it takes more than a little know-how to keep your clients secure.

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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.
This article will explain How to fix Broken backup chain in Veeam Backup & Replication.
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…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Suggested Courses
Course of the Month13 days, 10 hours left to enroll

963 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