Boot/qemu writable FS on USB


Forum: DSL Embedded
Topic: Boot/qemu writable FS on USB
started by: FarrisGoldstein

Posted by FarrisGoldstein on Feb. 28 2005,17:02
Forgive me if this is the wrong forum, as what I want to do may not be possible with DSL Embedded.

What I'd like to do is to be able to keep a decent sized usb drive (about half a gig) with an entire file system and DSL installed on it that will be bootable from within Windows using qemu. The catch is, I would like very much to be able to write directly to the USB drive as if I were booting a VM with VMware using raw disk access.

The purpose of this is that I do a lot of "hotdesking". I'm frequently on different desktop PCs with work, and rarely have the option of running linux on them. If I can do the above, it would be easy for me to stay in Windows on the work machines and still have a usable/writable linux desktop wherever I go.

So, is something like this even possible? I look forward to your advice.

Posted by cbagger01 on Feb. 28 2005,17:42
You can do this and write to the "Virtual Hard drive" image file that it on your USB drive.

However, if you want to write directly to the USB drive's root directory, this is not easily possible.

My solution is to do this:

1) Install samba.dsl
2) From MSWindows Explorer, add Network sharing to my USB drive letter (E:\ drive)
3) Use LinNeighborhood or the command line program smbmount to mount the Windows network share for the USB drive at mountpoint /mnt/winusb
4) Enjoy

Posted by marker on Feb. 28 2005,17:54
i duno if that can be done, going through qemu and all, but what I do is use samba... cause it works great.. here's a stupid little script i wrote to mount drives (including usb drives)

Code Sample

#!/bin/sh
#
# mountdrive <ip> <driveletter> <username> <passwd>

sudo mkdir /mnt/$2
sudo smbmount //$1/$2\$ /mnt/$2 -ousername=$3,password=$4,uid=dsl


to mount e$ on ur machine as nt user/pass to /mnt/e
Code Sample
mountdrive 192.168.0.5 e user pass


it at least gives you r/w access through smb protocol.

Posted by marker on Feb. 28 2005,17:56
forgot to mention as cbagger wrote,
you would need to install samba.dsl
or remaster with that package installed (which is what i did)

Posted by FarrisGoldstein on Feb. 28 2005,18:28
Thanks guys, I'll give this a shot.

Is there some piece of logic I'm missing as to why it isn't easy to give qemu raw access to a USB drive, install DSL onto it, and then write changes/installs directly to the drive from within Windows? I know it's not really a good comparison, but I can do precisely this with something like VMware. I was just hoping to do it with a little less overhead using qemu.

Posted by cbagger01 on Feb. 28 2005,23:08
The virtual PC inside QEMU is not allowed to have direct access to your PC hardware like your USB ports or your CDROM drive.

When running QEMU on a Linux-basec computer (IE: Linux is the host OS), it is possible to access some devices but USB support is not yet provided.

Posted by Fordi on Mar. 10 2005,14:42
Wayell, for linux, actually, you'd just have to use the /dev/sd?? block device that's allocated for the USB stick.  

