Skip to content

vasi/hfswrap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hfswrap

Boot ArchPower from a disk image on an HFS+ partition.

This is useful if you don't want to repartition your PowerPC Mac's drive, but still want to be able to run Linux.

Usage

You will need a fair amount of comfort with command-lines. This is Arch Linux, after all!

These instructions are rather manual, and require typing long boot instructions at a Grub console. Consider some steps which may make things easier, which you may want to read before starting these steps.

Initial setup

  • Make sure you're not using journaled HFS+. If you're running Mac OS X 10.3 or later, you'll probably need to disable journaling with diskutil disableJournal /.
  • Find some way to get data onto your Mac OS 9 or Mac OS X system. A good option is connecting to a network share using Netatalk. But you could also use scp, or USB/Firewire drives, or HTTP.
  • Create a place for your Linux data to live. On my drive, it's /arch. In all the steps below, you may need to modify commands to use your chosen path instead.
  • Put some initial data there:
    • A standalone Grub PowerPC binary, as a bootloader. One is included in this repo. You can also build your own Grub, but if your Mac operating system is pre-Mac-OS-X, you'll need a Grub that includes this patch that fixes reading HFS+ files.
    • An ArchPower install ISO.
  • Find out the label of the ISO. There's several ways to find this. On a Unix, run file archpower-current-powerpc.iso and it will display a label like ARCH_202509. On Mac OS 9, mount the ISO with Toast, and it will display the label as the volume name.

