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

AphoticD

macrumors 68020
Original poster
Feb 17, 2017
2,287
3,475
Preface

Firstly, props to @LightBulbFun for an earlier thread "PowerMac G5 running Linux with a PowerPC virtual machine" which was inspiration to tackle MOL KVM and as stated in that thread, any record "On paper so to speak" is useful as there aren't a great deal of resources for this topic.


An introduction to Mac-On-Linux (MOL)

Mac-On-Linux is an emulator / virtualising solution for PowerPC to run Mac OS (X) atop a Linux PPC installation. The software has been around for decades. Back in about 1999 - 2000 I can recall setting up and operating Mac OS 8.6 (my favoured version of Mac OS at the time) on an underpowered Power Macintosh 7220/200 (603ev) with 160MB EDO RAM, which was a learning platform for me to run various flavours of Linux. I recall Debian, Yellow Dog and Slackware were the go to distros for PPC at the time. During this period MOL development was active and early OS X support was well underway.

Although the software had mostly laid dormant throughout the past decade (official OS X guest supported ended at 10.3 Panther), there has been more recent development with added support for Tiger and KVM (Kernel-based Virtual Machine) on Linux ppc / ppc64. KVM essentially means that the VM guest can access the CPU hardware directly. My understanding is that in KVM "mode", an entire CPU (or thread) is allocated to the task of virtualising the assigned virtual machine.

The result of KVM is much improved (near native) speed on the same hardware. QEMU KVM is currently serving great results for various platforms (including Linux PPC), however MOL appears to have the edge on performance and as we know on these old machines, every speed improvement counts.

So after following the advice in the aforementioned thread and successfully getting QEMU KVM to install Tiger, I wanted to attempt to get MOL KVM working (as best as possible).

It's important to note that before starting, I had installed both Tiger (10.4.11) and Leopard (10.5.8) natively on this machine on separate partitions and then repartitioned to add the Ubuntu Mate partitions in a "Triple boot" setup.

In my prior attempts to get MOL working on a different G5 (Dual 1.8Ghz 2003), I found I had trouble with the Tiger installation DVD (and various formats of ISOs/rips) randomly failing during installation onto an image file, even though they all successfully passed the "Checking Installation Media" stage. Panther installed successfully in MOL from installation ISOs but I wanted Tiger on this G5. So, I went back and split up my Leopard partition with a 10GB partition for Tiger and installed Mac OS X 10.4 the old fashioned way (via DVD) and then updated to 10.4.11 and applied all the software updates.


Compiling Mac-On-Linux / MOL KVM

Platform
: Ubuntu Mate 16.04.2 ppc64
Hardware: Power Mac G5 Dual Core 2.3Ghz (Late 2005), 16GB RAM, Quadro FX4500 (512MB) PCIe

Install dependencies.

$ sudo apt-get install build-essential autoconf subversion zlibc zlib1g-dev libncurses-dev flex bison libx11-dev libxext-dev

For reference, this installation is of ubuntu-mate-16.04.1-desktop-powerpc.iso with all the current software updates to bring it to 16.04.2. In addition and prior to playing with MOL, I had manually added the following packages for my own interest. Although not directly associated, any of these packages may have carried other dependencies which could be required;

$ sudo apt-get install samba synergy ssh tasksel gparted ffmpeg mplayer gpac qemu-kvm openbios-ppc

Download and compile MOL (KVM) from source:

$ svn checkout svn://svn.code.sf.net/p/mac-on-linux/code/trunk mac-on-linux-code

$ cd mac-on-linux-code
$ export CFLAGS="-m32"
<-- this is required to build 32 bit binaries on a ppc64 system
$ ./autogen.sh
$ make


Enable these items in the menuconfig;
> Machine Specific Build Targets > Virtualization type > (X) KVM kernel module
> Network drivers > [X] TUN driver

(Save/Exit to continue compiling)

Once compiling has completed (approx 2 mins on my system).

$ sudo make install


CONFIGURE MACHINE OPTIONS
- increase RAM, disable Altivec and boot from an existing Tiger partition.

$ sudo vi /etc/mol/molrc.osx

Change values:
ram_size: 512 (or greater)
disable_altivec: yes

---- edit 'blkdev:' options ----

comment out /dev/cdrom line to disable access to the optical drive
#blkdev: /dev/cdrom -cd ${cdboot}
--
Enable booting off an existing Tiger partition (-rw -boot). Edit, remove or comment out any lines that don't apply to your system.
--
ifempty ${altconfig} {
# default configuration
blkdev: /dev/sda6 -rw -boot #Tiger
blkdev: /dev/sda3 -rw #Leopard
} else {
# alternate configuration
#blkdev: /tmp/osx.image -rw
#blkdev: /dev/loop0 -rw
}

--
autoprobe_scsi: no
--
enable_usb: no

Save/Write and exit (':wq')


