Basilisk II, SheepShaver & AppleTalk on Ubuntu (QEMU/KVM)

Basilisk II, SheepShaver & AppleTalk on Ubuntu (QEMU/KVM)

Status: 12 September 2020 - Tested and have completed doing two "large" physical disk dumps to Virtual Mac using "sheep_net" kernel module.


Basilisk II & SheepShaver are emulations for Motorola 68000 series and PowerPC series Apple Macintoshes. For retro-computing enthausiants they bring a virtualised retro computing experience. Both can be run on a number of platforms including: Windows, MacOS, FreeBSD, IRIX and Linux.  Here are tips on getting these running and trouble shooting their use on Ubuntu Linux.

I did this as I needed to set up an AppleTalk gateway to easily move files to/from a real M68000 series Mac.  Another way to achieve this is using netatalk, which is AppleTalk equivalent to Samba for SMB/CIFS.


Setting up Basilisk II

Ubuntu has a prebuilt Basilisk II package available that can be install as standard apt install package:

# sudo apt install basilisk2

---
--- NOTE: You may also need to install: libcanberra-gtk
---

# sudo apt install libcanberra-gtk-module libcanberra-gtk3-module

I have tested the following:

  • Ubuntu 20.04 - Does not work (segmenation fault on startup)
  • Ubuntu 18.04 - only "nojit" works
  • Ubuntu 16.04 - both "jit" and "nojit" work.  Through I was unable to find how to get equivalent of "Command" & "Alt/Option" keys working and there appears to be problem with disk emulation layer as "Apple HD SC Setup" is not able to detect disks.

With the Ubuntu 20.04 installation a Gnome Desktop icon is created and you can start Basilisk II emulator by double clicking the icon. For 16.04 & 18.04 open a terminal window and start by running: BasiliskII (default), BasiliskII-jit or BasiliskII-nojit which allows control of the "Just In Time" (JIT) compiler.


Setting up SheepShaver

There is no Ubuntu Sheep Shaver pre-built package so getting SheepShaver up and running requires a build from source. This requires:

  1. Install build tools
  2. Clone the git repository - "git clone https://github.com/cebix/macemu.git"
  3. Build and Test - "cd macemu/SheepShaver/src/Unix",
  4. Install

Given issues with Basilisk II on Ubuntu 18.04 & 20.04 I opted to do build on Ubuntu 16.04.

The build tools required are:  build-essential autoconf git libgtk2.0-dev x11proto-xf86dga-dev libesd0-dev libxxf86dga-dev libxxf86dga1 [optionally: libsdl1.2-dev or libsdl2-dev]

To build follow the following steps:

---
--- 1. Get Tools
---

# sudo apt install git build-essential automake libgtk2.0-dev x11proto-xf86dga-dev libesd0-dev libxxf86dga-dev libxxf86dga1

---
---  NOTE: not including libsdl1.2-dev/libsdl2-dev as these fail

---
--- 2. Clone Repository
---

# git clone https://github.com/cebix/macemu.git

---
--- 3. Make links
---

# cd macemu/SheepShaver
# make links

---
--- 4. Build
---

# cd src/Unix
# NO_CONFIGURE=1 ./autogen.sh
# ./configure

---
--- NOTE: Do default configure, I attempted build with SDL but this
---         results in undefined functions due to changes in
---         shared Basilisk II SDL code that have not been updated
---         to work correctly with SheepShaver
--- The following where tested:
--- ./configure --enable-sdl-video --enable-sdl-audio --disable-vosf
---      fails to build as not picking up the video functions in
---      macemu/BasiliskII/src/SDL/video-sdl.cpp
--- ./configure --enable-sdl-audio --disable-vosf
---      builds but you end up with "yellow sheep" video, apparently
---      related to an "endian" issue
--- ./configure --enable-sdl-video --enable-sdl-audio --with-sdl2 --disable vosf
---       --with-sdl2 flag is recognised with Basilisk II build but
---       not SheepShaver and fails with compile errors
---

---
--- 5. Test
---
# ./SheepShaver

---
--- Works but slow performance
---

Using sheep_net on Linux

If you want your Macintosh to be able to expose itself as an AppleTalk file server, then the default slirp network will not work. Slirp acts like a NAT firewall, which means it blocks all incoming requests.  This is where "sheep_net" comes in.

