If you ever tried to take a look around an OSX install DVD unter Linux you may have been surprised by
the marvelous compression algorithms that Apple uses, because there seems to be preciously little data on those disks:
$ du -sh /media/OSX86DVD/
132K /media/OSX86DVD/
There is no magic here, as seen by the fact that the same disk inserted into a running OSX system shows a completely different file structure with more than 4GB of data.
The explanation for this is that there are two filesystems on the DVD:
First, a normal ISO9660 CD file system, which contains some bootloader files, and not much else. This filesystem is the one that Linux (and Windows) see by default.
Behind the ISO9660 filesystem there is another one, which spans the rest of the disk. This is a complete hard disk image with it's own partition table, and which contains the real installer data. As Linux does not expect this it does not try to access this filesystem, and the files remain invisible.
In order to get at the files in the second part of the disk some command line magic is necessary. You will need root privileges for the following operations. I assume that the DVD device is /dev/sr0
, adjust as neccesary.
The Linux kernel has a nice block device mapping layer which allows us to take a slice out of an existing block device and present this slice as a new device. Even more, there is a helper tool that inspects a block device, looks for partitions and automatically creates such a mapping for each partition. This tool is called kpartx
.
So we use kpartx
to inspect the DVD device. The command for this is as follows:
# kpartx -a /dev/sr0
device-mapper: reload ioctl failed: Invalid argument
create/reload failed on sr0p1
device-mapper: reload ioctl failed: Invalid argument
create/reload failed on sr0p2
#
That did not work too well. For some reason the device mapper does not like CDROM/DVD devices. So we'll have to get a bit inventive. We create a loop device which is backed by the DVD device, and use that.
# /sbin/losetup /dev/loop0 /dev/sr0
# /sbin/kpartx -av /dev/loop0
add map loop0p1 (253:5): 0 63 linear /dev/loop0 1
add map loop0p2 (253:6): 0 9178688 linear /dev/loop0 448
#
The command found and created two partitions. The first partition is the ISO9660 file system at the beginning of the disk, the second one is the partition we are interested in. Let's look what's in it.
# file -s /dev/mapper/loop0p2
/dev/mapper/loop0p2: Macintosh HFS Extended version 4 data last mounted by: '10.0', created:
Tue Oct 30 00:32:01 2007, last modified: Wed Dec 19 16:45:14 2007, last checked: Tue Oct 30 00:32:01
2007, block size: 4096, number of blocks: 1147336, free blocks: 192685
#
That looks good. We could now mount the filesystem and look around.
# mount /dev/mapper/loop0p2 /mnt
# ls /mnt
Applications Desktop DB dev Install Mac OS X.app mach_kernel sbin tmp vanilla Volumes
bin Desktop DF etc Library private System usr var
#
To get rid of all this again we have to unmount the file system, destroy the mappings and release the loop device:
# umount /mnt
# kpartx -d /dev/loop0
# losetup -d /dev/loop0