This is blah of Tuomas Jormola. Blah is not a blog.

RSS Atom Add a new post titled:

This page serves as the reference list of software that I may want to install on a clean system running Mac OS X.

Networking

Media

Other applications and utilities

Posted Thu May 20 15:45:19 2010 Tags:

Introduction

This posting documents how I configured triple boot environment of Ubuntu 9.10 karmic, Mac OS X 10.6 and Windows 7 on one of my machines. All operating systems are installed on a single physical disk. Grub 2[1] boot loader installed by Ubuntu will be used as the primary boot loader. Grub will be then used to boot Chameleon[2] boot loader which boots Mac OS X. Grub boots Ubuntu and Windows directly.

Partitioning the disk

Partitioning the disk causes headache and requires some tweaking as we have to install both GUID Partition Table[3] and Master Boot Record Partition Table[4] on the same disk. Mac OS X only supports system disks with GPT. But Windows doesn’t support booting from a disk with GPT[5]. Ubuntu is happy to boot from disks paritioned using both GPT and MBR. Thus we have to create hybrid GPT/MBR boot record[6].

We’re going to do the initial partitioning of the system disk using Mac OS X installer. Follow the instructions in the posting Create Mac OS X 10.6 Snow Leopard USB installation media for Hackintosh and create bootable Mac OS X installer USB media.

Next we have to decide the partition table layout. When installing Grub 2 on a disk with GPT, it’s recommended to have BIOS Boot Partition[7],[8]. With the hybrid partition table in place, you’re limited to only 4 partitions that are available to Windows. And two of these partitions are reserved (EFI Partition and BIOS Boot Partition) so you only have 2 primary partitions to configure at your will. Also it’ll be difficult to work with the partitioning after we’ve finished with the installations and gotten everything to work so it’s better to do good initial planning.

Ubuntu 9.10 karmic and later install Grub 2 that is capable of handling LVM. Since we’re going to install Ubuntu on logical volume(s), there’s not need for a separate partition for /boot file system. That’s great!

I partitioned my 600GB disk as follows:

  • Partition 1: 200MB HFS+ volume labeled EFI. This is created automatically when partitioning the disk with Mac OS X diskutil(8)[9] tool. Chameleon boot loader code and support files are also installed on this volume. This way there’s no need to do any customization to the Mac OS X volume described below.
  • Partition 2: 2MB volume for the BIOS Boot Partition. Used by Grub.
  • Partition 3: 150GB NTFS volume for Windows.
  • Partition 4: 50GB Physical volume for volume group managed by LVM. The volume group will house the Ubuntu installation.
  • Partition 5: 100GB Mac OS X system volume labeled Hackintosh HD for the operating system, applications and user home directories.
  • Partition 6: ~300GB HFS+ volume labeled Video for video archive and scratch space used during editing of home videos.

To partition the disk boot Mac OS X installer and launch Terminal.app from the Utilities menu. First identify the system disk.

    -bash-3.2# diskutil list

In my system the system disk is /dev/disk7. Then I partitioned the disk using the following command.

    -bash-3.2# diskutil partitionDisk /dev/disk7 GPT \
        "MS-DOS FAT32" %noformat% 2M \
        "MS-DOS FAT32" %noformat% 150G \
        "MS-DOS FAT32" %noformat% 50G \
        "Journaled HFS+" "Hackintosh HD" 100G \
        "Journaled HFS+" Video 0b

I marked the Windows, Linux and BIOS boot partitions temporarily as FAT32 so that the space gets allocated for these partitions. The Windows partition will be formatted as NTFS when installing Windows 7, the Linux partition will be added to the volume group when installing Ubuntu and Grub installer will use the BIOS boot partition.

Installing Chameleon boot loader

The empty, just partitioned hard disk is not bootable and won’t be even after installing Mac OS X in the next step. But we can copy Chameleon boot loader and its configuration from the Mac OS X USB installer to the system disk. See my guide for more details about Chameleon. These steps assume that the Mac OS X installer was created like documented in that posting. While still in the Mac OS X installer with Terminal.app running, execute the following commands.

  1. Create HFS+ file system on the EFI volume and mount it.

    -bash-3.2# newfs_hfs -v EFI /dev/disk7s1
    -bash-3.2# mkdir /Volumes/EFI
    -bash-3.2# mount_hfs /dev/disk7s1 /Volumes/EFI
    
    
  2. Mark the EFI file system so that fseventsd doesn’t keep any logs there.

    -bash-3.2# mkdir /Volumes/EFI/.fseventsd
    -bash-3.2# touch /Volumes/EFI/.fseventsd/no_log
    -bash-3.2# chmod -R g-rwx,o-rwx /Volumes/EFI/.fseventsd
    -bash-3.2# chown -R root:admin /Volumes/EFI/.fseventsd
    
    
  3. Copy the Chameleon boot loader binaries to the root of the EFI volume. You really need the boot file, which is the last stage of Chameleon boot system and contains bulk of the Chameleon code, but it’s a good idea to have the images of the first stages at hand, too.

    -bash-3.2# ditto /Volumes/Hackintosh\ Snow\ Leopard\ Install\ Disk/boot /Volumes/EFI
    -bash-3.2# ditto /Volumes/Hackintosh\ Snow\ Leopard\ Install\ Disk/boot0 /Volumes/EFI
    -bash-3.2# ditto /Volumes/Hackintosh\ Snow\ Leopard\ Install\ Disk/boot1h /Volumes/EFI
    
    
  4. Copy Chameleon support file directory Extra to the EFI volume.

    -bash-3.2# ditto /Volumes/Hackintosh\ Snow\ Leopard\ Install\ Disk/Extra /Volumes/EFI/Extra
    
    
  5. Unmount the EFI volume.

    -bash-3.2# umount /dev/disk7s1
    -bash-3.2# rmdir /Volumes/EFI
    
    
  6. Eject the system disk so that you can write to the block device file in the next step.

    -bash-3.2# diskutil eject /dev/disk7
    
    
  7. Now you can copy the Chameleon initial boot code from the installer file system to the Master Boot Record at the beginning of the system disk.

    -bash-3.2# dd if=/Volumes/Hackintosh\ Snow\ Leopard\ Install\ Disk/boot0 of=/dev/disk7 bs=440 count=1
    
    
  8. Then copy the Chameleon 2nd stage boot code from the installer file system to the beginning of the EFI partition.

    -bash-3.2# dd if=/Volumes/Hackintosh\ Snow\ Leopard\ Install\ Disk/boot1h of=/dev/disk7s1
    
    
  9. Bootloader installation is now ready. Mount the Mac OS X volume so you can install Mac OS X onto it.

    -bash-3.2# diskutil mount /dev/disk7s5
    
    
  10. Finally, quit Terminal.app.

Installing Mac OS X 10.6 Snow Leopard

Go ahead and install Mac OS X normally on the Mac OS X volume (Hackintosh HD). After the installation is finished, the machine should boot to Mac OS X as we installed the Chameleon boot loader to the Master Boot Record and support files to the EFI partition in the previous steps. It’s a good idea to create backups of the Master Boot Record of the system disk at this stage so you can revert back if needed. You can use e.g. dd(1)[10] in Mac OS X installer shell.

    -bash-3.2# dd if=/dev/disk7 of=/Volumes/BackupVolume/mbr-backup bs=512 count=1

Installing Windows 7

When the system disk was partitioned above with diskutil(8)[9], it also created the hybrid GUID/MBR partition table. You can now boot Windows 7 installer and format the partition dedicated to Windows as NTFS. Proceed to install Windows on this partition. After Windows is installed, the machine now boots Windows as the Windows installer replaced Chameleon boot code in the Master Boot Record with its own boot code. No need to worry, we’ll get Mac OS X back after installing Ubuntu and configuring Grub.

Installing Ubuntu 9.10 karmic

Use Ubuntu alternate installer[11]. Boot the installer and proceed to the disk partitioning step. Choose manual partitioning and create a volume group to the partition dedicated to Ubuntu, create required volumes and install Ubuntu there. When the installer prompts for boot loader device installation, don’t answer yet but switch to the console (Alt-F2). We need to activate the BIOS Boot Partition first. In the following setup /dev/sda is the physical system disk.

  1. Mount the special file systems at the target file system.

    ~ # mount -o bind /dev /target/dev
    ~ # mount -o bind /sys /target/sys
    ~ # mount -o bind /proc /target/proc
    
    
  2. Enable BIOS Boot Partition using parted(1)[12].

    ~ # chroot /target parted /dev/sda set 2 bios_grub on
    
    
  3. Unmount the special file systems at the target file system.

    ~ # umount /target/dev
    ~ # umount /target/sys
    ~ # umount /target/proc
    
    

Now switch back to the installer virtual console (Alt-F1) and input the system disk block device name /dev/sda and finish with Ubuntu installation.

Restoring hybrid partition table