"sheep_net" relies on a kernel module which lets the emulator get access to the network interface, avoiding having a NAT layer in place. This means the emulator can now use AppleTalk and TCP/IP protocols and you can do things like set up your emulator to act as a CIF or NFS to Apple File Protocol (AFP) over AppleTalk gateway.

Why would this be helpful ? Well if you have some actual real vintage Mac's then then it is useful to be able to get files on and off them and preserve your collection of vintage applications.  You can also achieve the same thing with netatalk (v2), but this involves more configuration than using the emulator.

The original AppleTalk provided a very simple and easy to manage network that was perfect for small office environments back in its day.

So here the how...

  1. Install git on you Ubuntu host machine
  2. Clone the macemu git repository
  3. cd down into: ./macemu/src/BasiliskII/Unix/Linux/NetDriver
  4. Build & install the klm by doing: make install
  5. Load the klm: modprobe sheep_net
  6. Change the owner of /dev/sheet_net node to avoid permission problem or having to run Basilisk II as root: sudo chown <USER> /dev/sheet_net
  7. Start up Basilisk II GUI and change the networking to have the name of the network link (not the device) such as: enp0s1
  8. Start the machine and configure AppleTalk to use the ethernet interface and configure the TCP/IP  with either DHCP or statically defined address, gateway and DNS resolution details.
  9. You should now beable to use "Chooser" to connect to other LocalTalk Macs on your network

NOTE: The Ubuntu install also puts the sheep_net code in directory: /usr/shared/doc/basilisk2/example/NetDriver but this version is relatively old and one on macemu git repository has a number of fixes.


Mounting and Cleanup up HFS Disk Images

To boot your emulated Macintosh you will need a ROM dump and a bootable HFS disk image. The disk images are very suspect to failure, so if your emulation crashes or you have to kill it because it hangs, then it is likely not to be bootable at next startup.  To repair the HFS image you will need to mount it as raw block device and then do a file system check on this.

The tools to use are:

  • hfsprogs - apt package with support for HFS/HFS+ disk
  • losetup - provides loop setup function to create new /dev/loopX device
  • fsck.hf - part of hfs-utils, provide tools to check the /dev/loopX device file system
  • mount - with -t hfs -o loop options to allow you to mount and verify the HFS image

Here is sample session, showing how to mount image and do a file system check:

---
--- Use losetup (loop setup) to mount HFS image
---

$ sudo losetup -f -P MacOS-75.dmg

---
--- Use losetup to find the loop device image was mounted on...
---

$ sudo losetup -l
NAME SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE                                    DIO LOG-SEC
/dev/loop1
             0      0         1  1 /var/lib/snapd/snaps/gnome-logs_100.snap       0     512
/dev/loop8
             0      0         1  1 /var/lib/snapd/snaps/gnome-characters_550.snap
                                                                                  0     512
/dev/loop6
             0      0         1  1 /var/lib/snapd/snaps/gnome-3-26-1604_100.snap
                                                                                  0     512
/dev/loop4
             0      0         1  1 /var/lib/snapd/snaps/gnome-3-34-1804_36.snap   0     512
/dev/loop2
             0      0         1  1 /var/lib/snapd/snaps/core18_1885.snap          0     512
/dev/loop0
             0      0         1  1 /var/lib/snapd/snaps/gnome-system-monitor_148.snap
                                                                                  0     512
/dev/loop9
             0      0         0  0 /home/USER/MacOS-75.dmg
                                                                                  0     512
/dev/loop7
             0      0         1  1 /var/lib/snapd/snaps/gnome-calculator_748.snap
                                                                                  0     512
/dev/loop5
             0      0         1  1 /var/lib/snapd/snaps/core_9804.snap            0     512
/dev/loop3
             0      0         1  1 /var/lib/snapd/snaps/gtk-common-themes_1506.snap
                                                                                  0     512

---
--- Image is on /dev/loop9 so can now to file system check
---

$ sudo fsck.hfs -f /dev/loop9
[sudo] password for USER: 
** /dev/loop9
** Checking HFS volume.
Segmentation fault

---
--- Oops Segmentation fault.... on dirty disk...
---    Lets mount it and see contents
---