For Windows, I can't see why there's not a way (what about the \\?\Device\.... UDL filenames for things?  I'll look into this.)

Posted by Fordi on Mar. 10 2005,14:57
Ok, here's the thing.  I can be done.  With some code rewrite of QEMU (it's really just generalizing the disk IO code to use winioctl.h's functions rather than stdio.h).  But, we have a problem:

Access will be denied for device reads and writes if the device is locked for use.  Like, you know, if you're running a program off the stick, or you have it open in explorer.  In other words, you'd need to partition the medium, and you couldn't access the "data" partition by both operating systems at the same time.

But yeah, it can be done without samba.  Unfortunately, much like giving a 30-pound tom cat a purple mohawk, you'd probably hurt something and you'll most likely end up with less-than-satisfactory rewards.

Posted by cbagger01 on Mar. 11 2005,03:43
Fordi,

Once again you have demonstrated that anything is possible if you think big.

My brain tends to automatically discount any option that requires C programming skills and a custom recompile of an application that I don't fully understand how to use,  nevermind how to change. :)

If someone wants to actually do this thing, I wish them the best of luck, sincerely.

Posted by Sparky on Mar. 11 2005,21:43
Hi all;

(note: go gentle, it's my first time <grin>)

I stumbled across this forum after playing with < Private Virtual Machine >.  This is a pre-beta packaging of dsl w/qemu.

I unzipped the d/l to my usb drive and launched launched a qemu bat file.  Automagically detected broadband, keyboard, etc.  I was running a full DSL session from w/in a window on my Win2k box (emailing, surfing) w/in a few minutes.  

The only thing:  It is dog-slow.  D-O-G slow.

But it sure whet my appetite.

-Sparky

Posted by pcause on June 26 2005,18:29
QEMU can't access raw devices, and it doesn't let you mount Windows drives.  It needs a file to use as the virtual hard disk.  To use the USB drive, what you can do is use the qemu-img program (not part of DSL's embedded, unfortunatley) and create a file on the USB drive.  Then edit the dsl-windows.bat file and add -hdx=x:\filename - where hdx could be hdd hde, etc and c:\filename is the path of the file you created using qemu-ing.  Now when you start DSL, you can use fdisk hdx to create partitions on the file and then use mkfx -t ext2 tpo create a file system.
Posted by cbagger01 on June 27 2005,04:42
I think he meant

mkfs -t ext2 /dev/hdx

to create a filesystem for partition hdx

Posted by plenTpak on July 01 2005,02:03
I just experimented this today on Windows 2000 and was looking for more information. I was able to mount and read/write to a drive using "qemu -hda \\.\d:" (well, along with all the other arguments and such... it may also work in linux with -hda /dev/hd1 or similar...).

I was able to install Windows XP on it, restart the drive, and boot up Windows XP. However, it seems to (and I'm guessing here) treat the drive as an img file, since when I try to view the drive in Windows Explorer, the drive shows as unpartitioned.

So it seems like it would be possible to modify qemu to write to the drive normally, if someone who knew how to do it wanted to work on it... this feature might even be in development (this was the first site I stumbled across, so I haven't researched it too thoroughly yet...).

Tried doing the same thing in dsl (since this is a dsl forum) but I'm not familiar with linux, so I couldn't figure out how to mount the drive from inside qemu/dsl...

Posted by plenTpak on July 01 2005,02:17
Oh yeah, also, trying to boot from an existing drive (like running "qemu -hda \\.\c:" in Windows) causes qemu to stop responding (but continue using cpu cycles). I'm guessing qemu doesn't know what kind of file system it's reading, so if someone wanted to develop direct disk access from qemu, they'd need to handle that.

Barring that, it'd be nice if we could mount the .img files as a virtual drive, or edit them as if they were .isos or .zips.....

Posted by mstrhelix on July 29 2005,00:30
It seems very strange that when i chose to compile Qemu for winXP the packages i downloaded to install it ,MinGW . After installing it the program drops me into a shell and in windows i can place files in a certain directory and when i run the program it drops a shell and sees the new files........
Posted by mstrhelix on Aug. 08 2005,16:22
>Barring that, it'd be nice if we could mount the .img files as >a virtual drive, or edit them as if they were .isos or .zips.....

Actually you can unpack ISO's with MagicISO, you can get it here:  http://www.magiciso.com/download.htm

there is also instructions on the main page of magiciso.com.

after you edit the iso all you do is restart qemu with newiso.

Posted by lra on Aug. 08 2005,21:43
but qemu's disk format are not iso images - been there, tried that!

it IS possible to mount (raw) images as a virtual drive in linux, so yes, you can get access to the files inside the image outside of qemu. haven't tried writing to inside the image though.

iirc:

mkdir /mnt/newmntpoint
mount -o loop /path/to/imagefile /mnt/newmntpoint

Posted by mstrhelix on Aug. 14 2005,16:05
>but qemu's disk format are not iso images - been there, tried that!

You didn't try hard enough then cause i mount ISO images using Qemu every time i wanna test the ISO to see if it will work or not.
I have also booted dsl1.4.iso with Qemu with no problems at all.


qemu -hda image.iso

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