After installing Ubuntu, you should be able to boot it using Grub. However, Ubuntu installer and parted(1) have destroyed the hybrid GPT/MBR partition table. But we can fix that using the gptsync(1) tool which is part of the rEFIt[13]. gptsync package is available for Ubuntu[14], but unfortunately the version in karmic is too old to support BIOS Boot Partitions[15]. This has been fixed in the version 0.13-4 of the package. Until there’s a working version of gptsync package in Ubuntu, you can use the package from Debian[16]. When you have a version of gptsync(1) installed which supports BIOS Boot Partitions, go ahead and re-create the hybrid partition table.

    ~$ sudo gptsync /dev/sda

Updating Grub boot menu

Ubuntu installer should detect the Windows 7 installation and create a Grub menu entry for it. It’ll also detect the Mac OS X installation and create menu entry for that, too. However, that is no good to us since it uses Grub’s native Mach kernel loading facilities[17] but we want to use Chameleon to boot Mac OS X.

So let’s create a custom menu entry that will boot Chameleon. Save the following script as /etc/grub.d/99_local_chameleon and set it executable.

#!/bin/sh

cat <<END_OF_MENU_ENTRY
menuentry "Mac OS X via Chameleon" {
        insmod hfsplus
        set root=(hd0,1)
        multiboot /boot
}
END_OF_MENU_ENTRY

Download script

    ~$ sudo chmod 755 /etc/grub.d/99_local_chameleon

And update the Grub configuration.

    ~$ sudo update-grub

Now you should have Grub menu from which you can choose whether to boot Ubuntu, Mac OS X or Windows.

Fixing Windows

Unfortunately, partition changes related to Ubuntu installation breaks Windows on my machine. When trying to boot Windows, I get Windows Boot Manager error screen with status 0xc00000e. To fix this, boot to Windows Recovery Environment and start Command Prompt. With Windows 7 retail DVD in hand, boot it, choose your language and locale settings and choose Repair your computer. If the Recovery Environment asks Do you want to apply repairs and restart your computer, choose No. Choose Use recovery tools that can help fix problems starting Windows and then clck Command Prompt. In the Command Prompt find the drive that contains the Windows installation. Most likely it’s C:. Run the following commands to repair Windows Boot Catalog.

    bcdedit /set {default} device partition=c:
    bcdedit /set {default} osdevice partition=c:
    bcdedit /set {bootmgr} device partition=c:

It should now be possible to boot Windows from the Grub boot menu.

References

Posted Mon Apr 19 21:52:10 2010 Tags:

Introduction

Here I document the steps that are needed to create a Windows 7 installation media that contains all retail editions of both 32-bit and 64-bit versions of the operating system. You’ll need original retail DVD media of both versions. It doesn’t matter which edition your’re using, since all Windows 7 DVDs contain the same installation image[1]. You also need a Windows 7 installation with about 10GB of free disk space.

This posting borrows a lot from this article[2]. Thanks and greetings to the author. Also Microsoft’s Windows 7 Technical Library Roadmap[3] has something to say about the topic[4],[5].

Windows Automated Installation Kit

  1. Download and install WAIK for Windows 7[6].

  2. Start Deployment Tools Command Prompt as Administrator. All subsequent commands are typed in the command prompt.

Extracting the original 32-bit media

  1. Create the following directory structure holding the installation image remastering data on a disk that can be used as scratch space. I’m using d:\aio as the base directory.

    md d:\aio
    md d:\aio\build
    md d:\aio\temp
    
    
  2. We use the 32-bit edition as basis for the image due to the reasons described in detail in the article referenced above[2]. Insert Windows 7 32-bit installation DVD into the drive. I’m using g:\ as the DVD drive letter in this listing.

  3. Copy the content of the DVD to d:\aio\build

    xcopy /e g:\ d:\aio\build
    
    
  4. Delete the ei.cfg file in order to unlock all editions[7].

    del d:\aio\build\sources\ei.cfg
    
    
  5. Eject Windows 7 32-bit installation media from the DVD drive

Integrate 64-bit install

  1. Insert Windows 7 64-bit installation media to the DVD drive

  2. Copy the install.wim file that holds the installation image to d:\aio\temp

    copy g:\sources\install.wim d:\aio\temp
    
    
  3. Now we can use ImageX[8] tool to integrate 64-bit editions from the 64-bit installation image with the 32-bit installation image.

    imagex /export d:\aio\temp\install.wim "Windows 7 HOMEBASIC" d:\aio\build\sources\install.wim "Windows 7 HOMEBASIC 64-bit"
    imagex /export d:\aio\temp\install.wim "Windows 7 HOMEPREMIUM" d:\aio\build\sources\install.wim "Windows 7 HOMEPREMIUM 64-bit"
    imagex /export d:\aio\temp\install.wim "Windows 7 PROFESSIONAL" d:\aio\build\sources\install.wim "Windows 7 PROFESSIONAL 64-bit"
    imagex /export d:\aio\temp\install.wim "Windows 7 ULTIMATE" d:\aio\build\sources\install.wim "Windows 7 ULTIMATE 64-bit"
    
    

Remaster ISO image of the installation media

  1. Finally, you can remaster the installation ISO image using Oscdimg[9].

    oscdimg -u2 -bd:\aio\build\boot\etfsboot.com -lGRMCULFRER_EN_DVD -t7/14/2009,12:26:40 d:\aio\build d:\aio\Windows_7_Retail_AIO.iso
    
    
  2. Now you have the final ISO image of the Windows 7 AIO installation media in the file d:\aio\Windows_7_Retail_AIO.iso. You could burn it to a DVD or create bootable USB installation stick[10],[11] or what ever.

References

Posted Mon Apr 19 21:51:47 2010 Tags:

Introduction

In this posting I’m creating Windows 7 pre-installation (Windows PE) and rescue images that can be PXE booted for both 64-bit and 32-bit systems. As source I’m using Windows 7 Ultimate retail images. You need a machine running Windows 7 to build the images using Windows Automated Installation Kit. This machine is named “Technician Computer” in the documentation[1]. The resulting bootable images are stored on a Linux server that has a DHCP server and TFTP server configured to serve PXE clients. ISC DHCP Server 3.1.2 and tftpd-hpa 0.49 are used. On the server TFTP root is /var/lib/tftpboot and we want to make Windows stuff available via TFTP under the path /i386/windows/. DHCP server is passing the following DHCP option to PXE clients:

    filename "/i386/pxelinux.0";

This PXELinux kernel comes from syslinux 3.63.

Other people have been writing about this stuff, too[2],[3],[4].

Windows Automated Installation Kit

  1. Download and install WAIK for Windows 7[5] on the Technician Computer.

  2. Start Deployment Tools Command Prompt as Administrator. All subsequent commands are typed in the command prompt.

Create Windows PE images

The following steps show you all the commands that are required to create and configure PXE bootable Windows PE 64-bit and 32-bit images.

  1. Insert your Windows 7 Ultimate 64-bit DVD to your DVD drive, mount an ISO image of the retail DVD or otherwise have the content of the retail DVD available under some directory. In this guide we’ll use DVD as the source and the content of the media is available under g:\.

  2. Create Windows PE 64-bit working directory

    copype.cmd amd64 c:\winpe_x64
    
    
  3. The plain Windows PE image created by WAIK for Windows 7 above doesn’t contain The Windows Recovery Environment[6]. However, we can use the Windows RE image on the DVD[7] as basis for our custom image. This way we get the recovery features and tools. So let’s mount the install image from the DVD and copy Windows RE image as our base image.

    md c:\winpe_x64\os_install
    imagex /mount g:\sources\install.wim 1 c:\winpe_x64\os_install
    copy c:\winpe_x64\os_install\windows\system32\recovery\winre.wim c:\winpe_x64\winpe.wim
    imagex /unmount c:\winpe_x64\os_install
    rd c:\winpe_x64\os_install
    
    
  4. You can now eject the DVD

  5. Mount the Windows PE 64-bit image

    imagex /mountrw c:\winpe_x64\winpe.wim 1 c:\winpe_x64\mount
    
    
  6. You can install 3rd party drivers to the Windows PE environment[8] if you need. I’m going to install some VMWare drivers here[9]. VMware drivers were copied from a host running under VMWare with VMWare Tools installed. Drivers are available at c:\Program Files\VMWare\VMWare Tools\Drivers\ and were copied to c:\winpe_x64\drivers\vmware.

    dism /image:c:\winpe_x64\mount /add-driver:c:\winpe_x64\drivers\vmware\audio\vmaudio.inf
    dism /image:c:\winpe_x64\mount /add-driver:c:\winpe_x64\drivers\vmware\mouse\vmmouse.inf
    dism /image:c:\winpe_x64\mount /add-driver:c:\winpe_x64\drivers\vmware\pvscsi\pvscsi.inf
    dism /image:c:\winpe_x64\mount /add-driver:c:\winpe_x64\drivers\vmware\vmxnet3\vmxnet3ndis6.inf
    
    
  7. Alternatively, you could add all the drivers under c:\winpe_x64\drivers\ in one go like this.

    dism /image:c:\winpe_x64\mount /add-driver:c:\winpe_x64\drivers /recurse
    
    
  8. You can see what drivers have been installed with the command

    dism /image:c:\winpe_x64\mount /get-drivers
    
    
  9. If you wish, you might set internationaliztion and localization options in the Windows PE environment[10]. In this example Finnish settings are used for standards and formats, keyboard layout and timezone while all other settings are set to American English by default.

    dism /image:c:\winpe_x64\mount /set-allintl:en-us
    dism /image:c:\winpe_x64\mount /set-userlocale:fi-fi
    dism /image:c:\winpe_x64\mount /set-inputlocale:fi-fi
    dism /image:c:\winpe_x64\mount /set-timezone:"FLE Standard Time"
    
    
  10. You may verify internationalization and localization settings by running the following command.

    dism /image:c:\winpe_x64\mount /get-intl
    
    
  11. If you don’t want to start the Windows Recovery Environment by default, edit c:\winpe_x64\mount\windows\system32\winpeshl.ini and replace the program that is launched by the Windows PE shell[11]. I use the following winpeshl.ini to initialize some stuff using wpeinit.exe[12] and the launch the command prompt. When your image is ready and you can boot it, you can launch The Windows Recovery Environment by running %SYSTEMDRIVE%\sources\recovery\recenv.exe from the command prompt after booting Windows PE.

    [LaunchApps]
    %SYSTEMROOT%\System32\wpeinit.exe
    %SYSTEMROOT%\System32\cmd.exe
    
    
  12. Install ImageX[13] tool from Windows AIK installation to the Windows PE environment. This allows you to work with the Windows Imaging File Format WIM[14] images within the Windows PE environment. You could use ImageX to install Windows 7 locally on a system supporting PXE booting using an installation image stored on a network share[15], for instance.

    copy "c:\Program Files\Windows AIK\Tools\amd64\imagex.exe" c:\winpe_x64\mount\Windows\system32
    
    
  13. Install any 3rd party applications and scripts you may want. Just copy the stuff somewhere under the image mount point, e.g. self-contained executables could go to c:\winpe_x64\mount\Windows\system32. Some examples include

    • Explorer++[16]
      • File manager
    • PE Network Configurator[17]
      • Allows you to configure networking in Windows PE
  14. Copy all files (but the directories containing localization data are not needed) from c:\winpe_x64\mount\Windows\Boot\PXE\ to /var/lib/tftpboot/i386/windows on the TFTP server.

  15. Unmount Windows PE 64-bit image

    imagex /unmount /commit c:\winpe_x64\mount
    
    
  16. Create Windows PE 32-bit environment. Windows 7 Ultimate 32-bit installation media must be available at g:\ so insert the DVD or mount the image first. I’ve included bulk of the commands here in one go, see the steps above for explanation.

    copype.cmd x86 c:\winpe_x86
    md c:\winpe_x86\os_install
    imagex /mount g:\sources\install.wim 1 c:\winpe_x86\os_install
    copy c:\winpe_x86\os_install\windows\system32\recovery\winre.wim c:\winpe_x86\winpe.wim
    imagex /unmount c:\winpe_x86\os_install
    rd c:\winpe_x86\os_install
    imagex /mountrw c:\winpe_x86\winpe.wim 1 c:\winpe_x86\mount
    dism /image:c:\winpe_x86\mount /add-driver:c:\winpe_x86\drivers /recurse
    dism /image:c:\winpe_x86\mount /set-allintl:en-us
    dism /image:c:\winpe_x86\mount /set-userlocale:fi-fi
    dism /image:c:\winpe_x86\mount /set-inputlocale:fi-fi
    dism /image:c:\winpe_x86\mount /set-timezone:"FLE Standard Time"
    copy "c:\Program Files\Windows AIK\Tools\x86\imagex.exe" c:\winpe_x86\mount\Windows\system32
    
    
  17. Install any 3rd party software or customizations (the winpeshl.ini customization shown above, for instance) for the Windows PE 32-bit environment in c:\winpe_x86\mount.

  18. Unmount Windows PE 32-bit image

    imagex /unmount /commit c:\winpe_x86\mount
    
    
  19. Your Windows PE images c:\winpe_x64\winpe.wim and c:\winpe_x86\winpe.wim are now ready for booting! Besides booting over PXE[18], you could create a bootable USB stick using these same images[19], for instance.

Boot configuration

  1. Create boot configuration data[20],[21] using the bcdedit tool[22].

    bcdedit /createstore c:\bcd-pxeboot
    
    
  2. Create ramdisk options in the boot configuration data

    bcdedit /store c:\bcd-pxeboot /create {ramdiskoptions}
    bcdedit /store c:\bcd-pxeboot /set {ramdiskoptions} ramdisksdidevice boot
    bcdedit /store c:\bcd-pxeboot /set {ramdiskoptions} ramdisksdipath \i386\windows\boot.sdi
    
    
  3. Create OS Loader settings for the Windows PE 64-bit image in the boot configuration data.

    bcdedit /store c:\bcd-pxeboot /create /application osloader /d "Windows PE 64-bit"
    
    
  4. Previous command will output a GUID for Windows PE 64-bit. In this guide we’ll use fa76e260-385f-11df-8c80-00241d86f38c, adjust to match yours.

    bcdedit /store c:\bcd-pxeboot /set {fa76e260-385f-11df-8c80-00241d86f38c} systemroot \Windows
    bcdedit /store c:\bcd-pxeboot /set {fa76e260-385f-11df-8c80-00241d86f38c} detecthal Yes
    bcdedit /store c:\bcd-pxeboot /set {fa76e260-385f-11df-8c80-00241d86f38c} winpe Yes
    bcdedit /store c:\bcd-pxeboot /set {fa76e260-385f-11df-8c80-00241d86f38c} osdevice ramdisk=[boot]\i386\windows\boot_x64.wim,{ramdiskoptions}
    bcdedit /store c:\bcd-pxeboot /set {fa76e260-385f-11df-8c80-00241d86f38c} device ramdisk=[boot]\i386\windows\boot_x64.wim,{ramdiskoptions}
    
    
  5. Create OS Loader settings for the Windows PE 32-bit image in the boot configuration data.

    bcdedit /store c:\bcd-pxeboot /create /application osloader /d "Windows PE 32-bit"
    
    
  6. Previous command will output a GUID for Windows PE 32-bit. In this guide we’ll use 28318ca0-3860-11df-8c80-00241d86f38c, adjust to match yours.

    bcdedit /store c:\bcd-pxeboot /set {28318ca0-3860-11df-8c80-00241d86f38c} systemroot \Windows
    bcdedit /store c:\bcd-pxeboot /set {28318ca0-3860-11df-8c80-00241d86f38c} detecthal Yes
    bcdedit /store c:\bcd-pxeboot /set {28318ca0-3860-11df-8c80-00241d86f38c} winpe Yes
    bcdedit /store c:\bcd-pxeboot /set {28318ca0-3860-11df-8c80-00241d86f38c} osdevice ramdisk=[boot]\i386\windows\boot_x86.wim,{ramdiskoptions}
    bcdedit /store c:\bcd-pxeboot /set {28318ca0-3860-11df-8c80-00241d86f38c} device ramdisk=[boot]\i386\windows\boot_x86.wim,{ramdiskoptions}
    
    
  7. Create Boot Manager settings in the boot configuration data. Boot Windows PE 64-bit by default.

    bcdedit /store c:\bcd-pxeboot /create {bootmgr}
    bcdedit /store c:\bcd-pxeboot /set {bootmgr} timeout 10
    bcdedit /store c:\bcd-pxeboot /displayorder {fa76e260-385f-11df-8c80-00241d86f38c} {28318ca0-3860-11df-8c80-00241d86f38c}
    bcdedit /store c:\bcd-pxeboot /default {fa76e260-385f-11df-8c80-00241d86f38c}
    
    

Copy files to the boot server

Note the casing of the target file names stored on the Linux server! It’s important to get these right, otherwise booting the client won’t work.

  1. Copy c:\winpe_x64\winpe.wim to the TFTP server as the file /var/lib/tftpboot/i386/windows/boot_x64.wim

  2. Copy c:\winpe_x86\winpe.wim to the TFTP server as the file /var/lib/tftpboot/i386/windows/boot_x86.wim

  3. Copy file c:\Program Files\Windows AIK\Tools\PETools\amd64\boot\boot.sdi to /var/lib/tftpboot/i386/windows on the TFTP server.

  4. Copy directory c:\Program Files\Windows AIK\Tools\PETools\amd64\boot\fonts as /var/lib/tftpboot/i386/windows/Fonts on the TFTP server.

  5. Copy the boot configuration data c:\bcd-pxeboot to the TFTP server as the file /var/lib/tftproot/i386/windows/BCD.

  6. Ensure that all files that were copied earlier from the mounted Windows PE 64-bit environment c:\winpe_x64\mount\Windows\Boot\PXE\ to /var/lib/tftpboot/i386/windows have lower case file names on the TFTP server.

Configure the boot server

  1. In order to configure PXELinux, Linux TFTP server and Windows PE network boot to work together, some tuning is required. On the server you must serve the Windows PXE boot kernel with suffix .0 or it won’t work[3]. Let’s create a symlink for that.

    ~: # ln -s pxeboot.n12 /var/lib/tftpboot/i386/windows/pxeboot.0
    
    
  2. Adjust your PXE configuration file (/var/lib/tftpboot/i386/pxelinux.cfg/default in my case) to boot /i386/windows/pxeboot.0 we just created. You could use e.g. the following PXE menu entry in /var/lib/tftpboot/i386/pxelinux.cfg/default:

    menu title Boot Menu
    ...
    label winpe
      menu label ^Windows PE
      kernel windows/pxeboot.0
    
    
  3. Configure TFTP server remapping. The Windows PE network boot system uses hard coded paths for some of the files it retrieves over TFTP. Those paths don’t match our setup here by default. It also uses backslashes instead of slashes to separate directories. This doesn’t work with TFTP server on Linux Fortunately, tftpd-hpa supports file remapping using an external configuration file[23]. Save the following text somewhere (/etc/tftpd-remap.conf for example) and adjust TFTP server startup so that this file is loaded with the tftpd -m command line option.

    # Map DOS style path separators to Unix path separators
    gr \\ /
    # Locate bootmgr.exe
    r ^bootmgr\.exe /i386/windows/bootmgr.exe
    # Map /Boot to /i386/windows
    r ^/Boot /i386/windows
    
    

References

Posted Mon Apr 19 21:51:17 2010 Tags:

Introduction

In this posting I document the steps needed to create an installer disk image from Mac OS X 10.6 Snow Leopard retail DVD in a generic way. While the process is well documented by others[1], I’ll do it here once more with a twist. The whole thing is created in shell using only command-line tools. The resulting disk image can be written onto a USB storage media and then used to install the operating system to a generic PC that is supported by the retail version of Mac OS X. You’ll need a working Mac OS X 10.6 installation running on a genuine Mac or Hackintosh with root shell access. For sake of simplicity, we use an image of the Mac OS X 10.6 Snow Leopard DVD (called ~/Desktop/Hackintosh/Mac_OS_X_10.6_Snow_Leopard.dmg in this guide) so you must create it from your physical DVD beforehand[2].

Preparing the installer image

  1. Create a disk image file for the installation media. 6500 megabytes will hold the installation partition. The disk image will be initialized with MBR partition scheme and one partition is created onto it. Soon we’ll wipe out this partition, though.

    ~: $ hdiutil create -size 6500m -layout MBRSPUD -fs HFS+ \
            ~/Desktop/Hackintosh/Mac_OS_X_10.6_Snow_Leopard_Hackintosh_Install_Disk.dmg
    
    
  2. Attach the Mac OS X 10.6 Snow Leopard retail DVD image.

    ~: $ hdiutil attach -nomount -noverify ~/Desktop/Hackintosh/Mac_OS_X_10.6_Snow_Leopard.dmg
    
    
  3. The command will print the device name for the disk. Write that down. In the guide we’re using /dev/disk1.

  4. Attach the newly created empty disk image.

    ~: $ hdiutil attach -nomount -noverify \
            ~/Desktop/Hackintosh/Mac_OS_X_10.6_Snow_Leopard_Hackintosh_Install_Disk.dmg
    
    
  5. Write down also the device name for the installer disk. In the guide we’re using /dev/disk2.

  6. Now we use dd(1) command to clone the 3rd partition from the retail DVD that holds the Mac OS X installer and write it to the 1st partition of the installer disk. Be sure to adjust the device names according to your system as you can potentially destroy your installation big time if you screw up here. This might take quite a lot of time to complete.

    ~: $ dd bs=1m if=/dev/disk1s3 of=/dev/disk2s1
    
    
  7. Then mount the installer disk. The installer file system should be available at /Volumes/Mac OS X Install DVD.

    ~: $ diskutil mount /dev/disk2s1
    
    
  8. Fix the installer mountpoint so that file can be owned by root.

    ~: $ sudo diskutil enableOwnership /dev/disk2s1
    
    
  9. Rename the installer file system. After that the installer file system is available at /Volumes/Hackintosh Snow Leopard Install Disk.

    ~: $ diskutil rename /dev/disk2s1 "Hackintosh Snow Leopard Install Disk"
    
    
  10. Mark the file system so that fseventsd doesn’t keep any logs there.

    ~: $ sudo rm -rf /Volumes/Hackintosh\ Snow\ Leopard\ Install\ Disk/.fseventsd
    ~: $ sudo install -o root -g admin -m 700 -d /Volumes/Hackintosh\ Snow\ Leopard\ Install\ Disk/.fseventsd
    ~: $ sudo touch /Volumes/Hackintosh\ Snow\ Leopard\ Install\ Disk/.fseventsd/no_log
    ~: $ sudo chmod 400 /Volumes/Hackintosh\ Snow\ Leopard\ Install\ Disk/.fseventsd/no_log
    ~: $ sudo chown root:admin /Volumes/Hackintosh\ Snow\ Leopard\ Install\ Disk/.fseventsd/no_log
    
    

Install Chameleon boot loader

  1. The installer won’t boot on a generic PC without a special boot loader which loads the Mac OS X kernel in an environment that emulates real Mac. See more about Chameleon in the posting Create preboot image for Chameleon bootloader. Download Chameleon 2.0-RC4[3] boot loader and extract Chameleon-2.0-RC4-r684-bin.tar.gz somewhere, e.g. ~/Desktop/Hackintosh thus creating directory ~/Desktop/Hackintosh/Chameleon-2.0-RC4-r684-bin.

  2. First, unmount the installer disk so that we can write directly to the block device.

    ~: $ diskutil unmount /dev/disk2s1
    
    
  3. Next few steps are also documented in the file doc/README under Chameleon directory. We’ll install the initial boot code to the master boot record of the installer disk.

    ~: $ sudo dd if=~/Desktop/Hackintosh/Chameleon-2.0-RC4-r684-bin/i386/boot0 of=/dev/disk2 bs=440 count=1
    
    
  4. And then let’s install the 2nd stage boot code at the beginning of the 1st partition of the installer disk.

    ~: $ sudo dd if=~/Desktop/Hackintosh/Chameleon-2.0-RC4-r684-bin/i386/boot1h of=/dev/disk2s1
    
    
  5. Mount the installer disk again. The installer file system should be available at /Volumes/Hackintosh Snow Leopard Install Disk.

    ~: $ diskutil mount /dev/disk2s1
    
    
  6. Fix the installer mountpoint so that file can be owned by root.

    ~: $ sudo diskutil enableOwnership /dev/disk2s1
    
    
  7. And then copy the final stage of Chameleon boot code to the installer file system. We’re now done with the boot loader core installation.

    ~: $ sudo install -o root -g wheel -m 644 ~/Desktop/Hackintosh/Chameleon-2.0-RC4-r684-bin/i386/boot \
            /Volumes/Hackintosh\ Snow\ Leopard\ Install\ Disk
    
    
  8. While not needed for Chameleon to operate, copy also the initial and 2nd stage boot code images to the installer file system. You may need these if you have to recover Chameleon installation.

    ~: $ sudo install -o root -g wheel -m 644 ~/Desktop/Hackintosh/Chameleon-2.0-RC4-r684-bin/i386/boot0 \
            /Volumes/Hackintosh\ Snow\ Leopard\ Install\ Disk
    ~: $ sudo install -o root -g wheel -m 644 ~/Desktop/Hackintosh/Chameleon-2.0-RC4-r684-bin/i386/boot1h \
            /Volumes/Hackintosh\ Snow\ Leopard\ Install\ Disk
    
    

Preboot image

Create preboot image for Chameleon that suits your system. I’ve written about this in the posting called Create preboot image for Chameleon bootloader. In the following steps it is expected that the preboot image is saved as the file ~/Desktop/Hackintosh/Preboot.dmg.

  1. Chameleon expects to find the preboot image under the directory Extra in the root of the installer file system. So let’s create that.

    ~: $ sudo install -o root -g wheel -m 755 -d /Volumes/Hackintosh\ Snow\ Leopard\ Install\ Disk/Extra
    
    
  2. Install the preboot image onto the installer file system

    ~: $ sudo install -o root -g wheel -m 644 ~/Desktop/Hackintosh/Preboot.dmg \
            /Volumes/Hackintosh\ Snow\ Leopard\ Install\ Disk/Extra
    
    

