• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

hdiutil Command Examples in Mac

by admin

hdiutil works with disk images, such as ISO or DMG files downloaded from the Internet. You can mount, unmount, create, resize, verify, and even burn images onto discs. To mount an ISO file mydisk.iso as a volume and access its contents, run:

# hdiutil attach mydisk.iso
# ls /Volumes
MyDisk

hdiutil Command Examples

1. Creating a disk image from a folder:

# hdiutil create test.dmg -srcfolder /path/to/folder/

Once the disk image is created, it can be mounted, copied, or sent like any other file.

2. To mount (or attach) a disk image, use:

# hdiutil mount test.dmg

A mounted disk image appears on the Desktop, in the Finder, and shows up as a directory in /Volumes. All removable media, such as CDs, DVDs, external disks, and USB flash drives are mounted in /Volumes.

3. Disable write access to the mounted image.

# hdiutil attach -readonly test.dmg

3. To unmount (or detach) a disk image, use:

# hdiutil unmount /dev/device-name

The device name is usually something like /dev/disk3s2. You can also unmount it using the /Volumes/mountpoint if you know where it was mounted:

# hdiutil unmount /Volumes/mountpoint

4. To check that the ISO image: mydisk.iso is valid and undamaged, run:

# hdiutil verify mydisk.iso

5. Burning an ISO to CD (or DVD)

– First, load a blank CD, then:

# hdiutil burn cd-image.iso

6. Create an encrypted disk image:
This creates a 10 MB encrypted disk image and internally formats it as a journaled HFS+ file system (the OS X default):

# hdiutil create -encryption -size 10m -volname encdata test.dmg -fs HFS+J

During the creation of the disk image, you will be prompted for a password that will allow access to the contents of the disk image. You must remember the password or anything you put into the image will be lost.

See the hdiutil manpage or run hdiutil help for more information.

# man hdiutil

Notes

Essentially hdiutil is the command-line equivalent of the Disk Copy application, hdiutil manages disk images. See the hdiutil manpage or run hdiutil help for more assistance.

Filed Under: Linux, Mac

Some more articles you might also be interested in …

  1. lvextend command examples in Linux
  2. “yum clean all” not clearing yum repository cache in CentOS/RHEL/OEL
  3. Why Does “/var/log/messages” Report Martian Packets
  4. CentOS / RHEL 6 : How to boot into rescue mode
  5. Oracle Software Group Accounts OSDBA, OSOPER, Oracle Inventory group
  6. How to convert text files to all upper or lower case
  7. lvscan Command Examples in Linux
  8. How to Use “repoquery” Command to List Package Dependencies
  9. How to Mask or Unmask a Service in CentOS/RHEL 7 and 8
  10. How to Integrate CentOS/RHEL system into an AD Domain with LDAP/Kerberos/SSSD

You May Also Like

Primary Sidebar

Recent Posts

  • JavaFX ComboBox: Set a value to the combo box
  • Nginx load balancing
  • nginx 504 gateway time-out
  • Images preview with ngx_http_image_filter_module

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright