Burn an ISO image safely with xorrecord
You will write one ISO 9660 image to a CD, DVD or Blu-ray disc with xorrecord, while checking the drive first and avoiding an accidental overwrite. The examples target the installed xorriso 1.5.6 package on GNU/Linux. Allow 10 to 20 minutes for preparation and a burn, plus the time needed to verify the disc.
The route
Jump straight to the step you need, or tick off Done means at the end.
Before you start
You need the xorriso package, an accessible optical writer, suitable blank or appendable media, and an ISO image such as ./release.iso. The device must not be mounted or used by another program. A normal user needs read and write permission for the optical device. Use sudo only when your account lacks that permission; running the whole burn as root can hide a device-permission problem rather than fixing it.
Check the local version and the command's emulation mode first:
$ xorrecord --no_rc -version
$ xorrecord --no_rc -help
The version output should identify xorriso 1.5.6 on the system described by this guide. The --no_rc option is deliberately first: without it, xorrecord may read generic xorriso startup files from locations such as /etc/xorriso/xorriso.conf and $HOME/.xorrisorc. Those files can add commands you did not put in the shell line.
1. Find the drive address
Put the blank or appendable disc in the drive, then ask xorrecord to list accessible MMC drives:
$ xorrecord --no_rc --devices
Look for a line containing an address such as /dev/sr0. The address is the value for dev=. A typical result resembles this:
0 -dev '/dev/sr0' rwrw-- : 'Vendor' 'Optical Writer'
If the command reports that no drives were found, check the cable or virtual machine pass-through, confirm that the drive exists with ls -l /dev/sr*, and check your group or udev permissions. The device scan itself does not burn or alter media. If the drive is already mounted, unmount its filesystem before using it.
2. Inspect the drive and media
Replace /dev/sr0 below with the address you found. This reads drive and media information without supplying a track source:
$ xorrecord --no_rc dev=/dev/sr0 -inq -atip -toc
Use the output to confirm the writer, media type, whether the medium is erasable, and whether it is blank, closed or appendable. A blank write-once disc is suitable for a new image. A closed disc cannot accept another session. Reusable CD-RW or DVD-RW media can be blanked, but that is a destructive operation.
3. Check the image before burning
Confirm that the source exists and is a regular file. This catches a mistyped path before the drive starts:
$ test -f ./release.iso && ls -lh ./release.iso
$ file ./release.iso
The image should be described as an ISO 9660 filesystem, possibly with Rock Ridge or Joliet extensions. If file cannot read it, stop and repair or regenerate the image. Do not use a directory as the track source: xorrecord accepts readable files and standard input, but not directories.
4. Run a cautious burn
The following command writes one data track, pads it for compatibility, ejects the tray after the work, and asks for verbose progress. It uses a fixed speed rather than the default maximum speed, which can make a marginal drive or disc easier to diagnose:
$ xorrecord --no_rc -v dev=/dev/sr0 speed=4 fs=8m \
blank=as_needed padsize=300k -eject ./release.iso
blank=as_needed prepares a medium only when its state permits it. It may blank reusable media, so inspect the -toc output first. It will not make a non-blank write-once disc safe.
The default program FIFO is 4 MB; fs=8m gives a slower source more buffering, at the cost of some memory and filesystem cache. A speed of 4 is interpreted using the medium's unit when no suffix is supplied. You can use an explicit value such as 4d for 4x DVD or 4c for 4x CD.
There is no undo for a write to CD-R, DVD-R or BD-R. If you are testing a command, use -dummy with supported rewritable or emulated media, but treat it as a check rather than a guarantee: the manual warns that dummy mode depends on the drive and medium combination. Do not add --drive_not_exclusive merely to get past a busy-drive error. It disables locking and can allow a mount or another process to interfere with the burn.
Checkpoint: confirm the burn
A successful run should end without a non-zero exit status and should report that the track and session finished. Check the status explicitly if the command was part of a script:
$ printf 'exit=%s\n' "$?"
After -eject, reload the disc and ask xorrecord for its table of contents:
$ xorrecord --no_rc dev=/dev/sr0 -toc
For stronger verification, mount the reloaded disc read-only at a temporary mount point, list the expected files, then unmount it. Mounting generally needs elevated privileges unless your desktop automount policy handles it:
$ sudo mount -o ro /dev/sr0 /mnt
$ find /mnt -maxdepth 2 -type f | head
$ sudo umount /mnt
If the disc is mounted automatically, do not issue the manual mount command against the same device. If the contents differ from the source tree, discard the burn and investigate the image or drive rather than trusting a partial result.
Adding a second ISO session
Use -multi only when you deliberately want the medium to remain appendable. Without it, a sequential disc is closed after the session and cannot normally receive another session. DVD-R DL and DVD-RW blanked with blank=deformat_quickest cannot use this workflow.
For the first session, create an image and burn it with -multi:
$ xorrisofs -o image-1.iso -J -graft-points /docs=./docs
$ xorrecord --no_rc -v dev=/dev/sr0 -multi \
--grow_overwriteable_iso blank=as_needed \
padsize=300k -eject image-1.iso
Before creating the next image, obtain the two numbers required by xorrisofs -C. Reloading the tray can help the operating system notice the new session:
$ m=$(xorrecord --no_rc dev=/dev/sr0 -msinfo)
$ xorrisofs -M /dev/sr0 -C "$m" -o image-2.iso \
-J -graft-points /photos=./photos
$ xorrecord --no_rc -v dev=/dev/sr0 -multi \
--grow_overwriteable_iso -eject padsize=300k image-2.iso
--grow_overwriteable_iso extends the same ISO-style workflow to overwritable DVD or Blu-ray media. It implies -isosize, so the source must be an ISO 9660 image. It does not turn arbitrary files into sessions.
Common failures
- Permission denied: grant your user the distribution's normal optical-device access, then log in again. Use
sudo xorrecord --no_rc --devicesonly as a diagnostic comparison. - Device busy: unmount the disc and stop software that polls or writes to the drive. Keep exclusive locking enabled.
- Track size is required: DVD-R DL and quickly de-formatted DVD-RW can need a known length. Use a regular image file, or provide the exact
tsize=value;-isosizeworks only for an ISO 9660 source. - Buffer or speed problems: lower
speed=, increasefs=moderately, and avoid very large FIFOs that starve the system's read cache. Old CD drives may still abort on temporary source delays. - Unexpected settings: put
--no_rcfirst, or inspect the xorriso startup files before relying on a repeated command.
Done means
- The installed version and drive address were checked.
- The ISO was identified before the burn.
- The medium state was understood before any blanking option was used.
- The burn exited successfully and the reloaded disc showed the expected files.
- The disc was unmounted cleanly, or its appendable state was intentionally preserved with
-multi.