Boot configuration

Optionally, you can customize many boot properties such as boot console graphics mode or enabled hardware by creating the file Extra/com.apple.Boot.plist under the Chameleon boot disk. You could start by copying the file /Library/Preferences/SystemConfiguration/com.apple.Boot.plist from an existing Mac OS X Snow Leopard installation and then use it as template. Chameleon binary download[3] contains the file doc/BootHelp.txt which lists the supported com.apple.Boot.plist settings. Also these postings[4],[5] contain some useful info about com.apple.Boot.plist file.

If you want that the installer is booted automatically without displaying Chameleon GUI, use the following kind of boot configuration and save it as /Volumes/Hackintosh Snow Leopard Install Disk/Extra/com.apple.Boot.plist. Of course you may also add any local modifications, such as enabling of some hardware, if needed.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Kernel</key>
    <string>mach_kernel</string>
    <key>Kernel Flags</key>
    <string></string>
    <key>Legacy Logo</key>
    <string>Yes</string>
    <key>Quiet Boot</key>
    <string>Yes</string>
    <key>GUI</key>
    <string>No</string>
    <key>Scan Single Drive</key>
    <string>Yes</string>
</dict>
</plist>

Finalizing the installer

  1. Cleanup installer file system

    ~: $ sudo rm -rf /Volumes/Hackintosh\ Snow\ Leopard\ Install\ Disk/.Trashes
    
    
  2. Image is now ready! You can now eject the retail DVD and the installer disk images.

    ~: $ diskutil eject /dev/disk1
    ~: $ diskutil eject /dev/disk2
    
    

The installer image ~/Desktop/Hackintosh/Mac_OS_X_10.6_Snow_Leopard_Hackintosh_Install_Disk.dmg is now ready to be written onto a USB storage media.

References

Posted Mon Apr 19 21:50:49 2010 Tags:

Introduction

This is documentation of the hardware specific configuration that my Hackintosh requires in order to run unpatched retail version of Mac OS X 10.6 Snow Leopard perfectly. So this is not a generic guide, more like reminder for myself. Of course many of these tricks can be applied to other hardware configurations as well, especially if using a motherboard manufactured by Gigabyte.

The hardware configuration is the following:

  • Intel Xeon X3350 processor
  • 4x 1GB Kingston HyperX KHX8500D2
  • Gigabyte GA-EX38-DS5 motherboard, BIOS version F4
    • Intel ICH9 chipset
    • ALC889 audio chip
  • Gigabyte GV-NX88T512HP NVIDIA GeForce 8800 GT graphics card
  • 3ware 9650SE-4LPML SATA RAID controller
    • 4x Western Digital Velociraptor 300GB WD3000GLFS hard disks configured in RAID10

See my hardware inventory on the machine for more details about the system.

Kernel extensions

Besides the mendatory kernel extensions I need the following drivers to be placed inside the preboot image as described in the article Create preboot image for Chameleon bootloader.

  • LSI3ware9000.kext [1]
    • Driver for the 3ware RAID Controller. Referenced driver is a beta release. The current stable release[2] doesn’t support 64-bit driver as of writing this.

DSDT patches

I use the following set of patches that are applied against the ASL source of the DSDT of the motherboard that was extracted and decompiled as documented in the posting Create preboot image for Chameleon bootloader.

Fix compiler errors

This patch fixes errors in the source code noted by iasl compiler[3],[4]

--- dsdt.dsl.orig  2010-02-05 22:34:31.000000000 +0200
+++ dsdt.dsl       2010-02-05 22:37:10.000000000 +0200
@@ -276,18 +276,23 @@
         Notify (\_SB.PCI0.USB3, 0x00)
         Notify (\_SB.PCI0.USB4, 0x00)
         Notify (\_SB.PCI0.USB5, 0x00)
+        Return (Package (0x02)
+        {
+            Zero,
+            Zero
+        })
     }

     Scope (\_SI)
     {
         Method (_MSG, 1, NotSerialized)
         {
-            Store (Local0, Local0)
+            Store (Zero, Local0)
         }

         Method (_SST, 1, NotSerialized)
         {
-            Store (Local0, Local0)
+            Store (Zero, Local0)
         }
     }

Download patch

Fix CMOS corruption

Booting Mac OS X without this patch corrupts the CMOS of the motherboard[4],[5],[6]. You don’t need ElliottForceLegacyRTC.kext when this is applied.

--- dsdt.dsl.orig  2010-02-05 22:34:31.000000000 +0200
+++ dsdt.dsl       2010-02-05 23:42:48.000000000 +0200
@@ -3144,7 +3144,7 @@
                             0x0070,             // Range Minimum
                             0x0070,             // Range Maximum
                             0x00,               // Alignment
-                            0x04,               // Length
+                            0x02,               // Length
                             )
                         IRQNoFlags ()
                             {8}
@@ -3155,7 +3155,7 @@
                             0x0070,             // Range Minimum
                             0x0070,             // Range Maximum
                             0x00,               // Alignment
-                            0x04,               // Length
+                            0x02,               // Length
                             )
                     })
                     Method (_CRS, 0, NotSerialized)

Download patch

CPU power management

The following fixes are needed in order to make native Mac OS X CPU power management work[3],[4]. You don’t need NullCPUPowerManagement.kext when this is applied.

--- dsdt.dsl.orig  2010-02-17 03:07:40.000000000 +0200
+++ dsdt.dsl       2010-02-17 03:10:23.000000000 +0200
@@ -3060,21 +3060,7 @@
                     })
                     Method (_CRS, 0, NotSerialized)
                     {
-                        If (LGreaterEqual (OSFX, 0x03))
-                        {
-                            If (HPTF)
-                            {
-                                Return (ATT6)
-                            }
-                            Else
-                            {
-                                Return (ATT5)
-                            }
-                        }
-                        Else
-                        {
-                            Return (ATT5)
-                        }
+                        Return (ATT6)
                     }
                 }

@@ -3097,40 +3083,12 @@
                     })
                     Method (_STA, 0, NotSerialized)
                     {
-                        If (LGreaterEqual (OSFX, 0x03))
-                        {
-                            If (HPTF)
-                            {
-                                Return (0x0F)
-                            }
-                            Else
-                            {
-                                Return (0x00)
-                            }
-                        }
-                        Else
-                        {
-                            Return (0x00)
-                        }
+                        Return (0x0F)
                     }

                     Method (_CRS, 0, NotSerialized)
                     {
-                        If (LGreaterEqual (OSFX, 0x03))
-                        {
-                            If (HPTF)
-                            {
-                                Return (ATT3)
-                            }
-                            Else
-                            {
-                                Return (ATT4)
-                            }
-                        }
-                        Else
-                        {
-                            Return (ATT4)
-                        }
+                        Return (ATT3)
                     }
                 }

@@ -3159,21 +3117,7 @@
                     })
                     Method (_CRS, 0, NotSerialized)
                     {
-                        If (LGreaterEqual (OSFX, 0x03))
-                        {
-                            If (HPTF)
-                            {
-                                Return (ATT1)
-                            }
-                            Else
-                            {
-                                Return (ATT0)
-                            }
-                        }
-                        Else
-                        {
-                            Return (ATT0)
-                        }
+                        Return (ATT1)
                     }
                 }

Download patch

Enable autoinsertion of EFI strings for the graphics card

Chameleon supports autoinsertion of EFI strings for NVIDIA graphics card[7]. Unfortunately, there’s a bug with Gigabyte DSDT that prevents this from working[3]. In order to fix that you need the following patch.

--- dsdt.dsl.orig  2010-02-05 22:34:31.000000000 +0200
+++ dsdt.dsl       2010-02-08 03:18:09.000000000 +0200
@@ -401,7 +401,7 @@
         {
             Name (_HID, EisaId ("PNP0A03"))
             Name (_ADR, 0x00)
-            Name (_UID, 0x01)
+            Name (_UID, 0x00)
             Name (_BBN, 0x00)
             Method (_S3D, 0, NotSerialized)
             {

Download patch

Enable device data insertion

Some of the patches below requires the DTGP method in order to insert faked device ids, layout ids and other data to the onboard devices and thus fooling Mac OS X to believe genuine Apple components exists in the system for which the stock drivers can be load [4].

--- dsdt.dsl.orig  2010-02-09 00:34:52.000000000 +0200
+++ dsdt.dsl       2010-02-09 00:34:40.000000000 +0200
@@ -218,6 +218,38 @@
             }
         }
     }
