drutil - macOS


Overview

drutil is a command-line utility used on macOS systems for interacting with optical drives. This utility allows users to manage tasks such as burning, erasing, and inspecting optical disks. It caters particularly to situations requiring direct control over CD or DVD drives, such as creating data backups, audio CDs, or distributing large data files on physical media.

Syntax

The basic syntax for drutil is:

drutil [subcommand] [options]

The command structure can vary significantly depending on the chosen subcommand and options.

Options/Flags

  • erase: Erases a rewritable disc.
    • quick: Quickly erases a disc by blanking disc’s headers.
    • full: Completely erases a disc by overwriting all content.
  • burn: Used to burn a disc using the specified device.
    • -noverify: Skips verification after burning.
    • -speed: Specifies the speed for burning the disc.
  • status: Shows the status of the disc drive.
  • tray: Controls the opening and closing of the disc tray.
    • open: Opens the tray.
    • close: Closes the tray.
  • info: Provides detailed information on the device’s capabilities and the disc inserted.

Examples

  1. Erase a Rewritable Disc Quickly:
    drutil erase quick
    
  2. Burn a Disc Image at Max Speed:
    drutil burn -speed max /path/to/image.iso
    
  3. Check Drive Status:
    drutil status
    
  4. Open and Close the Drive Tray:
    drutil tray open
    drutil tray close
    

Common Issues

  • Disc Not Recognized: Make sure the proper format disc is inserted, and it’s not damaged.
  • Burning Fails: Verify the disc is not already full or write-protected, and the file path to burn is correct.
  • Drive Not Available: Check connections and hardware compatibility, or try restarting the system.

Integration

drutil can be integrated with shell scripts and other macOS commands for batch processing or automated tasks, such as creating regular backups or running system diagnostics. For example:

Backup Script:

#!/bin/bash
# Backup files to CD/DVD
tar -czvf backup.tar.gz /path/to/files
drutil burn -speed max /path/to/backup.tar.gz
echo "Backup complete"
  • hdiutil: Handles disk images for mount/unmount operations and can be used before burning disk images with drutil.
  • diskutil: Manages disk-related tasks on macOS, ideal for preparing partitions or volumes before using other tools.

For more detailed information, refer to the macOS man pages or the official Apple Support website.