Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

cellularmitosis

macrumors regular
Original poster
Mar 6, 2010
185
267
I recently read through https://tinkerdifferent.com/threads...ntoo-linux-on-an-ibook-g4-success-story.3339/ and watched
and noticed the install process involves spending more than a day being booted from the livecd.

I instead took the route of minimizing the time spent with the livecd, doing the bare minimum required to have a bootable, ssh-able machine.

I captured it as a script here: http://leopard.sh/linux/gentoo-ppc.sh

To use this, download and burn the latest .iso from https://distfiles.gentoo.org/releases/ppc/autobuilds/current-install-powerpc-minimal/, boot from the .iso, then run:

Code:
wget -O - http://leopard.sh/linux/gentoo-ppc.sh | bash

Note: the above command will wipe your hard drive.

This will partition and format your hard drive, unpack a stage3 tarball, copy the kernel+modules from the live cd, install a bootloader, set the root password to "root", set sshd to start on boot, then reboot.

After the machine reboots, it should get a DHCP lease and you should be able to ssh in as root and perform the rest of the install.
 
  • Like
Reactions: repairedCheese
Including the script here just for reference:

edit: see the updated script in the post which follows this one
 
Last edited:
Note: this script will go "stale", as it looks like the gentoo team only keeps the stage3 tarballs around for about a month, and there is unfortunately no "latest" symlink for the stage3 tarball.

If a future reader runs the script and gets a 404 on https://distfiles.gentoo.org/releas...nrc/stage3-ppc-openrc-20250424T020521Z.tar.xz, just ping me and I'll update the script.

edit: hmm, actually it looks like I could have the script grab https://distfiles.gentoo.org/releas...tage3-ppc-openrc/latest-stage3-ppc-openrc.txt and parse the filename out of it...

edit2: ok, yeah, I was able to determine the filename of the latest tarball with:

Code:
# determine the latest tarball filename
stage3_tarball=$(wget -O - https://distfiles.gentoo.org/releases/ppc/autobuilds/current-stage3-ppc-openrc/latest-stage3-ppc-openrc.txt | grep '\.tar\.' | awk '{print $1}')

so now the script shouldn't go "stale".

updated script:

Code:
#!/bin/bash

# a bare-minimal installer for ppc gentoo.

# instructions:
# - download and burn the latest iso from
#   https://distfiles.gentoo.org/releases/ppc/autobuilds/current-install-powerpc-minimal/
# - boot from the iso, then run this script:
#   wget -O - http://leopard.sh/linux/gentoo-ppc.sh | bash

set -e -o pipefail
set -x

GREEN='\033[1;32m'
WHITE='\033[1;37m'
NC='\033[0m'

{ set +x; } 2>/dev/null
echo -e "\n ${GREEN}* ${WHITE}Setting the time.${NC}\n"
set -x

if which chronyd >/dev/null 2>&1 ; then
    chronyd -q
elif which ntpd >/dev/null 2>&1 ; then
    ntpd -q -g
fi

{ set +x; } 2>/dev/null
echo -e "\n ${GREEN}* ${WHITE}Partitioning the disk.${NC}\n"
set -x

mac-fdisk /dev/sda << EOF
i
y

b
2p
c
3p
3p
root
w
y
EOF
sleep 1

{ set +x; } 2>/dev/null
echo -e "\n ${GREEN}* ${WHITE}Formatting the root partition.${NC}\n"
set -x

umount /dev/sda3 || true
mkfs.ext4 /dev/sda3
mkdir -p /mnt/gentoo
mount /dev/sda3 /mnt/gentoo

{ set +x; } 2>/dev/null
echo -e "\n ${GREEN}* ${WHITE}Installing a stage 3 tarball.${NC}\n"
set -x

# determine the latest tarball filename
stage3_tarball=$(wget -O - https://distfiles.gentoo.org/releases/ppc/autobuilds/current-stage3-ppc-openrc/latest-stage3-ppc-openrc.txt | grep '\.tar\.' | awk '{print $1}')

cd /mnt/gentoo
url=https://distfiles.gentoo.org/releases/ppc/autobuilds/current-stage3-ppc-openrc/$stage3_tarball
wget -O - $url | unxz | tar xp --xattrs-include='*.*' --numeric-owner

{ set +x; } 2>/dev/null
echo -e "\n ${GREEN}* ${WHITE}Setting up the boot partition.${NC}\n"
set -x

hformat -l bootstrap /dev/sda2
mkdir -p /mnt/gentoo/boot/NWBB
mount --types hfs /dev/sda2 /mnt/gentoo/boot/NWBB/
grub-install --boot-directory=/mnt/gentoo/boot --macppc-directory=/mnt/gentoo/boot/NWBB /dev/sda2
umount /mnt/gentoo/boot/NWBB/
hmount /dev/sda2
hattrib -t tbxi -c UNIX :System:Library:CoreServices:BootX
hattrib -b :System:Library:CoreServices
humount

{ set +x; } 2>/dev/null
echo -e "\n ${GREEN}* ${WHITE}Copying kernel + modules from livecd.${NC}\n"
set -x

cd /mnt/cdrom/boot
cp -a ppc32 ppc32.igz System-ppc32.map grub /mnt/gentoo/boot/
mkdir -p /mnt/gentoo/lib/modules
cp -a /lib/modules/6.12.21-gentoo-ppc32-ppc /mnt/gentoo/lib/modules

{ set +x; } 2>/dev/null
echo -e "\n ${GREEN}* ${WHITE}Creating a grub config.${NC}\n"
set -x

cat > /mnt/gentoo/boot/grub/grub.cfg << EOF
set default=0
set gfxpayload=keep
set timeout=3
insmod all_video

menuentry 'ppc32' --class gnu-linux --class os {
    linux /boot/ppc32 root=/dev/sda4 ro
    initrd /boot/ppc32.igz
}
EOF

{ set +x; } 2>/dev/null
echo -e "\n ${GREEN}* ${WHITE}Chrooting.${NC}\n"
set -x

mount --types proc /proc /mnt/gentoo/proc
mount --rbind /sys /mnt/gentoo/sys
mount --make-rslave /mnt/gentoo/sys
mount --rbind /dev /mnt/gentoo/dev
mount --make-rslave /mnt/gentoo/dev
mount --bind /run /mnt/gentoo/run
mount --make-slave /mnt/gentoo/run
chroot /mnt/gentoo /bin/bash << 'ENDCHROOT'
set -e -o pipefail
source /etc/profile
set -x

GREEN='\033[1;32m'
WHITE='\033[1;37m'
NC='\033[0m'

{ set +x; } 2>/dev/null
echo -e "\n ${GREEN}* ${WHITE}Setting the root password to 'root'.${NC}\n"
sleep 3
set -x

passwd << EOF
root
root
EOF

{ set +x; } 2>/dev/null
echo -e "\n ${GREEN}* ${WHITE}Configuring sshd.${NC}\n"
set -x

rc-update add sshd default

cat >> /etc/ssh/sshd_config << EOF
PermitRootLogin yes
EOF

ENDCHROOT

{ set +x; } 2>/dev/null
echo -e "\n ${GREEN}* ${WHITE}Configuring portage.${NC}\n"
set -x

cat >> /mnt/gentoo/etc/portage/make.conf << EOF

FEATURES="buildpkg getbinpkg"
EOF

{ set +x; } 2>/dev/null
echo -e "\n ${GREEN}* ${WHITE}Rebooting.${NC}\n"
set -x

cd /
reboot
 
Last edited:
  • Like
Reactions: repairedCheese
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.