+    Method (DTGP, 5, NotSerialized)
+    {
+        If (LEqual (Arg0, Buffer (0x10)
+                {
+                    /* 0000 */    0xC6, 0xB7, 0xB5, 0xA0, 0x18, 0x13, 0x1C, 0x44,
+                    /* 0008 */    0xB0, 0xC9, 0xFE, 0x69, 0x5E, 0xAF, 0x94, 0x9B
+                }))
+        {
+            If (LEqual (Arg1, One))
+            {
+                If (LEqual (Arg2, Zero))
+                {
+                    Store (Buffer (One)
+                        {
+                            0x03
+                        }, Arg4)
+                    Return (One)
+                }
+
+                If (LEqual (Arg2, One))
+                {
+                    Return (One)
+                }
+            }
+        }
+
+        Store (Buffer (One)
+            {
+                0x00
+            }, Arg4)
+        Return (Zero)
+    }
     Method (\_WAK, 1, NotSerialized)
     {
         Store (0xFF, DBG1)

Download patch

Power button

This patch enables you to put the computer to sleep by pressing the power button[4].

--- dsdt.dsl.orig  2010-02-17 03:29:10.000000000 +0200
+++ dsdt.dsl       2010-02-17 03:29:32.000000000 +0200
@@ -389,7 +389,7 @@
     {
         Device (PWRB)
         {
-            Name (_HID, EisaId ("PNP0C0C"))
+            Name (_CID, EisaId ("PNP0C0C"))
             Method (_STA, 0, NotSerialized)
             {
                 Return (0x0B)

Download patch

USB

This patch changes the device ids of the USB controller to match those of Intel ICH10 chipset which Mac OS X recognizes as built-in. It is important to have the USB ports seen as built-in by Mac OS X or otherwise you’ll get problems when resuming the machine from sleep[8],[9].

--- dsdt.dsl.orig  2010-02-19 00:22:15.000000000 +0200
+++ dsdt.dsl       2010-02-19 00:27:51.000000000 +0200
@@ -4084,6 +4084,19 @@
                     0x03,
                     0x03
                 })
+                Method (_DSM, 4, NotSerialized)
+                {
+                    Store (Package (0x02)
+                    {
+                        "device-id",
+                        Buffer (0x04)
+                        {
+                            0x34, 0x3A, 0x00, 0x00
+                        },
+                     }, Local0)
+                     DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))
+                     Return (Local0)
+                 }
             }

             Device (USB1)
@@ -4104,6 +4117,19 @@
                     0x04,
                     0x03
                 })
+                Method (_DSM, 4, NotSerialized)
+                {
+                    Store (Package (0x02)
+                    {
+                        "device-id",
+                        Buffer (0x04)
+                        {
+                            0x35, 0x3A, 0x00, 0x00
+                        },
+                     }, Local0)
+                     DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))
+                     Return (Local0)
+                 }
             }

             Device (USB2)
@@ -4124,6 +4150,19 @@
                     0x0C,
                     0x03
                 })
+                Method (_DSM, 4, NotSerialized)
+                {
+                    Store (Package (0x02)
+                    {
+                        "device-id",
+                        Buffer (0x04)
+                        {
+                            0x36, 0x3A, 0x00, 0x00
+                        },
+                     }, Local0)
+                     DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))
+                     Return (Local0)
+                 }
             }

             Device (USB3)
@@ -4164,6 +4203,19 @@
                     0x0E,
                     0x03
                 })
+                Method (_DSM, 4, NotSerialized)
+                {
+                    Store (Package (0x02)
+                    {
+                        "device-id",
+                        Buffer (0x04)
+                        {
+                            0x37, 0x3A, 0x00, 0x00
+                        },
+                     }, Local0)
+                     DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))
+                     Return (Local0)
+                 }
             }

             Device (USB4)
@@ -4184,6 +4236,19 @@
                     0x05,
                     0x03
                 })
+                Method (_DSM, 4, NotSerialized)
+                {
+                    Store (Package (0x02)
+                    {
+                        "device-id",
+                        Buffer (0x04)
+                        {
+                            0x38, 0x3A, 0x00, 0x00
+                        },
+                     }, Local0)
+                     DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))
+                     Return (Local0)
+                 }
             }

             Device (USB5)
@@ -4204,6 +4269,19 @@
                     0x20,
                     0x03
                 })
+                Method (_DSM, 4, NotSerialized)
+                {
+                    Store (Package (0x02)
+                    {
+                        "device-id",
+                        Buffer (0x04)
+                        {
+                            0x39, 0x3A, 0x00, 0x00
+                        },
+                     }, Local0)
+                     DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))
+                     Return (Local0)
+                 }
             }

             Device (USBE)
@@ -4224,6 +4302,24 @@
                     0x0D,
                     0x03
                 })
+                Method (_DSM, 4, NotSerialized)
+                {
+                    Store (Package (0x04)
+                    {
+                        "device-id",
+                        Buffer (0x04)
+                        {
+                            0x3A, 0x3A, 0x00, 0x00
+                        },
+                        "AAPL,clock-id",
+                        Buffer (0x01)
+                        {
+                            0x0A
+                        },
+                     }, Local0)
+                     DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))
+                     Return (Local0)
+                 }
             }

             Device (USE2)
@@ -4244,6 +4340,24 @@
                     0x0D,
                     0x03
                 })
+                Method (_DSM, 4, NotSerialized)
+                {
+                    Store (Package (0x04)
+                    {
+                        "device-id",
+                        Buffer (0x04)
+                        {
+                            0x3C, 0x3A, 0x00, 0x00
+                        },
+                        "AAPL,clock-id",
+                        Buffer (0x01)
+                        {
+                            0x0A
+                        },
+                     }, Local0)
+                     DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))
+                     Return (Local0)
+                 }
             }

             Device (IDE1)

Download patch

SATA

This patch fakes the device ids of the onboard SATA AHCI devices to match Intel ESB2 AHCI controller. Mac OS X will detect devices connected to ESB2 controller as internal. Without this patch the controller model is not detected by Apple’s SATA AHCI driver and the controller is seen as external. Since real Macs don’t offer any eSATA ports and thus Mac OS X lacks proper SATA hot-plugging facilities[10], this doesn’t affect functionality of the SATA controller or disks connected to it. But without this patch the disks will get the orange external disk icon in Finder. With the DSDT patch applied disks connected to the motherboard SATA connectors will show the gray internal disk icon[11].

--- dsdt.dsl.orig  2010-02-17 02:02:37.000000000 +0200
+++ dsdt.dsl       2010-02-17 02:04:40.000000000 +0200
@@ -4272,6 +4272,19 @@
                     FAS1,   2
                 }

+                Method (_DSM, 4, NotSerialized)
+                {
+                    Store (Package (0x02)
+                        {
+                            "device-id",
+                            Buffer (0x04)
+                            {
+                                0x81, 0x26, 0x00, 0x00
+                            }
+                        }, Local0)
+                    DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))
+                    Return (Local0)
+                }
                 Device (PRIM)
                 {
                     Name (_ADR, 0x00)
@@ -4394,6 +4407,19 @@
                     FAS1,   2
                 }

+                Method (_DSM, 4, NotSerialized)
+                {
+                    Store (Package (0x02)
+                        {
+                            "device-id",
+                            Buffer (0x04)
+                            {
+                                0x81, 0x26, 0x00, 0x00
+                            }
+                        }, Local0)
+                    DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))
+                    Return (Local0)
+                }
                 Device (PRIM)
                 {
                     Name (_ADR, 0x00)

Download patch

Audio

The following patch enables the ALC889 audio to work with stock Apple drivers[4].

--- dsdt.dsl.orig  2010-02-05 22:34:31.000000000 +0200
+++ dsdt.dsl       2010-02-09 00:24:11.000000000 +0200
@@ -341,7 +341,7 @@
             Notify (\_SB.PCI0.USBE, 0x02)
             Notify (\_SB.PCI0.USE2, 0x02)
             Notify (\_SB.PWRB, 0x02)
-            Notify (\_SB.PCI0.AZAL, 0x02)
+            Notify (\_SB.PCI0.HDEF, 0x02)
         }

         Method (_L02, 0, NotSerialized)
@@ -5062,7 +5062,7 @@
                 }
             }

-            Device (AZAL)
+            Device (HDEF)
             {
                 Name (_ADR, 0x001B0000)
                 Method (_PRW, 0, NotSerialized)
@@ -5073,6 +5073,21 @@
                         0x05
                     })
                 }
+                Method (_DSM, 4, NotSerialized)
+                {
+                    Store (Package (0x04)
+                    {
+                        "layout-id",
+                        Buffer (0x04)
+                        {
+                            0x42, 0x00, 0x00, 0x00
+                        },
+                        "PinConfigurations",
+                        Buffer (Zero) {}
+                    }, Local0)
+                    DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))
+                    Return (Local0)
+                }
             }

             Name (BUFA, ResourceTemplate ()

Download patch

Networking

The following patch makes Mac OS X see the onboard Ethernet devices as built-in, not external. Mac OS X uses the MAC address of the machine’s primary built-in network interface as part of the machine’s unique id[4].

--- dsdt.dsl.orig  2010-02-17 01:26:56.000000000 +0200
+++ dsdt.dsl       2010-02-17 01:26:38.000000000 +0200
@@ -1321,6 +1321,33 @@
                     })
                 }

