Hi everybody,
It is a little disappointing that Cygwin does not support loop devices. ImDisk is a great tool, but it appears only as a mounted volume "/cygdrive/x" and not as a device "/dev/whatever". So we can't use "dd" to copy the boot sector to the virtual disk.
How do you guys handle virtual disks?
Roel
No loop device in Cygwin
-
- Member
- Posts: 141
- Joined: Thu Jun 17, 2010 2:36 am
Re: No loop device in Cygwin
As embarrassing\broken this code is, it's what I wrote really quickly to produce a FAT32 HDD image for Qemu on Windows. I couldn't find any tool for Windows that could edit a binary image from the command line so I decided to write my own.
http://pastebin.com/dEE7vgfX
If you want to use it, you can do whatever you want with it, just keep in mind it's super ghetto. If you improve upon it, it would be nice if you sent me the code for my own use though .
Also, read this to know why Cygwin doesn't have loopback devices.
http://cygwin.com/ml/cygwin-developers/ ... 00005.html
http://pastebin.com/dEE7vgfX
If you want to use it, you can do whatever you want with it, just keep in mind it's super ghetto. If you improve upon it, it would be nice if you sent me the code for my own use though .
Also, read this to know why Cygwin doesn't have loopback devices.
http://cygwin.com/ml/cygwin-developers/ ... 00005.html
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: No loop device in Cygwin
MTools does everything and the kitchen sink on FAT images (And it looks like Rudster missed it because it seems to fit his bill).
I only touch physical storage as the last step to prevent incomplete builds. I always work with images because of that, and because pretty much all VMs and emulators prefer disk images. I have quite a few more tools in my arsenal, but they are all meant to deal with non-floppy or non-x86 platforms.
I only touch physical storage as the last step to prevent incomplete builds. I always work with images because of that, and because pretty much all VMs and emulators prefer disk images. I have quite a few more tools in my arsenal, but they are all meant to deal with non-floppy or non-x86 platforms.
Last edited by Combuster on Mon Mar 19, 2012 11:58 am, edited 1 time in total.
Re: No loop device in Cygwin
I use mostly raw images, so it's obvious to access them.
I've never used ImDisk but if it mounts images, then may be you can access them using something like /proc/sys/Device/HarddiskX/Partition0
( 1to1 cygwin mapping of Windows NT native \\.\Device\HarddiskX\ ), X is a number, Partition0 means accessing to the whole disk starting from sector 0, not to a partition. Be careful, you may accidentally erase your harddrive.
I've never used ImDisk but if it mounts images, then may be you can access them using something like /proc/sys/Device/HarddiskX/Partition0
( 1to1 cygwin mapping of Windows NT native \\.\Device\HarddiskX\ ), X is a number, Partition0 means accessing to the whole disk starting from sector 0, not to a partition. Be careful, you may accidentally erase your harddrive.
-
- Member
- Posts: 141
- Joined: Thu Jun 17, 2010 2:36 am
Re: No loop device in Cygwin
Just compiled it on Cygwin (odd that Cygwin doesn't provide a package for it), it looks very promising, thanks!Combuster wrote:MTools does everything and the kitchen sink on FAT images (And it looks like Rudster missed it because it seems to fit his bill).
I only touch physical storage as the last step to prevent incomplete builds. I always work with images because of that, and because pretty much all VMs and emulators prefer disk images. I have quite a few more tools in my arsenal, but they are all meant to deal with non-floppy or non-x86 platforms.
To anyone who compiles it on Cygwin, I had to edit the Makefile to include the libiconv library.
I changed the line (line 61 on my generated Makefile)
LIBS =
to
LIBS = /lib/libiconv.a
obviously you'll need libiconv installed (Cygwin provides a package if you don't already have it).
Re: No loop device in Cygwin
I use ImDisk to create/mount the image file and partcopy for inserting the bootsector or direct copying of sectors. The kernel gets copied using Windows normal copy command since it's a FAT12 image.
Re: No loop device in Cygwin
Please check out the extended article for diskpart
Re: No loop device in Cygwin
Nable, that would be "/proc/sys/Device/ImDisk0" in my case. It's ugly but it works. Thanks!
EDIT: I added this to my Makefile, so I can run "make mount boot unmount":
EDIT 2: Using device name "/proc/sys/DosDevices/Global/$(MOUNT):" is even better because it eliminates the need of UNIT, so ImDisk can pick the unit number itself. It also makes the code independent from ImDisk.
EDIT: I added this to my Makefile, so I can run "make mount boot unmount":
Code: Select all
IMAGE = hobbes.img
UNIT = 0
MOUNT = h
DEVICE = /proc/sys/Device/ImDisk$(UNIT)
DRIVE = /cygdrive/$(MOUNT)
boot : boot.bin
dd if=$< of=$(DEVICE)
mount :
imdisk -a -m $(MOUNT): -o fd -o rem -f $(IMAGE) -u $(UNIT)
unmount :
imdisk -d -m $(MOUNT):