Disk Images

Optical Disc formats
ISO 9660
[#usecdimg]: Using/mounting an existing image
Unix
[#unxcddrv]: Mounting an image on an actual disc in a local optical drive

(This information is based on pre-written text from: TOOGAM's Software Archive: Information about mounting CDs in Unix.)

Mounting an actual optical disc from a drive is rather straightforward and easy once one is familiar with how to mount other file system volumes, such as the ones storing information on a hard drive, and once the CD device is known.

[#mntwchcd]: Determining which device represents the desired optical drive

To check the name of the optical drive, try using:

ls -l /dev/*cd* /dev/*dvd*

If that turns up only one result, that is probably it. If it turns up many results, consider narrowing down the output to something like:

ls -l /dev/cd*

The rest of the text in this specific section is about trying to find any optical drive that may be in the system. (In a system with multiple optical drives, experimentation is often the quickest and most convenient way to determine which block device in the operating system corresponds to which drive.) Some of this text may be aimed at helping to locate the “first” optical drive that the operating system detected.

If there are multiple results, and one of them is /media/cdrom, then that filename is probably a link to the correct device, and so using /media/cdrom is probably an excellent choice. Otherwise, if /media/cdrom does not exist, but other /media/cdrom* do exist, then using those devices are probably the preferred ones. (Specifically, as one can figure out by following the next rule, the one with the lowest number may be most likely.)

If there are multiple /dev/cd* filenames that have different numbers in them, such as /media/cdrom0 and /media/cdrom1 and /media/cdrom2, the desirable block device to use is probably one with the lowest number.

For another example of how using the lowest numbered device may be correct, consider the default devices that might be seen in a standard OpenBSD installation. The filenames that look like they might be block devices might only include the following: /dev/cd0a and /dev/cd0c and /dev/cd1a and /dev/cd1c. Using the example devices shown above, one of the /dev/cd0? block devices will be the desired one to use. (In this above example, /dev/cd0c is the desired device. Using the entry that ends with c is similar to how OpenBSD handles partitions on a hard drive, something one generally learns when installing OpenBSD and learning how to make a proper BSD “disklabel”. (Other operating systems may refer to BSD “disklabel” as a “bsdlabel”.))

If a /media or /mnt subdirectory exists and a *cd* subdirectory exists under one of those things, that is probably meant to be the mount point of a CD. (Given the choise, when the mounted device is some sort of removable media, /media/ is the newer standardized preference, rather than the older /mnt.

The mount command will need a -t parameter. Following the “ -t ”, another required parameter is needed. The exact parameter to follow -t is not consistant among all optical discs in Unix, and may not be consistent for the same optical device if accessed by different versions of Unix. If the optical disc uses the UDF file format, try -t udf. If the optical disc uses ISO 9660 CDs (which is the most common format for CD images), the parameter may be “ -t cd9660” (particularly in BSD) or “ -t iso9660” (in operating systems using the Linux kernel).

Specifying “ -o ro” is generally unnecessary. Specifying “-o ro,unhide” is generally unnecesarry. (One exception is the WoW:WotLK UDF DVD when used under Debian. However, using -o ro,unhide in other operating systems may not work (because mount may cite “unhide” as an unsupported, invalid option).

So, an example of all this may be:

mount -t udf /dev/*cd* /media/*cdrom*
echo Note that the above may need customizing.

Additionally, support is generally included in the operating system to be able to mount *.iso (ISO 9660 CD) images. However, most operating systems which support this functionality will require an additional procedure, not just mounting a *.iso image directly. (This might not have been true with some older versions of Linux.) The secondary procedure may involve creating a “vnode” device with a separate command (and then, to cleanly free up resources, un-creating that device after unmounting the drive), or using an altered mount command (specifying some additional parameters). (See: Mounting disk/disc images in Linux, Mounting disk/disc images in OpenBSD, and Mounting disk/disc images in OpenBSD.)

Mounting CD images

The section about mounting an image on an actual disc contains some complexities which are not duplicated here. Basically, everything in the section about mounting an image on an actual disc in a local optical drive, except that the /dev/ directory isn't getting used.

Mounting a CD image file, which is a file on another accessible location storing data, may be a bit more complex than if data is read straight from an optical disc drive. This section addresses added complexity that comes from dealing with such files.

Making the image

First, the image needs to pre-exist. If the image is on a physical CD in an accessible physical CD-ROM drive, one may be able to make the image. (It might be somehow a tiny bit safer to unmount the drive first.) See the section on making a CD image.

[#mntcdlnx]: Mounting the image in Linux

Support for mounting images is built into standard Linux distributions. The syntax may be:

mkdir /mntpoint
mount -o loop -t iso9660 filename.iso /mntpoint
[#mntcdobs]: Mounting the image in OpenBSD

OpenBSD FAQ 14: Section about mounting disk images in OpenBSD (FAQ 14.11) discusses mounting a disc image with built-in software. One does need to be a superuser to perform this task. Since OpenBSD comes with the sudo, the example command lines will show the sudo being used. (If you are the root user, you may just leave off the word “sudo” from the example command lines.)

First, before using up one of the virtual node (“vnd”) devices, see which one(s) may be in use. Run:

sudo vnconfig -l

On a common system that is largely based on a default installation, there might be four “vnd” devices which are all not in use. For example, the output may be:

vnd0: not in use
vnd1: not in use
vnd2: not in use
vnd3: not in use

Plan to use one of the “vnd” images which is shown in that output, but which is not in use.

Note: The OpenBSD Updating Process may use vnd0. If the device is going to be mounted over a long period of time, plan to use a differnet “vnd” device if possible. Once a “vnd” device is in use, resources are reserved and that “vnd” device is not available for other purposes until those resources are freed up.

The preferred method of mounting depends on what version of OpenBSD is being used:

Mounting an image with a virtual node in OpenBSD 5+
sudo vnconfig vnd1 input.iso
sudo mount -t cd9660 /dev/vnd1c /mntpoint
Mounting an image with a virtual node in OpenBSD 4.x and earlier

The Changelog for OpenBSD 5.0 notes, “Removed svnd backward compatibility from vnd(4).” (OpenBSD 4.9 manual page for vnd stated, “There are two variants, the traditional vnd that bypasses the buffer cache and thus is suitable for swap on files, but not for building disk-images, and the svnd (``safe'' vnd) variant that goes through the buffer cache, thereby maintaining cache-coherency after the block-device is closed which makes it suitable for creating disk images.”

Before support for this was removed, the official documentation did show using an “svnd” device. So, the commands to mount would be:

sudo vnconfig svnd1 input.iso
sudo mount -t cd9660 /dev/svnd1c /mntpoint
[#obsdvndu]: Cleaning up when done

After the device is no longer needed, an image may stop being used with two steps. Before performing these steps, it might be helpful to run “ vnconfig -l ” to help identify which virtual nodes are being used.

Unmounting the image
sudo umount /mntpoint

Or, the umount command may also be given the (/dev/*vnd*) device that was mounted, instead of the mount point where the device got mounted to.

Stop using the virtual node

This step frees up the resources so that the previously-allocated “*vnd*” device may be used for other purposes.

e.g.:

OpenBSD 5.0 Example
sudo vnconfig -u vnd1
Example for earlier versions of OpenBSD
sudo vnconfig -u svnd1

Of course, this should match what device was allocated earlier. If the above examples have been used, older versions of OpenBSD may need to make a reference to something like svnd1 instead of vnd1.

[#mntcdfbs]: Mounting the image in FreeBSD
Mounting an image in FreeBSD 5.x and newer
mdconfig -a -t vnode -f filename.iso -u 1

The -u parameter ends up specifies the device that becomes mountable, so -u 1 causes /dev/md1 to become mountable. This may then be mounted similar to using an optical disc directly.

mount -t cd9660 /dev/md1 /media/cdrom

To undo this, use “umount /media/cdrom” and then use “mdconfig -d -u 1

FreeBSD 4

In FreeBSD 4.x, mount with two commands:

vnconfig /dev/vn0c ./image.iso
mount -t cd9660 /dev/vn0c /cdrom

Umount with a standard “umount /cdrom” followed by “vnconfig -u /dev/vn0c

This whole process in FreeBSD 4.x is similar to the process of mounting CD images in OpenBSD, and the process is noted at The FreeBSD Diary's page on mounting an ISO image.

Microsoft Windows
Using CD images

Details about some other possible options may be at TOOGAM's Software Archive: Windows software for virtual optical drives.

Microsoft's Virtaul CD-ROM Control Panel

For example, An option that comes straight from Microsoft is the Virtual CD-ROM Control Panel. This may not work quite as well with some operating systems: It may be meant for Windows XP, work unofficially with Windows 2000 (according to Software Patch's review of MS Virtual CD-ROM Ctrl Panel applet), and work less well in Windows Vista (Blog discussing usability in Vista says the virtual drive's contents may only be accessed as an Administrator). Directions for MS Virtual CD-ROM Ctrl Panel applet (possibly split across an advertisement that is in the middle of the instructions) gives some step-by-step instructions.

http://www.ltr-data.se/opencode.html/ provides software called ImDisk for WinNT/2K/XP/newer. (Note: at the time of this writing, this software hasn't been tested or verified by the author of this text. So, please perform any warranted caution needed to ensure proper system stability/security.) This is open source.

WinCDEmu is LGPL. (That is according to Wikipedia's page on WinCDEmu, which contains a box near the bottom of the page. That box contains hyperlinks to some other projects.) (Note: at the time of this writing, this software hasn't been tested or verified by the author of this text. So, please perform any warranted caution needed to ensure proper system stability/security.) The web page notes this supports WinXP through Windows 10, and that the avaiable sources can be used to create an unsupported “Win2K-compatible version.”

A web page called Windows driver examples (Mirror: Windows driver examples) provides FileDisk and HttpDisk, both of which allow mounting CD images without requiring Administrator privileges. Source code may be included with the programs' distributions. WinImage: Filedisk 64-bit referneces filedisk with tray icon. (Note: at the time of this writing, this software hasn't been tested or verified by the author of this text. So, please perform any warranted caution needed to ensure proper system stability/security.)

To mount, an option for home, personal, and non-commercial purposes may be Daemon Tools Lite, downloadable from Daemon Tools Download Site. The installer may ask about installing some optional unrelated software as well. Once installed, the software can be pretty easy to use by interacting with the shortcut/context/“right-click” menu of an icon that is in the “system tray”/“message notification area”.

Extracting files from images
To extract files, see 7-Zip. The main website has software for Microsoft Windows (both for use by the command line, and software that uses a GUI), and there are versions of the software for other platforms. Another option could be to mount the image. There may be some additional software to choose from: see TOOGAM's Software Archive: Archivers: section related to optical images.
[#mkopdsim]: Making a data image of an optical disc
If there is an existing CD

This may be very similar to the topic of making images of exiting (bootable) media.

Unix
Using dd

Knowing which device represents the desired optical drive will be needed. Getting all the standard data off of the CD may be done with the dd command. Note that for optical drives, the dd command may fail unless specifying a valid block size of 2048. If the device being used is /dev/cd0c (which will probably work in OpenBSD for the first CD device, but may be named different in other operating systems), then

dd bs=2048 if=/dev/cd0c of=output.iso

Very often the dd command may be used with devices that require permissions to access. Unlike file permissions, setting permissions on a device may not be enough to make a device really fully accessible to another user. (The exact requirements may vary between operating systems.) For a one-time event, trying to modify permissions may not be as easy as successfully accomplishing the desired goal by just running software as a superuser.

Note: The dd command is not really designed to handle errors in a useful manner. Other software may be in some ways better, such as by being safer if using subpar equipment (including media). The advantage, though, is that the dd command is generally pre-installed on many/most Unix machines.

It may be possible to get a status report from dd by sending it a signal. The first step is to identify the PID of the running dd process. (See “listing what is running” for details on that.) In OpenBSD, the status report may be done by sending a SIGINFO signal. (To do that, run “ kill -s SIGINFO pidNumber ”, customizing pidNumber as needed, and using sudo if needed.) Wikipedia's article on dd (Unix): “Progress Information” section says that using -USR1 works in Linux/Ubuntu: It is verified that using -USR1 will terminate the dd program in OpenBSD.

If a status report is being requested, the progress output will come from the dd command (not from the kill command). So, so after running kill, if no error messages appeared, go check the terminal that is running the dd command.

[#rdcdrtl]: readcd from CDRTools

Another option may be to use readcd from the CDRTools package.

After making sure the program is available (installing the package first, if needed), the first thing to do may be to figure out how to properly specify the drive to use. Some tips are in the section about CDRTools. This non-optional step varies among platforms, and the remaining steps simply assume that the parameters needed to successfully specify the correct device have been successfully figured out.

cdrecord dev=... driveropts=help -checkdrive
cdrecord dev=... -checkdrive
readcd dev=... -v -c2scan
readcd dev=... -v -clone -f=output.raw

Other parameters, such as -noerror and -nocorr or retries=#, should not be needed for most undamaged CDs. (Some forms of “copy protection” have been known to intentionally include what software perceives as damage.) Lowering speed might help in some cases (namely with older drives). Consider using these and/or other options as needed.

If doing a standard read (leaving off parameters like -clone) the output may be bit for bit identical to the output of a dd command. This sort of image might be more compatible with some software (other than cdrecord with its -clone command line parameter).

cdparanoia
Software called cdparanoia may present another option.
Microsoft Windows

Some of the software used to write disc images may be helpful. See writing CD images in Microsoft Windows.

Creating an image from scratch
Creating in Unix
Command line programs

First is some information about some software options to choose from. Following is information about using the software.

CD images

Some software. Before deciding what to download, see what you may already have. Executable names may include mkisofs, mkhybrid, genisoimage. (So, try running “ which mkisofs ” to see if this shows any command. If not, try using one of the other filenames mentioned.)

[#cdrtools]: CDRTools

Software released by Jörg Schilling (which has sometimes been spelled Joerg Schilling).

Usage for mkisofs
Usage:
[#misofbas]: Basic mkisofs command line

Use:

mkisofs -vvrJT -V cdname -o filename.iso directoryName optionalMoreDirectoryNames

The filename to be created should come right after the “ -o ” parameter. The word “ directoryName” in the example is a list of one or more directories. It might be possible to specify filename(s), possibly depending on the version/derivative/variant/clone of mkisofs being used and possibly varying based on what command line parameters are being used (such as if creating bootable media?). The -V cdname is technically optional, but is recommended so that the CD has a recognizable name. (Do note that the parameter after “-V ” is customizable, so give it a sensible name that is less than 33 characters long.)

The “ -v -v ” command line parameters are meant to increase verbosity. (Unusually in the Unix world, at least one variation, mkhyrbid (tested with OpenBSD 4.4), will work just fine using “ -vvrJT ” but will not work using “ -rJv ”. The order of the parameters is crucial.) The “rJ” is optional and causes data to be written in a way that is generally more useful: an operating system may find the files are not stored in all uppercase letters. (If “rJ” causes any issues, try “RJ” or “R”.) The “T” may cause an extra file named TRANS.TBL to be visible. That file is expected to be relatively harmless (taking up only very little space) and may help the CD to work nicer in some environments.

Relying on a Unix command line shell to expand wildcards may be convenient, so to create a CD with all files in the current directory, use:

mkisofs -vvrJT -o ../filename.iso .

The following might also work (even if it seems less consistent with the documentation):

mkisofs -vvrJT -o ../filename.iso *
mkhybrid

For very basic usage, if it is desirable to use mkhybrid instead of mkisofs (e.g. since mkhybrid comes pre-installed in OpenBSD), follow the basic syntax for mkisofs, but just specify to use the mkhybrid command instead of the mkisofs command.

The mkhybrid command

Wayback Machine @ archive.org's archive of James Pearson's page from February 19, 1999 shows what seems to have been a home page for the mkhybrid command.

OpenBSD comes with the mkhybrid command, and the OpenBSD Manual Page for the mkhybrid command references an FTP site for HFS (and another non-working FTP site from ftp://ftp.ge.ucl.ac.uk/pub/mkhfs which was a site also mentioned by Wayback Machine @ archive.org's archive of James Pearson's page from April 30, 1999). The manual page says, “mkhybrid is based on mkisofs and works in exactly the same way as mkisofs without the HFS options. The change in name is to signify that it does something extra. If you do not need the HFS options, then you should really be using mkisofs.” However, there is no indication of why to use mkisofs instead. (Perhaps just the thought that perhaps mkisofs may be using a newer version?) And when mkhybrid is part of the operating system (as in the case of OpenBSD), it may be more convenient than installing the cdrtools package.

Wayback Machine @ archive.org's archive of James Pearson's page from April 21, 2000 shows the page said, “Note: mkhybrid is now part of the cdrecord package.” (The hyperlink did reference J. Schilling's name.)

Creating bootable media with mkisofs

This may have changed over time, so especially be aware of using a very old version.

Try adding the following command line options:

-no-emul-boot -b bootfile -c boot.cat

Note that some of the referenced filename(s) may be the names for (often hidden) files on the CD. If the CD mastering/authoring software can make the files on the fly, then the files may not need to pre-exist.

e.g. to make an OpenBSD bootable disc:

mkhybrid -rJ -no-emul-boot -b $( uname -r )/$( uname -m )/cdbr -c boot.cat -o mybootcd.iso .
Front-ends (for mkisofs

(Some/all of these may not have been heavily tested. Explore at your own risk.)

cdrdao
A graphical interface called gcdmaster may come with cdrdao. An online manual for gcdmaster is available. The software XDuplicator, is another front-end for cdrdao. Wikipedia's page for cdrdao also mentions K3b as a third party graphical front-end.
CDRecord
Options include MyBashBurn which uses text-based windows and is based on BashBurn, X-CD-Roast (uses GTK+) front-end for cdrtools, TkDVD (Savannah site for TkDVD) for dvd+rw-tools and cdrecord, and more. Wikipedia's list of optical disc authoring software lists some, Wikipedia's page about Cdrkit: “Front-ends” section mentions another (Xfburn).
Usage for readcd

The following example shows using readcd although the syntax may be similar for cdrecord. Other included commands, such as devdump might vary, so don't be afraid to refer to actual documentation for the software before running a command.

One way to detect the device to use may be to use “ readcd -scanbus ”. (That doesn't work in all cases. For instance, OpenBSD's port of CDRTools does not support scanbus. At least some CDRTools software in at least some version of Microsoft Windows wasn't stable when using -scanbus.)

Specifying the device

For most uses of readcd (not including readcd -scanbus), the first parameter will be a reference to the device. The specific way to refer to the device may vary among different platforms. An example that works with one platform may not work in another environment. This text may not show every possible example, but does provide some generalizations. Documentation that is meant specific for a platform can certainly be helpful: try to find that (perhaps bundled with the software package, or else from a web page containing information specific to the operating system being used).

Running “ readcd dev=help ” may show some helpful clues.

Otherwise, if such documentation doesn't clearly show how to specify a device, some experimentation, possibly mixed with intelligence such as data gathered from a working execution of readcd -scanbus, may be helpful. (To experiment, consider perhaps trying a quick non-destructive command, such as “ cdrecord -checkcd dev=... ” and then make sure the right optical drive was really specified by using a quick and hopefully non-destructive command line “ cdrecord -eject dev=... ”.)

Having stated all that, the following generalized information is provided in case this helps at all.

readcd dev=deviceName:#,#,#

For some platforms, the “deviceName: might not be needed at all, leaving only dev=#,#,#. Documentation bundled with the port for OpenBSD shows that distribution of the software uses deviceName (e.g., quite specifically for OpenBSD, a /dev/rcd0c file may be applicable) and does not use :#,#,# at all. (The man page, which is more largely based on the main CDRTools distribution, says, “Some operating systems or SCSI transport implementations may require to specify a filename in addition.” Despite those last two words, “in addition”, the OpenBSD variant uses the device name instead of any other references.)

The manual page for cdrecord shows a similar syntax where REMOTE:username@hostname: may be used in place of a deviceName or, varying the syntax slightly, the username@ could be left off (leaving REMOTE:hostname: as the replacement for the deviceName.)

The comma-separated numbers (#,#,#) refers to a SCSI bus, target, and LUN. Each of those comma-separated numbers are integers. (The # shown is figurative.) However, the SCSI bus may simply be left off. Or, the SCSI Bus and the target may be replaced with a single at sign (“@”) character. Or, all of these numbers (the entire #,#,#) may be replaced with a single at sign (“@”) character.

cdrkit

Article about cdrkit being uploaded to Debian describes the creation of cdrkit being done over an issue of a licence change that was made to the older CDRTools package. Executable names are changed. Jörg Schilling complained about cdrkit, page on CDRecord's site discussing cdrkit

HFS Utilities

HFS Utilities port for Win32, OS/2, and apparently (from the documentation) DOS (although no download for a DOS executable seemed to be visible).

cdrdao
A quick review suggests that this supports TOC files (as well as the BIN/CUE file formats).
DVD software

drd+rw-tools home page says “It should be explicitly noted that growisofs is a front-end to mkisofs, i.e. invokes growisofs to perform the actual ISO9660 file system layout.” (See also: Wikipedia page for dvd+rw-tools.) Note that this software is more than just a front-end to growisofs, as it can actually write to CDs.

Creating in Windows and similar
...
Image compression
See ECM: e.g. Neill Corlett's ECM home page, and the information at TOOGAM's Software Archive: Archivers: section related to optical images. (General purpose formats for compressed data, like a Zip file, may be inferior.)
[#writtocd]: Writing data to an optical disc

Note: this guide may be assuming that the data is ready to be written to a disc. Making a data image of an optical disc might be a step that needs to be performed prior to trying to write the data, at least for the data writing portion to be a simple and smooth process.

In Unix
Writing a DVD image

OpenBSD FAQ 13: section about writing DVDs (FAQ 13.10.3) says, “At the moment, the best option is growisofs from the sysutils/dvd+rw-tools package.” “This utility writes an ISO 9660 image to the DVD medium.” This “best option” does not come with the operating system, so the first step to using this solution is to install the software (if it wasn't previously installed). (See: installing software (using pkgtools).)

For writing to the disc, the preferred software may depend on the disc type. The drd+rw-tools home page says, “the DVD burners available on the market can burn even CD-R[W] media and cdrecord is the tool for this job.” (The cdrecord command comes with other software.)

To write to a DVD image, the preferred way is to start by making an optical disc image (in ISO 9660 format). Then use:

growisofs -dvd-compat -Z /dev/rcd0c=filename.iso

Another option that may work, without needing to create an image first, is to use:

growisofs -dry-run -Z /dev/rcd0c -R /dir
Writing a CD image

It is assumed by these instructions that the data is in an image file. (If not, see making an optical disc image.)

There may be various software products able to perform this task. Consider using whichever is pre-installed, unless the pre-installed software doesn't seem to support any sort of burn protection (e.g. buffer overrun prevention) technologies. In that case, seeking out additional software may be worthwhile (just to prevent wasting an optical media disc if writing doesn't work well for some reason).

cdio

If the CD is a re-writable disc that needs to be erased first, perhaps the command to use is:

cdio -f cd0c blank

Use:

cdio -f cd0c -vv tao file.iso
cdio -f cd0c eject

Some more details about this software: OpenBSD's Manual Page for the cdio command: “History” section that comes with OpenBSD says, “The cdio command is based on cdcontrol, which first appeared in FreeBSD 2.1.” CDControl's web page states that the software's “main base is the cdrecord and cdda2wav program. The cdcontrol is” ... “all under GPL license.”

cdrecord from CDRTools

After making sure the program is available (installing the package first, if needed), the first thing to do may be to figure out how to properly specify the drive to use. Some tips are in the section about CDRTools. This non-optional step varies among platforms, and the remaining steps simply assume that the parameters needed to successfully specify the correct device have been successfully figured out.

cdrecord dev=... driveropts=help -checkdrive
cdrecord dev=... -checkdrive
readcd dev=... -v -c2scan
readcd dev=... -v -clone -f=output.raw
[#cdwrtmsw]: Writing to CDs in Microsoft Windows
ISOBURN

Windows 7 Beta 1 introduced isoburn (which has been seen in the %windir%\System32\ directory). Running it without parameters will show help. Here is an example of writing quietly:

%windir%\System32\ISOBURN /q d: file.iso

If a person inserts an optical disk and then pushes the “Burn” button, the software may simply update the “Status” section by showing the following statement: “Please wait while the disc burder ins getting ready, and then try again.” If that is shown, simply wait a second or a few seconds, and try again. (It would have been nice if the software would simply have tried waiting five seconds and then proceeded with an attempt without requiring further user interaction, but apparently that would have been too convenient.)

There is a “Verify disc after burning” checkbox. The softare will (automatically) eject the disc after showing “The disc image has been successfully bruned to disc.” (in the “Status” section of the window).

Copying files to a CD in Windows XP and newer

Some Windows XP documentation:

Writing a CD image to a CD

Besides the options mentioned already, additional options may include:

Some operating systems may require downloaded drivers: see the previous hyperlink for details.

Ejecting and injecting/closing
ejecting
ejecting a drive in Unix

Note that Unix commonly has the drive ignore attempts to eject (even including if the physical “eject” button gets pressed) if a drive is mounted.

OpenBSD has an “ eject device ” that does the same thing as “ mt -f device offline 1 ”. (This will require knowing the name of the device.) (See: OpenBSD manual page for the eject command.)

injecting (closing the drive tray)

Remember that there is no software-based standard that will be able to inject all drives. Some drives, perhaps particularly on laptops that were designed to be light weight when possible, may not provide a capability to have the drive tray be closed by any method except to have someone (or something) physically press the drive bay closed.

There is a pseudo-standard. This may not be an official standard that is specified by any organization of clearly noteworthy authority, and a lot of software does not follow this common trait. However, some software does; enough to know about this as a possibility.

To inject, sometimes software provides the capability using the same interface as an eject command. In some cases, trying to specify that a disc should be ejected, when the disc is already ejected, will inject. In other cases, specifying to eject a disc that is already ejected might have no effect.

injecting/closing a drive in Unix

Note that Unix commonly has the drive ignore attempts to eject (even including if the physical “eject” button gets pressed) if a drive is mounted.

OpenBSD has an “ eject -t device ” command. (This will require knowing the name of the device.) Based on the documentation related to ejecting an optical disc, it seems likely that this may be somewhat related to the “ mt ” command. (See: OpenBSD manual page for the eject command.)

injecting/closing a drive in Microsoft Windows

CDR package by Chris Morse Sebrell (distributed from TOOGAM's software archive) provides a small executable file, with source code.

For Microsoft Windows, IntelliAdmin guide to writing optical discs highlights some updates made to some software made by IntelliAdmin. This article metnions the addition of /close, and states that adding the ability “was tough. Someone emailed me a while back asking if it was possible to programatically close the drive. After lots of searching we came up empty handed. During our update we found an obscure way to make it happen.” The ability is included in IntelliAdmin's BurnDisk.exe program.

There may be some other approaches described by SuperUser: How to close the Optical Drive tray in Windows.

[#udf]: Universal Disk Format (“UDF”)
Overview and other such intro info

Historical Wikipedia Article: Modification from October 2010 removed the following text: “Almost directly after the first version of UDF was released, it was adopted by the DVD Consortium as the official file system for DVD Video and DVD Audio. Nowadays, a UDF file system may be found on most authored optical discs in the market, and on almost all recordable DVD media that are used for video recording.” (Metadata removed from quoted material.)

Specifications

For specifications, Optical Storage Technology Association's specifications for the Universal Disk Format (“UDF”) contains multiple versions. (Microsoft KB Q321640: Reading UDF Disc in Win XP references the osta.org website as a resource for specifications.)

Extensions
See also: Wikipedia's page on Mount Rainier (packet writing), Wikipedia's article on “Live File System”.
Using UDF images

UDF files are often treated similar to ISO 9660 files. See the section on using a CD image, but know that references to ISO9660/CD9660 might need to be altered to specify UDF. The UDF file format may be more common/prevalent on DVDs than on CDs. Still, many operating systems may treat DVD drives similar to CD drives, such as Unix having a symlink called /etc/cdrom (even if the device is a DVD+/-RW drive, or a drive capable of even more/newer format(s).)

UDF support in Microsoft Windows
UDF support in Win XP
Microsoft KB Q321640: Reading UDF Disc in Win XP, Microsoft KB Q899527

Windows Vista supports /FS:UDF when using FORMAT, and also /R: and /D parameters which are specific to UDF.

[#impristg]: Images of “Primary Storage” Devices (e.g. Hard Drives)

info is moving to images of primary storage devices.

Information about hard drive images is covered in more detail in the Virtualization page: disk image files (and more specifically the Virtualization page: file formats for disk images section). Such disk images could potentially have a use other than being used by software that implements virtual machines. However, software that implements virtual machines will often come bundled with software that handles hard drive images.

For making images, specifically see the Virtualization page: section subsection about making disk images. For a discussion about various disk image formats, see that same approximate section of documentation. For converting, see Primary Storage Devices: converting disk images.

[#flopyimg]: Floppy disk images
Floppy disk images in Unix
Creating a floppy disk image

For Unix, images of an actual pre-existing floppy disk are typically created using a command like the following: “ dd bs=512 if=/dev/fd0 of=floppy.144

To create a blank image from scratch, which is using a common size of 1,440KB formatted, use:

dd bs=512 count=2880 if=/dev/zero of=floppy.144
Mounting a floppy disk image
Mounting a floppy disk image in OpenBSD
Preparing a desired mount point

The FHS standard would suggest that this file be mounted under a directory that is under /media, but /media does not exist. This can easily be resolved:

sudo mkdir -m 0770 /media
sudo mkdir -p -m 0770 /media/demodisk

The -m 0770 can be left off entirely, and is just done to set permissions (allowing full access to root and the wheel group, and no access to anybody who is not root and is not part of the wheel group). If this permission-setting isn't desired, the -m 0770 can be skipped and also the first line can be skipped entirely.

Mounting a disk image

First, identify what virtual node devices are available and not already being used.

sudo vnconfig -l

For OpenBSD 5.x and newer, the following is the preferred method:

sudo vnconfig vnd1 input.144
sudo mount -t msdos /dev/vnd1c /mntpoint

Older versions of OpenBSD should add an s between the /dev/ and the vnd, as shown by mounting a CD image in OpenBSD.

Unmounting a disk image

The process is the same as a local CD image. See: Unmounting and then using (OpenBSD's) vnconfig.

Floppy disk images in DOS and compatible

For MS-DOS (and compatible operating systems), some software to handle this is in TOOGAM's Software Archive: Archivers Page. (Search for the section about “Disk Images”.) GtBtIm06.Zip is a great option for creating a disk image. Software is mentioned (on TOOGAM's Archivers page) for being able to work with the contents of existing disk images. For writing an image to the disk, there are a few variations of RaWrite/RawWrite. Some might work better on some machines than other machines.