+                Device (LAN0)
+                {
+                    Name (_ADR, 0x00)
+                    Name (_PRW, Package (0x02)
+                    {
+                       0x0B,
+                       0x04
+                    })
+                    Method (_DSM, 4, NotSerialized)
+                    {
+                       Store (Package (0x04)
+                       {
+                          "built-in",
+                          Buffer (0x01)
+                          {
+                             0x01
+                          },
+                          "device_type",
+                          Buffer (0x09)
+                          {
+                             "ethernet"
+                          }
+                       }, Local0)
+                       DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))
+                       Return (Local0)
+                    }
+                }
                 Name (PIC4, Package (0x04)
                 {
                     Package (0x04)
@@ -1419,6 +1446,33 @@
                     })
                 }

+                Device (LAN1)
+                {
+                    Name (_ADR, 0x00)
+                    Name (_PRW, Package (0x02)
+                    {
+                       0x0B,
+                       0x04
+                    })
+                    Method (_DSM, 4, NotSerialized)
+                    {
+                       Store (Package (0x04)
+                       {
+                          "built-in",
+                          Buffer (0x01)
+                          {
+                             0x01
+                          },
+                          "device_type",
+                          Buffer (0x09)
+                          {
+                             "ethernet"
+                          }
+                       }, Local0)
+                       DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))
+                       Return (Local0)
+                    }
+                }
                 Name (PIC5, Package (0x04)
                 {
                     Package (0x04)

Download patch

SMBIOS

This is just for the cosmetics, but I use the following smbios.plist to set the system serial number and some other hardware details.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>SMserial</key>
    <string>IICOROE2TEI</string>
    <key>SMbiosvendor</key>
    <string>Gigabyte</string>
    <key>SMbiosversion</key>
    <string>F4</string>
    <key>SMbiosdate</key>
    <string>07/25/2008</string>
    <key>SMboardmanufacturer</key>
    <string>Gigabyte</string>
    <key>SMboardproduct</key>
    <string>GA-EX38-DS5</string>
    <key>SMmemtype</key>
    <string>19</string>
    <key>SMmemspeed</key>
    <string>1066</string>
    <key>SMmemmanufacter</key>
    <string>Kingston</string>
    <key>SMmempart_1</key>
    <string>KHX8500D2</string>
    <key>SMmempart_2</key>
    <string>KHX8500D2</string>
    <key>SMmempart_3</key>
    <string>KHX8500D2</string>
    <key>SMmempart_4</key>
    <string>KHX8500D2</string>
</dict>
</plist>

Boot configuration

I use the following com.apple.Boot.plist. It allows booting of Mac OS X with no delays. Also booting is limited to the disk where the Chameleon bootloader was load from since this disk also contains the Mac OS X installation.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Kernel</key>
    <string>mach_kernel</string>
    <key>Kernel Flags</key>
    <string></string>
    <key>GraphicsEnabler</key>
    <string>Yes</string>
    <key>Legacy Logo</key>
    <string>Yes</string>
    <key>Quiet Boot</key>
    <string>Yes</string>
    <key>GUI</key>
    <string>No</string>
    <key>Scan Single Drive</key>
    <string>Yes</string>
</dict>
</plist>

References

Posted Mon Apr 19 21:50:21 2010 Tags:

Introduction

When running non-modified retail version of Mac OS X on a generic PC, a special boot loader is needed in order to trick the vanilla Apple operating system to think it’s running on a genuine Mac[1]. One of these boot loaders is called Chameleon[2]. But Chameleon installation requires some tweaking in order to do the magic. It’s not enough just to install Chameleon on the system disk but you also need some hardware-specific configuration in order to enjoy a fully working Hackintosh system.

The configuration consists of multiple files. You could install these files directly to the system disk you’re booting from or the EFI file partition if using hard disk with GPT partition layout. But it’s also possible to bundle all the needed stuff except boot configuration inside a single disk image file which Chameleon loads on startup and reads the files inside the image. This way you only need to install this preboot image file and boot configuration file and your system disk remains less polluted. I find this approach much more appealing as it allows me to keep the system as clean as possible.

In this guide we’re going to create a Chameleon preboot image from the scratch in a generic way. It is assumed that the machine and motherboard in particular in use has good compatibility with vanilla Mac OS X Snow Leopard. In practice this means Intel Core 2 processor with Intel chipset on the motherboard. You’ll also need a working Mac OS X 10.5 or 10.6 installation running on a genuine Mac or Hackintosh with root shell access. The whole process is being done in the shell using command-line tools. Also if you’re going to patch your DSDT, you’re probably going to need a way to boot Linux on the machine if you don’t have Mac OS X already installed. Ubuntu Live CD would do it just fine[3].

Preparing the preboot image

  1. Create the preboot disk image and mount it. We’re using the file ~/Desktop/Hackintosh/Preboot.dmg in this guide.

    ~: $ hdiutil create -size 4m -layout MBRSPUD -fs HFS+ -uid 0 -gid 0 \
            -volname Preboot ~/Desktop/Hackintosh/Preboot.dmg
    ~: $ hdiutil attach -noverify ~/Desktop/Hackintosh/Preboot.dmg
    
    
  2. Write down the device name for the preboot disk. In the guide we’re using /dev/disk3.

  3. Fix the preboot mountpoint so that file can be owned by root.

    ~: $ sudo diskutil enableOwnership /dev/disk3s1
    
    
  4. Mark the file system so that fseventsd doesn’t keep any logs there.

    ~: $ sudo rm -rf /Volumes/Preboot/.fseventsd
    ~: $ sudo install -o root -g admin -m 700 -d /Volumes/Preboot/.fseventsd
    ~: $ sudo touch /Volumes/Preboot/.fseventsd/no_log
    ~: $ sudo chmod 400 /Volumes/Preboot/.fseventsd/no_log
    ~: $ sudo chown root:admin /Volumes/Preboot/.fseventsd/no_log
    
    

Kernel extensions

Chameleon needs to load some kernel extensions prior to booting the Mac OS X kernel in order to fix some issues running the Apple operating system on non-Apple hardware. Also Mac OS X may not include drivers for all of your hardware so you need to add any 3rd party drivers that your hardware needs to function. You can read this article[4] to find more about kernel extensions.

  1. Create directory to hold the kernel extensions. You must not change the path as Chameleon expects to find the kernel extensions under Extra/Extensions directory under the root of the preboot volume.

    ~: $ sudo mkdir -p /Volumes/Preboot/Extra/Extensions
    
    
  2. Download the following mendatory kernel extensions saving each .kext file under /Volumes/Preboot/Extra/Extensions.

    • fakesmc.kext [5],[6]
      • System Management Controller emulator. Mac OS X won’t boot on a Hackintosh without this.
    • OpenHaltRestart.kext [7]
      • Fixes shutdown/restart issues.
  3. You may want to include the following additional generic kernel extensions.

  4. Download any 3rd party driver kernel extensions for your hardware and place them under /Volumes/Preboot/Extra/Extensions too. Good places to find additional kernel extensios are kexts.com[11] and myHack[10]. For a real-world example, you can read my posting Technical details of my Hackintosh installation.

  5. Fix permissions and ownership of the kernel extensions. Kernel extensions won’t load if the files are not owned by root:wheel[12].

    ~: $ sudo find /Volumes/Preboot/Extra/Extensions -type f -exec chmod 644 {} \;
    ~: $ sudo find /Volumes/Preboot/Extra/Extensions -type d -exec chmod 755 {} \;
    ~: $ sudo chown -R root:wheel /Volumes/Preboot/Extra/Extensions
    
    
  6. Create/update extensions cache

    ~: $ sudo kextcache -m /Volumes/Preboot/Extra/Extensions.mkext /Volumes/Preboot/Extra/Extensions
    
    

Patch DSDT

DSDT[13],[14] is an ACPI table that is stored in the BIOS. In order to work correctly, some functionality in Mac OS X depends on features of the DSDT that can be found on Macs. The DSDT in your generic PC’s BIOS might be incorrect or buggy when used with Mac OS X. Chameleon supports overriding the DSDT provided by your hardware with a version loaded prior to loading the operating system. Thus you can create a patched DSDT for your hardware based on your original DSDT that is also compatible with Mac OS X and make your Hackintosh behave well without modifying hardware or BIOS.

The plan for DSDT patching is straightforward.

  1. First you need to extract the DSDT binary code in AML format (ACPI Machine Language) wired to your BIOS.

  2. Then you decompile the AML binary to ASL (ACPI Source Language), which is source code to the AML binary in ASCII format.

  3. Edit the AML source code to patch in any desired fixes.

  4. Compile the patched AML source to get an updated DSDT AML binary file.

  5. You need to include the resulting DSDT AML binary file in the Chameleon preboot environment so Chameleon can find and load it and override the built-in DSDT with the patched one on system startup.

For decompilation and compilation of DSDT you need Intel ASL compiler/decompiler[15]. For Debian/Ubuntu, the tool is available in the package iasl[16]. Mac version[17] is also available. The iasl binary is stored in the Tools directory of the linked download.

Actual changes to the DSDT are always dependant on the combination of particular hardware and BIOS version so I’ll go through these steps here in a generic way.

Extracting the DSDT AML binary

In Linux, the DSDT extraction is a breeze as the blob available under the /proc file system[14]. Just run

    ~: $ sudo install -o `whoami` /proc/acpi/dsdt ~/dsdt-original.aml

and you have a copy of your DSDT AML binary in the file ~/dsdt-original.aml.

In Mac OS X you can extract the DSDT AML binary to the file ~/Desktop/Hackintosh/dsdt-original.aml by running the following command:

    ~: $ ioreg -lw0 | perl -pne'$_=pack"c*",map{hex}unpack"(A2)*",($_=~/"DSDT"=<([^>]+)/)[0]' \
            > ~/Desktop/Hackintosh/dsdt-original.aml

Note that if running Mac OS X, be sure that the system doesn’t have a patched currently DSDT applied or you won’t be able to extract the original DSDT in the BIOS!

Decompiling DSDT AML binary to ASL source

Use the following iasl command to decompile the DSDT AML binary ~/Desktop/Hackintosh/dsdt-original.aml and save it as ASL source file ~/Desktop/Hackintosh/dsdt.dsl:

    ~: $ iasl -d ~/Desktop/Hackintosh/dsdt-original.aml && \
            mv ~/Desktop/Hackintosh/dsdt-original.dsl ~/Desktop/Hackintosh/dsdt.dsl

Editing the DSDT ASL source

Now you can edit the file ~/Desktop/Hackintosh/dsdt.dsl and fix any hardware-specific problems with the DSDT. I’ve documented the needed DSDT patches for one of my systems in the posting Technical details of my Hackintosh installation. Many of these patches are quite generic.

Compiling ASL source to DSDT AML binary

After applying the desired set of patches, compile the ASL source back to a DSDT AML binary file ~/Desktop/Hackintosh/dsdt.aml with the following command:

    ~: $ iasl ~/Desktop/Hackintosh/dsdt.dsl

Configuring Chameleon preboot image to load the DSDT AML binary

Let’s say you have the modified DSDT AML binary saved as the file ~/Desktop/Hackintosh/dsdt.aml. In order for Chameleon to find and load the patched DSDT, the file needs to be installed as Extra/dsdt.aml under the preboot image root. So copy it like this:

    ~: $ sudo install -o root -g wheel -m 644 ~/Desktop/Hackintosh/dsdt.aml /Volumes/Preboot/Extra

Customizing SMBIOS

System Management BIOS or SMBIOS stores some details about your hardware[18],[19]. In Mac OS X you can view the current SMBIOS information with System Profiler.app. Chameleon allows customization of the SMBIOS values. You can do this by creating the file Extra/smbios.plist under the preboot image root. You could use this feature to make your Hackintosh mimic some existing Mac model or you could provide your own values. It’s all optional, though. But If you want to do that, then read these articles[20],[21] for more details and save the resulting file as /Volumes/Preboot/Extra/smbios.plist.

Here is a sample smbios.plist which gives the system a custom serial number.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>SMserial</key>
    <string>CEIF6JI3XU6</string>
</dict>
</plist>

Configure Chameleon to use the preboot image

By default Chameleon tries to find DSDT and SMBIOS data from the system disk. In order to instruct Chameleon to use the preboot image, the file RAMDisk.plist needs to be added to the root directory of the preboot file system. So save the this as /Volumes/Preboot/RAMDisk.plist.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>BTAlias</key>
    <string>Yes</string>
</dict>
</plist>

Finalize preboot image

  1. Cleanup preboot file system

    ~: $ sudo find /Volumes/Preboot -type f -exec chmod 644 {} \;
    ~: $ sudo find /Volumes/Preboot -type d -a ! -name .fseventsd -exec chmod 755 {} \;
    ~: $ sudo chown -R root:wheel /Volumes/Preboot
    ~: $ sudo find /Volumes/Preboot -name .DS_Store -exec rm {} \;
    ~: $ sudo rm -rf /Volumes/Preboot/.Trashes
    
    
  2. Eject the preboot disk

    ~: $ hdiutil eject /dev/disk3
    
    

The preboot image ~/Desktop/Hackintosh/Preboot.dmg is now ready to be deployed in the Extra directory of a Chameleon boot disk.

References

Posted Mon Apr 19 21:49:45 2010 Tags:

Introduction

In this guide I document how you can create a disk image of bootable Windows 7 installation media without having a working Windows installation in hand. The image could be written to a physical USB storage device. This guide is an adaptation of the standard way to create Windows 7 USB installation media that are all around the net[1],[2].

Preparation

During this guide we’re assuming that

  • You have a 64-bit Linux installation at hand with capability to run KVM virtual machines
    • Ubuntu 9.10 was used when writing this posting
  • Root access on the said Linux machine
  • The target platform is Windows 7 64-bit
  • Bootable ISO image of Windows 7 installation media exists
    • We’re using the image 7600.16385.090713-1255_x64fre_client_en-us_Retail_Ultimate-GRMCULXFRER_EN_DVD.iso

It should be very straightforward to adapt this guide to apply to 32-bit Linux host or Windows 7 target.

Creating the image

  1. First create a disk image file for the Windows 7 installation media. 3200 megabytes will hold the installer of Windows 7 Ultimate 64-bit.

    ~: # qemu-img create -f raw /scratch/images/win7.img 3200M
    
    
  2. Launch KVM so that the virtual machine boots from CD-ROM that has the Windows 7 installation ISO image attached to it. Also the empty disk image is added to the virtual machine.

    ~: # kvm -cpu qemu64 -m 1024 -vnc :1 -hda /scratch/images/win7.img -cdrom \
            /scratch/images/7600.16385.090713-1255_x64fre_client_en-us_Retail_Ultimate-GRMCULXFRER_EN_DVD.iso
    
    
  3. Connect to the display of the virtual machine using a VNC viewer. You should see Windows 7 installation program loading. Make your language / localization / keyboard selections and press Next.

  4. Choose Repair your computer

  5. Select Use recovery tools that can help fix problems starting Windows and click Next.

  6. Click Command Prompt

  7. Now we’re using diskpart[3] utility that can be launched from the recovery shell.

    X:\Sources>diskpart
    
    
  8. Input the following commands in order to partition and format the virtual disk.

    select disk 0
    create partition primary
    select partition 1
    active
    format fs=ntfs quick
    assign
    exit
    
    
  9. The virtual disk is now available as drive C:. Now you can copy the contents of the installation media (CD-ROM drive D:) onto it.

    xcopy d:\ c:\ /e
    
    
  10. Close the shell and click Shut Down in the System Recovery Options window.

  11. The installation disk is now ready! Now you can write the disk image file win7.img to a physical USB storage device with e.g. dd(1).

References

Posted Sun Jan 31 20:20:20 2010 Tags:

Self note for installing AIX Technology Levels and Service Packs.

  1. cd /scratch/6100-02-00-0846
  2. bffcreate -c -d .
  3. rm -f .toc
  4. inutoc .
  5. /usr/lib/instl/sm_inst installp_cmd -a -d $PWD -f _update_all -c -N -g -X -Y
Posted Tue Jan 26 22:33:03 2010 Tags:

It’s being oh-so on the edge and way too cool to have your personal blog. You know, a place where you write a couple of times “I met some interesting people today” or “Today, I really saw the best movie ever”. And after a few months, you forget the whole thing. And nobody notices because no-one was reading, because, quite frankly, who gives a damn who you’ve met or what do you go to see in the local cinema?

Of course, there’re some great blogs on the Internet. To me, what makes a blog interesting is that it concentrates on quite narrowed set of topics, it is updated frequently, and that the author is an expert in the field she or he is writing about. For instance, Bruce Schneier’s blog is an excellet source of insight.

But blog posts by not-so-famous-and-interesting-people can be good source of technical information. Nowadays, when you google around information on some technical problem, you’ll most likely find that someone has blogged about it. And that’s great.

I’m not not-so-famous-and-interesting-person and I don’t want to be trendy and tell the world about the great restaurant I visited yesterday. But I often solve technical problems on my own that other people might find userful. So why not setup a space where to document these things. That would make a nice back reference for myself, too.

Since I’m not planning to post anything on regular basis, I don’t want to call this thing a blog. So it’s called blah instead.

Posted Mon Jan 25 04:28:12 2010