CONFIGURE SOUND
- Disable All - I couldn't get either alsa or oss to work, so "nosound" is set to bypass and reduce conflicts/instability.

$ sudo vi /etc/mol/molrc.sound
--
sound.driver: nosound
startboing.enabled: no

--
Save/Write and exit (':wq')


CONFIGURE VIDEO
-- set base resolution and disable console video.

$ sudo vi /etc/mol/molrc.video

Edit resolution line, change to:
resolution: 1024/768/60 # width/height/Hz

Disable console video (I couldn't get this to work either)

enable_console_video: no

Save/Write and exit (':wq')


CONFIGURE NETWORKING
-- MOL will share the network with the guest via NAT and DHCP.

Edit the MOL tunconfig script to specify a DNS to use:
$ sudo vi /etc/mol/tunconfig

Uncomment the NAMESERVER line and enter a valid DNS address. In my case I entered the local IP address of my xDSL modem.

NAMESERVER=10.1.1.1 <-- change to a valid nameserver IP address.

Scroll down to to the end of the file and then below the lines;

"if [ "$IFACES" ] ; then
echo 1 > /proc/sys/net/ipv4/ip_forward"


Copy and paste;

$IPTABLES -t nat -A POSTROUTING -j MASQUERADE

Save/Write and exit (':wq')

The "tunconfig" script will execute when MOL is started. You can view the table while running MOL with the command sudo iptables -t nat -L . You'll find that MOL/tunconfig will attempt to tidy up by flushing the "nat" table after exiting.


Next is to modify MOL's DHCP config file to remove DNS confusion.

$ sudo vi /etc/mol/dhcpd-mol.conf

Scroll down to the subnet 192.168.41.0 section and comment out the next line;

#option domain-name-servers 192.168.41.1;

Save/Write and exit (':wq')


FIRST BOOT
We are now ready to boot Tiger in Mac-On-Linux !

$ sudo startmol -X


On the initial run, MOL will spit out a timebase_frequency value.
Copy the "timebase_frequency:" output (such as "timebase_frequency: 0x01FCA554"), then add to the sessions.map as instructed;

$ sudo vi /etc/mol/sessions.map

Paste the line in near the top of the file.

Save/write and exit (':wq')


Once the guest system boots, the MOL drivers will appear on the desktop as a disk image, run the installer and reboot/shutdown then run again with;

$ sudo startmol -X


I found that using FTP to transfer files in and out of the system via guest and host works. Enable FTP Sharing in Mac OS X via System Preferences > Sharing and then access from the host side;

$ sftp 192.168.41.2

You can then get and put files to transfer. Of course you could always use scp .

It may be possible to mount your host's SMB shares in the guest, but I couldn't get this to work - it just hangs when trying to connect to smb://192.168.41.1 from within the guest.

While the old version of Safari works, I couldn't get TenFourFox to start up. Realising that TFF builds are CPU specific, I tried downloading the G3 edition and bumped the system memory up to 1GB, but still no luck.

In further research I found there is a TenFourKit version of Webkit for Tiger, but all the links seem to be dead. I'll keep hunting for this as it could make Safari more usable.

Good luck and post your screenshots!

-AphoticD

image1.png
 
Last edited:
I believe that you can only bridge Ethernet Networking with a TAP device not TUN.

This briefly explains TUN/TAP on QEMU which looks like the basis of MOL.

https://qemu.weilnetz.de/doc/qemu-doc.html#pcsys_005fnetwork

I bridged mine on OS X as described here :

https://forums.macrumors.com/threads/qemu-on-os-x-10-5-running-linux-guest-with-networking.1974866/

But it looks like you already have your network bridged since you can access Tiger from your Linux host ?

Thanks Lastic, your post helped get further onto the right path. It's now working perfectly in a nat/masquerade setup without using the proxy service. I have updated the CONFIGURE NETWORKING section and removed any mention of tinyproxy.

It is safe to apt-get remove tinyproxy and remove the Proxy settings from within the guest Mac OS X System Preferences if anybody had tried this method.

Still I would find the ultimate setup would be "Bridged" as in the VM is virtually on the same subnet as other LAN devices. But this config still eludes me.

Cheers,
AphoticD
 
Thanks Lastic, your post helped get further onto the right path. It's now working perfectly in a nat/masquerade setup without using the proxy service. I have updated the CONFIGURE NETWORKING section and removed any mention of tinyproxy.

It is safe to apt-get remove tinyproxy and remove the Proxy settings from within the guest Mac OS X System Preferences if anybody had tried this method.

Still I would find the ultimate setup would be "Bridged" as in the VM is virtually on the same subnet as other LAN devices. But this config still eludes me.

Cheers,
AphoticD

Currently at work so I can't troubleshoot further but could you give me your networking configuration on MOL and
your ifconfig on Ubuntu since it's not clear to me how you have currently setup your network.

I think you'll have to add your tun device to your eth device using brctl ?
 
very cool to see this guide :) its much better then my write up thats for sure heh. I wonder if the G5s support anything like VT-D it would be nice to pass through a dedicated GPU to the VM (something like a Radeon 9200 etc) tho I suspect that would require QEMU. also wondering if MOL can Boot OS9 in KVM mode Last i checked QEMU had issues doing so (but worked fine in emulator mode)
 