Booting the installer

  • Reboot your Mac. Hold down Command-Option-O-F to enter Open Firmware.

  • Find your Mac OS partition. Run dir hd:1,\, then dir hd:2,\, and continue until you get a list of files that corresponds to the partition you want to use. In my case, it's partition 9. In all the steps below, you may need to modify commands to use your partition number instead.

  • Boot from Grub, eg: boot hd:9,arch\grub. The rest of the steps here will take place on the Grub command line.

  • Make sure Grub can read your HFS+ partition by loading the right modules: insmod part_apple; insmod hfsplus.

  • Find your Mac partition in Grub. If it's partition 9, you should be able to run ls (ieee1275/hd,apple9)/ to see a list of files.

  • Setup a Grub loopback device for the ISO. Eg: loopback loop (ieee1275/hd,apple9/arch/archpower-current-powerpc.iso

  • Load Linux from the loopback. You'll use a command with several components:

    • The Linux image itself: linux (loop)/arch/boot/ppc/vmlinuz-linux
    • The extra modules required: earlymodules=loop,hfsplus
    • The location of your image, eg: img_dev=/dev/sda9 img_loop=arch/archpower-current-powerpc.iso
    • Identifiers of the ISO, which will depend on the label you found earlier. Eg: archisobasedir=arch archisolabel=ARCH_202509.

    Putting it all together, that's: linux (loop)/arch/boot/ppc/vmlinuz-linux earlymodules=loop,hfsplus img_dev=/dev/sda9 img_loop=arch/archpower-current-powerpc.iso archisobasedir=arch archisolabel=ARCH_202509.

  • Load the initrd: initrd (loop)/arch/boot/ppc/initramfs-linux.img

  • Boot with boot. It may take awhile, so be patient.

Installing

  • Once booted, you'll be at a root shell.
  • Start the Arch installation guide from after the boot the live environment stage: Setting up Internet, the clock, etc. Stop when you get to the partitioning step.
  • Mount your HFS+ partition, eg: mkdir /hfs; mount /dev/sda9 /hfs
  • Now you'll need an image to hold your ArchPower root. You won't be able to shrink or expand this easily, so be careful with the size you choose. Create the image with dd, eg: for an 8 GB image: dd if=/dev/zero of=/hfs/arch/arch.img bs=1M count=8192 status=progress.
  • Create a filesystem on your image, eg: mkfs.ext4 -L archhfs /hfs/arch/arch.img. Here archhfs is the filesystem label, you can choose any label you want.
  • Mount your root partition to /mnt, eg: mount /hfs/arch/arch.img /mnt
  • Continue the installation guide, stopping at the fstab step. Don't use genfstab, just create a line in /etc/fstab like LABEL=archhfs / ext4 defaults 1 1.
  • Continue the guide until the bootloader step. There's already a bootloader, so there's no need to install one.
  • Before rebooting, you'll need to setup a custom initrd hook to enable booting from an image on HFS+. Copy the contents of this repo's initcpio directory to /etc/initcpio/. You should now have files like /etc/initcpio/hooks/hfswrap, etc.
  • Edit /etc/mkinitcpio.conf to add hfswrap to the HOOKS=(...) list. After the existing autodetect entry is a good place for it.
  • WARNING: These initrd scripts will likely not work if you enable the hooks systemd or shutdown. Make sure neither of those are enabled, and save your mkinitcpio.conf.
  • Rebuild your initrds to include the new hook: mkinitcpio -P.
  • Now you can reboot!

Booting the installed system

  • Get back to Grub, the same way you did before, and again insmod part_apple and insmod hfsplus.

  • Setup loopback, but this time for your Arch root image: loopback loop (ieee1275/hd,apple9)/arch/arch.img.

  • Load Linux from the loopback. There are different required arguments this time:

    • The Linux image itself: linux (loop)/boot/vmlinuz-linux
    • The root specifier: root=LABEL=archhfs rw
    • Parameters to identify the image on HFS+: hfswrap_dev=/dev/sda9 hfswrap_path=arch/arch.img

    Putting it all together, that's: linux (loop)/boot/vmlinuz-linux root=LABEL=archhfs hfswrap_dev=/dev/sda9 hfswrap_path=arch/arch.img

  • Load the initrd: initrd (loop)/boot/initramfs-linux.img.

  • Boot with boot. After a minute or so, you'll be booted into ArchPower!

  • Your HFS+ wrapper partition will be visible mounted at /run/hfswrap/fs. Don't mount it anywhere else while running Arch, it's dangerous to double-mount a filesystem.

Optional ways to make the process easier

That's a lot of steps, and some may be hard to remember at a console. There's a few ways to enhance your experience:

  • Consider using a first-stage bootloader, instead of Open Firmware. I use ofchooser, here's an example config file for a setup like mine. You probably want to make your first-stage bootloader the default boot-device.
  • Rather than typing lots of complex Grub commands, consider creating a grub.cfg file on your HFS+ partition. Here's an example grub.cfg that I use for both booting the installer, and booting the installed ArchPower. If you're at the Grub command-line, you can load up your grub.cfg with a command like configfile (ieee1275/hd,apple9)/arch/grub.cfg.
  • Even typing the configfile command is annoying! You can build your own Grub that includes an embedded grub.cfg, like this example, which in turn auto-loads your grub.cfg from HFS+. Just run grub-mkstandalone -O powerpc-ieee1275 --locales= --themes= --fonts= -o grub /boot/grub/grub.cfg=grub-embedded.cfg, and replace the Grub from this repo with your new grub binary.
  • Copying complex commands into the Arch install environment is error-prone. Consider enabling SSH in the installer so you can SSH in from another computer, and copy/paste commands.
  • It can be hard to see important log messages from early boot, if anything goes wrong. Consider setting rd.log=all in your kernel parameters, so that early initrd logs end up in the systemd journal and dmesg.
    • Also, the kernel may attempt to switch to a framebuffer very early on, which can make the screen go black during part of early boot. Consider enabling your framebuffer module in the MODULES=(...) section in mkinitcpio.conf, so you get your console back quickly. Eg: MODULES=(aty128fb) on my machine. You can figure out which framebuffer module you need by running lsmod | grep fb once booted.
  • Booting with a flag like hfswrap_dev=/dev/sda9 is a bit dangerous if you ever connect other disks, since you can't be sure which one will become sda. Consider running blkid /dev/sda9, and picking one of the values it reports for identifying your wrapper. For example, hfswrap_dev=LABEL=MacHD.
  • If you need swap, it's probably better to put it on the HFS+ wrapper than on your embedded image. Create a swap file with dd, initialize it as swap with mkswap, and then add it to your fstab under /run/hfswrap/fs/. Here's an example fstab.

What if something doesn't work?

  • Make sure you're running with the kernel param rd.log=all and a framebuffer, so you can see any logs. See above for more details.
  • Try booting with hfswrap disabled, by adding the kernel param disablehooks=hfswrap. This will likely drop you into a rescue console, where you can try manually mounting your HFS+ partition to /run/hfswrap/fs, and then loop-mounting your image to /new_root.
  • If you get stuck, you can always boot from the installer, mount your image file, and then arch-chroot into it. This gives you the opportunity to edit any initrd hooks, change your fstab, etc.

License

(C) 2025 Dave Vasilevsky Licensed under the GNU GPL 2.0

About

Boot PowerPC Arch without repartitioning your Mac

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages