Sonntag, 28. Juni 2009

10.) [10.5] Some Terminal Work

Now it's time for some work in the terminal. Don't be affraid, it's quite easy. The goal of this steps is to cleanup the USB-Stick, set the owner and permissions for kernel extensions and to build the kernel extensions cache file.
  1. Login into an account with Administrator rights
  2. Insert the EFIBOOT USB-Stick
  3. Open the Terminal Application (Applications -> Utilities)
  4. Become root with by entering "sudo -s" and providing your administrator account password

If you insert a removeable drive like an USB-Stick it gets mounted by Mac OS X with some options we don't want, like nosuid or noowners. Therefore we have to remount the USB-Stick without this special flags. Ok let's start. The shell promt is blue. The commands you have to enter are green and the output of the commands is dark red. To get help for a command you can enter "man commandname". For instance, if you wanna know something about the "mount" command enter:
root@MacBook [~] > man mount
MOUNT(8) BSD System Manager's Manual MOUNT(8)

mount -- mount file systems

mount [-adfruvw] [-t ufs | lfs | external_type]
mount [-dfruvw] special | node
mount [-dfruvw] [-o options] [-t ufs | lfs | external_type] special node

The mount command calls the mount(2) system call to prepare and graft a
special device or the remote node (rhost:path) on to the file system tree
at the point node. If either special or node are not provided, the
appropriate information is taken from the fstab(5) file.

The system maintains a list of currently mounted file systems. If no
arguments are given to mount, this list is printed.

The options are as follows:

-a All the filesystems described in fstab(5) are mounted. Excep-
tions are those marked as ``noauto'' or are excluded by the -t
flag (see below).

-d Causes everything to be done except for the actual system call.
This option is useful in conjunction with the -v flag to deter-
mine what the mount command is trying to do.

-f Forces the revocation of write access when trying to downgrade a
filesystem mount status from read-write to read-only.

This gives you the manpage of the command mount. Within man you can go forward with "f" or "space" and backwards with "b". To leave "man" press "q". Even "man man" is possible :) OK... now let's really star us with the terminal work. First run "mount" without arguments to find out which device our USB-Stick is and there it is mounted.
root@MacBook [~] > mount
/dev/disk0s2 on / (hfs, local, journaled)
devfs on /dev (devfs, local)
fdesc on /dev (fdesc, union)
map -hosts on /net (autofs, automounted)
map auto_home on /home (autofs, automounted)
/dev/disk0s3 on /Volumes/BOOTCAMP (ntfs, local, read-only, noowners)
/dev/disk1s2 on /Users/admin (hfs, local, nodev, nosuid, journaled)
/dev/disk2s1 on /Volumes/EFIBOOT (hfs, local, nodev, nosuid, journaled, noowners)

Some background info about Unix Devices. Under Unix devices can be accessed through special device files. You can find these device files normally in the directory /dev. Harddisks and also USB-Stick are named /dev/disk or /dev/rdisk. The first number is the disk counter. Then comes an "s" (stands for slice/partition) and another number, which is the partition number. You can see that the USB-Stick is the device /dev/disk2 and /dev/disk2s1 is the EFIBOOT partition on the USB-Stick. You can find this info also in the Disk Utility. Select the disk or partition and then "Info". Disk Identifier is the same as the device name under /dev. OK, now let's unmount and remount the USB-Stick. Find out which disk number has the USB-Stick in your case. In my case it is the number 2.
root@MacBook [~] > umount -f /Volumes/EFIBOOT
root@MacBook [~] > mkdir efitemp
root@MacBook [~] > mount_hfs /dev/disk2s1 efitemp/
root@MacBook [~] > mount
/dev/disk0s2 on / (hfs, local, journaled)
devfs on /dev (devfs, local)
fdesc on /dev (fdesc, union)
map -hosts on /net (autofs, automounted)
map auto_home on /home (autofs, automounted)
/dev/disk0s3 on /Volumes/BOOTCAMP (ntfs, local, read-only, noowners)
/dev/disk1s2 on /Users/admin (hfs, local, nodev, nosuid, journaled)
/dev/disk2s1 on /Users/admin/efitemp (hfs, local, journaled)

The USB-Stick is mounted now at the directory efitemp (which was created by mkdir efitemp) and without these special option (nosuid, noowner). Let's start with some cleanups.
root@MacBook [~] > cd efitemp
root@MacBook [~/efitemp] > ls -la@
total 6336
drwxrwxr-x 17 root wheel 646 Jun 28 21:56 .
drwx------+ 35 admin staff 1258 Jun 28 23:31 ..
-rw-rw-r--@ 1 _unknown _unknown 6148 Jun 28 00:49 .DS_Store 32
drwx------ 3 root wheel 102 Jun 27 20:13 .Spotlight-V100
d-wx-wx-wt 3 root wheel 102 Jun 28 23:30 .Trashes
-rw-r--r-- 1 root wheel 0 Jun 27 20:13
drwx------ 4 root wheel 136 Jun 28 23:32 .fseventsd
-rw-r--r-- 1 root wheel 736736 Jun 27 13:36
drwxrwxr-x 7 root wheel 238 Jun 28 00:49 Extra
drwxr-xr-x 3 root wheel 102 Apr 1 16:17 IOAHCIBlockStorageInjector.kext
drwxrwxr-t 3 root wheel 102 Jun 27 20:22 Library
-rw-r--r-- 1 root wheel 2204417 Jun 27 13:38
-rw-r--r-- 1 root wheel 279168 Jun 27 20:23 boot
drwxr-xr-x 4 root wheel 136 Apr 1 16:17 usr

The command "ls -la@" lists all the file and directories and also the extended attributes. We will now delete all these extended attributes (with xattr) and the .DS_Store files with the command "find".
root@MacBook [~/efitemp] > find . -type d -exec xattr -d "" {} \; -print
root@MacBook [~/efitemp] > find . -type f -exec xattr -d "" {} \; -print
root@MacBook [~/efitemp] > find . -type d -exec xattr -d " quarantine" {} \; -print
root@MacBook [~/efitemp] > find . -type f -exec xattr -d " quarantine" {} \; -print
root@MacBook [~/efitemp] > find . -name ".DS_Store" -exec rm -f {} \; -print

Now let's set the ownership and permissions of the kernel extensions and build the kernel extensions cache file extensions.mkext.
root@MacBook [~/efitemp] > cd Extra/
root@MacBook [~/efitemp/Extra] > chmod -R 755 Extensions
root@MacBook [~/efitemp/Extra] > chown -R root:wheel Extensions
root@MacBook [~/efitemp/Extra] > kextcache -a i386 -m Extensions.mkext Extensions
root@MacBook [~/efitemp/Extra] > ls -la@
total 112
drwxrwxr-x 6 root wheel 204 Jun 28 23:58 .
drwxrwxr-x 16 root wheel 612 Jun 28 23:45 ..
drwxrwxr-x 6 root wheel 204 Jun 28 23:45 Extensions
-rw-r--r-- 1 root wheel 52374 Jun 28 23:45 Extensions.mkext
drwxrwxr-x 6 root wheel 204 Jun 26 10:52 Themes
root@MacBook [~/efitemp/Extra] > cd
root@MacBook [~] > umount -f efitemp
root@MacBook [~] > rmdir efitemp

That's all. You are done and almost ready for the first boot of your Chameleon-Mac.


  1. Unfortunately word wrapping seems to be incorrect. I had to look into the html source code of this blog to be able to read the terminal commands completely.

  2. First things first: This blod & guide is awesome! I nearly bought this efix dongle and then discovered what you unveiled, damn! So, i'm a noob regarding OSx86 and just i'm just failing to follow the guide further. On the last step, "chown -R root:wheel Extensions" or the kextcache command, i got the error message that there are missing dependencies. So what did I wrong?