$ sudo mount -t hfs /dev/loop9 HFS
$ ls HFS
'About System 7.5'   Desktop          'DesktopPrinters DB'            'System Folder'
'Apple Extras'      'Desktop DB'      ''$'\003\002\001''Move&Rename'   Trash
'AppleShare PDS'    'Desktop DF'      'Shutdown Check'                 Users
 Applications       'Desktop Folder'   SimpleText
 
---
--- Ok still readable lets do further check...
---   Need to unmount it first
---

$ sudo umount HFS
$ sudo fsck.hfs -q /dev/loop9
** /dev/loop9
QUICKCHECK ONLY; FILESYSTEM DIRTY
$ sudo fsck.hfs -q -p /dev/loop9
Segmentation fault

---
--- Oops still getting segmentation fault.
---   Best thing at this point is to boot emulator from another disk
---   image and to do a check of the image from within the emulator
---   So lets release the loop9 device
---
$ sudo losetup -d /dev/loop9

NOTE 1: To get hfs/hfs+ support do: "sudo apt install hfsplus hfsprogs"

NOTE 2: Always make sure you have a backup of your HFS image if it is important and always have an alterate boot disk in case you need to do a recovery.


The "ERROR: Not enough free memory."

On MacOS I am able to run my machines with 1024 MB RAM, with both Basilisk II & SheepShaver. With Ubuntu 16.04 Basilisk II the maximum size I am able to run is 512 MB RAM. When I went to next increment in size to 1024 I get failure:

$ BasiliskII-jit 
Basilisk II V1.0 by Christian Bauer et al.
ERROR: Not enough free memory.
Segmentation fault (core dumped)

Current workaround is simply not use more than 512 MB with Basilisk II.

SheepShaver works with 1024 MB.


AppleTalk Gateway using netatalk (on FreeBSD)

Another way to provide an AppleTalk gateway is by using Netatalk. This provides the equivalent of Samba but for Apple Filing Protocol (AFP) and if you use older version (2.x) then it has support for AppleTalk which is needed to work with older Macs. There are some complexities with this as it requires you compile AppleTalk support into the kernel.

To achieve this I swapped over to using FreeBSD VM. FreeBSD had AppleTalk available up until version 10.4. So I downloaded FreeBSD 10.4 AMD64 DVD iso and did install with src code included (to allow kernal recompile).

Steps are:

  1. Get 10.4 AMD 64 ISO
  2. Create new FreeBSD VM and boot from DVD (note that you cannot directly boot a UEFI VM from this DVD), so if you want to use UEFI VM you have to play around by starting boot from existing FreeBSD install and then changing boot device to cd).
  3. Rebuild kernel with updated "option ATATALK" in config (/usr/src/sys/amd64/conf/GENERIC) & reboot
  4. Do pkg install of netatalk (I advise not to do this via ports as the ports tree will point to newer version)
  5. Make sure you have extra NIC on VM just for AppleTalk and do not configure IP address on this NIC
  6. Reboot
  7. Setup you atatalk configuration
  8. Reboot & Test

In summary this is much more work that just using "Basilisk II" emulator with sheep_net to provide your AppleTalk solution.

NOTE: I will provide more detailed notes at once I have completed testing. My assessment is that for most Retro Mac'ing needs this is more complicated than is justified to get simple AppleTalk AFP service going.


And a Screen Snap

A VM each for PowerPC SheepShaver and OS 9 and Motorola M68040 Basilisk II and System Software 7.5.3.

Now by mounting NFS or CIFS network file systems somewhere under the that is selected for the Unix Root file systems then this provide a way gateway between NFS/CIFS storage and old world Macs.

Basilisk II & SheepShaver running with QEMU/KVM VM on Ubuntu

NOTE 1: In general Basilisk II Mac has snappier performance that the Sheep Shaver PowerPC machine.

NOTE 2: Both emulators are running in Ubuntu 16.04 VM guest with sheep_net KLM for AppleTalk on an Ubuntu 20.04 Host.


References & Links:

Basilisk II and SheepShaver - are both managed via same sites and a central repository on github

The emuculation Forums - go to place for information on running the emulators, though be aware that some of the topics are very very old and likely to be out 0f date

Another AppleTalk Adventure -