QEMU Tips

From Marss86

Revision as of 10:25, 19 November 2011 by Avadh (Talk | contribs) (Serial Console Setup)

Increase QEMU Image Size

Follow steps given below to increase the size of QEMU image.

1- Convert to a raw image

   qemu-img convert system.qcow -O raw system.raw

2- Increase the size of the raw image

   dd if=/dev/zero of=system.raw seek=N obs=1GB count=0

where N is the number of GigaBytes

IF NTFS: Fix the NTFS BPB Edit the raw file: hexedit system.raw Goto to offset 7E00: 7E00 Change 80 to FF at offset 7E1A and save: FF --> Ctrl-x --> y

3. Use gparted or other similar live-cd system to resize your 'ext' or 'ntfs' partitions

4. Boot to your new disk image and make sure everything is working fine.

5. If you need to save space, convert back to qcow

   qemu-img convert system.raw -O qcow growed-system.qcow

QEMU and GDB

When running QEMU under gdb, gdb stops on every signal received by QEMU. QEMU uses SIGUSR2 as timeout for VM, we can ignore this signals and continue with our debugging. To disable this signals you can give following command in gdb terminal.

   (gdb) handle SIGUSR1 SIGUSR2 noprint nostop

Serial Console Setup

Reference: [1]

Create /etc/init/ttyS0.conf file with following contents:

# ttyS0 - getty
#
# This service maintains a getty on ttyS0 from the point the system is
# started until it is shut down again.

start on stopped rc RUNLEVEL=[012345]
stop on runlevel [!012345]

respawn
exec /sbin/getty -L 115200 ttyS0 vt102

Only change in the file from above link is I have added run level 0 and 1 also to start serial console. After enabling this serial console you can use '-serial pty' option in Marss command line to forward serial console to a 'char' device. Then you can use any scripting language to perform repetitive tasks.

Automatic Login to Console

If you want to automatically login to either serial or default console than add following line at the end of tty configuration.

For default console tty1 edit /etc/init/tty1.conf:

exec /bin/login -f root < /dev/tty1 > /dev/tty1 2>&1

For serial console ttyS0 edit /etc/init/ttyS0.conf:

exec /bin/login -f root < /dev/ttyS0 > /dev/ttyS0 2>&1
Personal tools