Mounting an Mac OS X install DVD in Ubuntu 14.04

This document describes how to use a Linux computer to extract the BaseSystem.dmg image file from an Mac OS X (10.7+) installation DVD. The image file can be used to create a recovery disk, i.e. by using the Mac OS X "Disk Utility" to write it to an HSF+ partition on an USB-stick.

The USB-stick should contain an GUID partition table to be usable as a startup disk. Accessing DVD partitions The DVD device is /dev/sr0.The DVD contains multiple partitions and can't be mounted the usual way:

  bash$> mount -t hfsplus /dev/sr0 /mnt/disk1
mount: /dev/sr0 is write-protected, mounting read-only
mount: wrong fs type, bad option, bad superblock on /dev/sr0,
       missing codepage or helper program, or other error
       In some cases useful info is found in syslog - try
        dmesg | tail or so

We can't create block devices (one for each partition on the DVD) directly using partx, we have to access them thru a loop device:

bash$> partx -a /dev/sr0
partx: /dev/sr0: error adding partitions 1-4

bash$>modprobe loop
bash$>/sbin/losetup /dev/loop0 /dev/sr0
losetup: /dev/sr0: warning: file smaller than 512 bytes, the loop device maybe be useless or invisible for system tools.

bash$>partx -av /dev/loop0
partition: none, disk: /dev/loop0, lower: 0, upper: 0
/dev/loop0: partition table type 'mac' detected
/dev/loop0: partition #1 added
/dev/loop0: partition #2 added
/dev/loop0: partition #3 added
/dev/loop0: partition #4 added

Listing filesystems Let's examine the type of filesystem on the DVD:

bash$>file -s /dev/loop0*
/dev/loop0:   Apple Driver Map, blocksize 2048, blockcount 2043557, devtype 0, devid 0, descriptors 0, contains[@0x800]: Apple Partition Map, map block count 4, start block 1, block count 15, name Apple, type Apple_partition_map, contains[@0x1000]: Apple Partition Map, map block count 4, start block 16, block count 1, name Macintosh, type Apple_Driver_ATAPI, contains[@0x1800]: Apple Partition Map, map block count 4, start block 18, block count 2043536, name disk image, type Apple_HFS, contains[@0x2000]: Apple Partition Map, map block count 4, start block 2043554, block count 3, type Apple_Free
/dev/loop0p1: Apple Partition Map, map block count 4, start block 1, block count 15, name Apple, type Apple_partition_map
/dev/loop0p2: data
/dev/loop0p3: Macintosh HFS Extended version 4 data last mounted by: '10.0', created: Wed Aug 17 15:04:13 2011, last modified: Thu Aug 18 01:47:54 2011, last checked: Thu Aug 18 00:04:13 2011, block size: 4096, number of blocks: 1021768, free blocks: 91314
/dev/loop0p4: data

Mounting the HFS+ partition The third partition contains the Mac OS X setup files. This shows how to mount this partition on the DVD:

bash$>mount -t hfsplus -o ro /dev/loop0p3 /mnt/disk1
mount: /dev/loop0p3 is write-protected, mounting read-only
bash$>mount | grep hfs
/dev/loop0p3 on /mnt/disk1 type hfsplus (ro)

DVD Content With the DVD partition mounted, all that remains is to transfer the BaseSystem.dmg file to a Mac OS X computer. The DVD content should look something like this:

bash$>ls -l /mnt/disk1/
  total 480884
  -rw-r--r-- 1 root cdrw      1876 Aug 18  2011 BaseSystem.chunklist
  -rw-r--r-- 1 root qemu 451942804 Aug 18  2011 BaseSystem.dmg
  drwxr-xr-x 1 root root         3 Aug 17  2011 Install Mac OS X Lion.app
  drwxr-xr-x 1 root root         3 Jun 17  2011 Library
  -r--r--r-- 1 root root     46516 Jun  8  2010 MacOSX_Media_Background.png
  drwxr-xr-x 1 root root        51 Aug 18  2011 Packages
  drwxr-xr-x 1 root root         3 Jun 17  2011 System
  -rw-r--r-- 1 root cdrw    859312 Aug 18  2011 boot.efi
  -rw-r--r-- 1 root cdrw  23995042 Aug 18  2011 kernelcache
  -rw-r--r-- 1 root root  15565140 Jul 27  2011 mach_kernel
  drwxr-xr-x 1 root root         3 Jun 17  2011 private
  drwxr-xr-x 1 root root         4 Aug 18  2011 usr