QEMU virtual harddrive


Forum: DSL Embedded
Topic: QEMU virtual harddrive
started by: Hasbro35

Posted by Hasbro35 on Jan. 10 2005,23:44
I tried to replace the existing QEMU virtual harddisk file "harddisk" by using "qemu-img create harddisk 500M" (I am using a  1 GB Lexar Jumpdrive)

The command line above creates a 500M file in the default RAW format.

Two questions:
1. Is RAW the correct format?
2. Are there default files on the default 60K harddisk that need to be copied to the new 500MB harddisk (if so is there a better method to upgrade the size of the virtual drive file)?

Posted by roberts on Jan. 11 2005,05:20
I do not use the qemu-img program. Instead I do everything from DSL.
To make the pseudo harddrisk I used the following 2 steps from DSL.

dd of=harddisk bs=1024 seek=60000 count=0

mke2fs harddisk  ( ignore the warning and proceed )

There are files on the default 60MB harddisk. The backup.tar.gz is there.
Since qemu is a "known" virtual machine, it has a pre-made backup.tar.gz on hdb The sound blaster modprobe is in the opt/bootlocal.sh.

If you make a larger pseduo harddisk, with a different name of course, then mount both the 60MB and your new one.

Something like this:

mkdir /mnt/test2

mount harddisk /mnt/test -o loop
mount newdrive /mnt/test2 -o loop

Then copy over the backup.tar.gz.

cp /mnt/test/backup.tar.gz /mnt/test2
umount /mnt/test
umount /mnt/test2

Then you can delete the 60MB one, rename the larger one to harddisk and you should be good to go.

Posted by pcause on June 22 2005,00:37
Do you do the dd command from DSL running under qemu?  What direcotry are you in when you do the command?
Posted by meo on June 22 2005,07:29
Hello pcause!

I've made a small HOWTO about the matter (for personal reference) and here it comes:


HOWTO make a new virtual HD in DSL-embedded

Boot from DSL-embedded on a usb-drive

Make the new virtual hd in “Xshells -> Root Access”

#mount -rw /dev/hda1 /mnt/hda1

#dd if=/dev/zero of=/mnt/hda1/harddisk bs=1024 count=410000
(This will create a 400 MB virtual drive; that's what I use)

#mke2fs /mnt/hda1/harddisk
(Just ignore any warning and proceed)


Copying over files to the new hd

#mount /mnt/hdb

#mount /mnt/hda1/harddisk /mnt/test -o loop

#cp /mnt/hdb/backup.tar.gz /mnt/test

#umount /mnt/hdb

#umount /mnt/test

As you can see I prefer to make the new drive on hda1 and that means I can use the actual name harddisk. So you can do it either ways.

Have fun,
meo

Posted by pcause on June 22 2005,10:50
Thanks and that is an excellent write up.  Unfortunately, my laptop can't boot from a USB device.  Is there was way to do this from DSL running on qemu?
Posted by roberts on June 22 2005,18:29
Qemu provides a virtual machine. You have access to these currently "too small" drives that you wish to make larger. So, no. You need to access some physical drive that can provide the space to create the larger file, the "virtual drive" in. Even if you have a monster windows box and you have enough ramdisk for this file, you would still need samba or some such setup to make it possible to write this file to a real hard drive. It is so much easier to boot from DSL to do this task.

Since your question really has nothing to do with DSL, maybe you should check the Qemu support site. If you find a way. Please share.

Posted by pcause on June 23 2005,10:50
The solutions I have found are to use qemu-img or a Windows "dd" program.  Haven't tried the windows dd program yet, but here is the one I've found -< dd for windows >
Posted by jason_kronz on July 11 2005,18:02
I had problems with all the above procedures.  This is what worked for me.  btw,  I do not keep the original backup.tar.gz file in this process.  I haven't found an easy way to do that.  I believe that it is not needed on new installs.  But I'm a DSL newb so that may be incorrect.  Someone please post if this is not the case.

I had the problem of not being able to install to a 128M pendrive because it really only had 124M (bad sectors).  So I actually needed to make a smaller harddisk, before I could even boot to DSL.

These instructions are done on Ubuntu Linux as the host system.

Make the pendrive as per the embedded instructions first.  If you had the problem like me of too small of a destination then remove the "/qemu/harddisk" file from the copy.  Thats the file we are going to recreate.  I would imagine most people will be installing to larger pendrives (not smaller like mine) and won't have a problem as you'll be just replacing the "harddisk" file.
(btw qemu was not part of the regular Ubuntu install - "#apt-get install qemu" will help out there)

I'm assuming your pendrive is /dev/sda1 substitute if different.

Make sure it is mounted:
#mount -t vfat /dev/sda1 /mnt/sda1

#cd /mnt/sda1/qemu
#qemu-img create harddisk 56M  <--Change to what size you want here.
#mke2fs harddisk     <--- Ignore the warnings...hit y to proceed


Now boot DSL.  (I used QEMU exclusively so it should work for you too).

At this point the drive was visible under DSL, but it wouldn't work (unknow filesystem).  I'm not completely sure why it didn't but it's easy to recreate the filesystem using DSL.

So under DSL:
#mke2fs /dev/hdb  <-- Again ignore the warnings...

Try to do a backup in DSL:
#filetool.sh backup

If you get errors/hangs check the file "/opt/.backup_device" it should have just one line with "hdb" on it.  For some reason mine was empty, but once I added it everything worked.  

Using filetool.sh as a debug tool helps.  It will give you errors that should help you fix any problems that come up.

Once you can backup without errors go ahead and shutdown and restart DSL (for good measure).

You should have a working "hdb" of your new size in DSL.

btw, I'm using a pqi i-stick.  Nothing like having a DSL in your wallet.

Posted by cbagger01 on July 12 2005,03:23
I think that the biggest thing provided by the backup.tar.gz is the startup command that is used to activate the virtual PC's sound card driver.

So if you dumped your backup.tar.gz, then you probably have no sound being produced from inside your DSL embedded PC.

Powered by Ikonboard 3.1.2a
Ikonboard © 2001 Jarvis Entertainment Group, Inc.