Any chance we could get a tutorial on how to get MOL working with KVM on the G4 with Mate 16.04?

I've already tried these build instructions and built a kernel with KVM support, and MOL boots but hangs just after it finds the mach_kernel on the disk or cd. It just sits there and the kernel never loads.

I built MOL with the debugger enabled, but I don't know the commands for the interactive debugger, anyone know how to use it?

I don't think it's a problem with kvm, dmesg | grep kvm* returns no errors, nomally when qemu kvm hangs we'll see Emulation failed xxxxxxx from grep kvm in dmesg.
 
Any chance we could get a tutorial on how to get MOL working with KVM on the G4 with Mate 16.04?

I've already tried these build instructions and built a kernel with KVM support, and MOL boots but hangs just after it finds the mach_kernel on the disk or cd. It just sits there and the kernel never loads.

I built MOL with the debugger enabled, but I don't know the commands for the interactive debugger, anyone know how to use it?

I don't think it's a problem with kvm, dmesg | grep kvm* returns no errors, nomally when qemu kvm hangs we'll see Emulation failed xxxxxxx from grep kvm in dmesg.

A distant memory popped up to tell me there was an issue with kvm on the G4’s when smp was enabled. If it’s a single processor, try disabling smp and rebuild the kernel... maybe?
 
  • Like
Reactions: LightBulbFun
yeah I recall that being an issue as well

but on that note if your using MOL on a G3/G4 I dont think it needs KVM to work, it can use its own thing :)
 
  • Like
Reactions: AphoticD
A distant memory popped up to tell me there was an issue with kvm on the G4’s when smp was enabled. If it’s a single processor, try disabling smp and rebuild the kernel... maybe?
You can't build the KVM module with SMP enabled on arch ppc32.

I found a .deb package someone built over at Amiga world, and that worked with KVM on the G4, so I know at least circa 2014 the MOL code with KVM could work on the G4. I'll be trying some more builds to see how things go.......

The old MOL module never got upstreamed, so I doubt it works with later kernels, and I like to run the latest stable kernel.
 
  • Like
Reactions: AphoticD
Anyone try a build on Debian 10 32bit PPC?

I'm having an issue, not sure what's causing it, I already had to remove the new version of flex and install flex-old, but now I'm getting this error and I don't know how to fix it:

Bash:
make
+ Entering scripts
+ Entering src
+ Entering lib
+ Entering main
+ Entering linux
    Compiling    misc.o           
In file included from misc.c:25:
../misc.h:22:67: warning: ‘struct ucontext’ declared inside parameter list will not be visible outside of this definition or declaration
extern void signal_handler( int sig_num, siginfo_t *sinfo, struct ucontext *puc, ulong rt_sf );
                                                                   ^~~~~~~~
misc.c:71:55: warning: ‘struct ucontext’ declared inside parameter list will not be visible outside of this definition or declaration
signal_handler( int sig_num, siginfo_t *sinfo, struct ucontext *puc, ulong rt_sf )
                                                       ^~~~~~~~
misc.c:71:1: error: conflicting types for ‘signal_handler’
signal_handler( int sig_num, siginfo_t *sinfo, struct ucontext *puc, ulong rt_sf )
^~~~~~~~~~~~~~
In file included from misc.c:25:
../misc.h:22:13: note: previous declaration of ‘signal_handler’ was here
extern void signal_handler( int sig_num, siginfo_t *sinfo, struct ucontext *puc, ulong rt_sf );
             ^~~~~~~~~~~~~~
misc.c: In function ‘signal_handler’:
misc.c:58:26: error: dereferencing pointer to incomplete type ‘struct ucontext’
#define get_nip(puc) (puc->uc_mcontext.regs->nip)
                          ^~
misc.c:92:14: note: in expansion of macro ‘get_nip’
   backtrace( get_nip(puc) );
              ^~~~~~~
make[3]: *** [../../../config/Rules.make:97: ../../../obj-ppc/build/src/main/linux/misc.o] Error 1
make[2]: *** [../../config/Rules.make:76: sub-linux-all] Error 2
make[1]: *** [../config/Rules.make:76: sub-main-all] Error 2
make: *** [config/Rules.make:76: sub-src-all] Error 2



Likely, again, a new version of one of MOL's dependancies, but I don't know which one is conflicting with the two definitions of signal_handler?
 
try adding this to the top of src/main/linux/misc.h:
#include <ucontext.h>

I don't have linux on my eMac G4 yet but do want to try MOL out after I get Debian 10 or 11 running.

Which source tree are you using & how many tweaks have you had to make @DearthnVader ?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.