How can I convert directories to disk images so I can import them into my virtual machines?

Discussions about using non Windows and Linux guests such as FreeBSD, DOS, OS/2, OpenBSD, etc.
Post Reply
ZenHacker
Posts: 22
Joined: 1. Jul 2015, 20:26
Primary OS: MS Windows 7
VBox Version: PUEL
Guest OSses: MS-DOS 6.22, Kali Linux, Plan 9, Metasploitable
Location: COMMAND.COM

How can I convert directories to disk images so I can import them into my virtual machines?

Post by ZenHacker »

I need a free solution for converting between directories and disk images. I want to be able to convert a directory to an ISO file or floppy image that I can then insert into a virtual machine. I have downloaded a lot of abandonware in the form of directories containing the necessary binaries, but I am restricted to using this software in DOSBox. This is fine when I'm using something like Wordstar, but if I have software that requires the insertion of multiple floppies in succession, it can become problematic.

I know MagicISO has floppy image conversion capabilities, but it costs money, something that I don't currently have, and no, I don't want to download the trial version. Another solution I could use is to create an archive of the directory, then write a simple C program to reverse it, use dd to cut off the tar or cpio headers, reverse it back, then change the extension to .iso or .ima. I'm not sure if this would work, because I don't know if there might be other file delimiters left by tar/cpio that would make it incompatible with the raw formats. What are your suggestions?
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: How can I convert directories to disk images so I can import them into my virtual machines?

Post by socratis »

ZenHacker wrote:I am restricted to using this software in DOSBox
This isn't really a VirtualBox question, is it? In any event, if I'm not mistaken, your host is running OSX, based on your previous posts. For future reference, don't leave such vital details out of your questions.

If that's the case, open Utilities, Disk Utility. From the File menu select New -> Disk Image from Folder... You can select Compressed (dmg) or DVD/CD master (cdr). VirtualBox can mount them both on your VM.
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
ZenHacker
Posts: 22
Joined: 1. Jul 2015, 20:26
Primary OS: MS Windows 7
VBox Version: PUEL
Guest OSses: MS-DOS 6.22, Kali Linux, Plan 9, Metasploitable
Location: COMMAND.COM

Re: How can I convert directories to disk images so I can import them into my virtual machines?

Post by ZenHacker »

I used Disk Utility to create a disk image from a directory. VirtualBox failed to open the file. It saves it as an Apple disk image (.dmg or .dmg.cdr), which VirtualBox doesn't recognize. Can you help me with this?
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: How can I convert directories to disk images so I can import them into my virtual machines?

Post by socratis »

OK, I can swear this was working. It isn't (host 10.9.5). I will investigate what is going on.
First time that I don't actually verify an advice, and @%# happens! :evil:
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: How can I convert directories to disk images so I can import them into my virtual machines?

Post by socratis »

It's not quite what I thought it would be. Last time I tried it I wasn't on VBox 5.x on OSX 10.9, so I'm not sure if something changed. But, here's a command from the Terminal that will do what you want:
   hdiutil makehybrid -o "<Path_to_output>.iso" -iso -joliet "<Path_to_folder>"
I was able to mount the image in VirtualBox with no problem. I also have a physical Windows 7 host and I was able to mount the image with "ImDisk Virtual Drive" (free, open source), "Virtual CD-ROM Control Panel" (free, Microsoft), "Daemon Tools (adware)" and natively in Windows 8/10, but not with "ISODisk" (expected, there's a warning for Win7). I guess 4/5 is OK ;)
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
Post Reply