HFSFromScratch

From code/src wiki
Jump to navigationJump to search

Goal: To install Macintosh System 7.5.3 from scratch using only 1 SCSI2SD and a Linux PC with an SD card reader.

  • The Mac cannot be booted using a floppy disk, or any other disk

Step 1: Create the HFS filesystem image

Install your Mac OS (System 6 or 7) using an emulator. This is by far the easiest way to get started! Be sure to create the emulated disk a little smaller than the SD card you'll be using. eg. for a 2GB SD card create a 1.9GB disk image.

The following emulators have been tested to produce usable HFS disk images:


Step 2: Prepend an Apple Partition Map to the image

We'll use hfdisk to create the partition table. We want to end up with the following partition layout:

type name Starting Sector # of sectors Description
Apple_partition_map Part Map 1 63 Partition table
Apple_Driver Driver_Partition 64 32 SCSIManager driver, normally provided by Apple Drive Setup
Apple_HFS Mac Volume 96 ... Installed OS from emulator.

Determine how many sectors your emulated disk image.

Sectors = (size of emulated HFS disk image) / 512.

The partition map and driver partition require 96 sectors. Create an empty file that is 96 sectors larger than the emulated disk image. In the following example, the emulated disk image is 1887436800 bytes, which is 3686400 sectors.

$ dd if=/dev/zero of=disk.img bs=512 count=3686496

Use hfdisk to create the partition layout:

$ ./hfdisk disk.img
Command (? for help): i
Device block size [3686496]: 
new size of 'device' is 3686496 blocks

Command (? for help): C
First block [64]: 
Length (in blocks, kB (k), MB (M) or GB (G)) [3686432]: 32
Name of partition: Driver_Partition
Type of partition (L for known types): Apple_Driver

Command (? for help): C
First block [96]: 
Length (in blocks, kB (k), MB (M) or GB (G)) [3686400]: 
Name of partition: Mac_Volume
Type of partition (L for known types): Apple_HFS

Command (? for help): p
disk.img
        #                    type name                length   base    ( size )  system
disk.img1     Apple_partition_map Apple                   63 @ 1       ( 31.5k)  Partition map
disk.img2            Apple_Driver Apple_Driver            32 @ 64      ( 16.0k)  Driver
disk.img3               Apple_HFS Apple_HFS          3686400 @ 96      (  1.8G)  HFS

Block size=512, Number of Blocks=3686496
DeviceType=0x0, DeviceId=0x0
Drivers-
1: @ 64 for 32, type=0x1

Command (? for help): w
IMPORTANT: You are about to write a changed partition map to disk. 
For any partition you changed the start or size of, writing out 
the map causes all data on that partition to be LOST FOREVER. 
Make sure you have a backup of any data on such partitions you 
want to keep before answering 'yes' to the question below! 

Write partition map? [N/y]: y
The partition map has been saved successfully!


Partition map written to disk. If any partitions on this disk 
were still in use by the system (see messages above), you will need 
to reboot in order to utilize the new partition map.

Command (? for help): q

Step 3: Copy a SCSI driver partition

I've found that lido driver partitions are the most portable.

$ dd if=lido.img of=disk.img seek=64 bs=512

Step 4: Copy the emulator HFS filesystem

Copy the image file created by the emulator into the disk image.

$ dd if=emulator_disk.img of=disk.img seek=96 bs=512

Step 5: Boot your Mac!

Write the disk image to an sd card, then put the SD card in the SCSI2SD and boot the Mac:

$ sudo dd if=disk.img of=/dev/sdX
$ sudo sync