After some time I decided to write another entry here that some might find useful, especially if they wish to run HP-UX (32bit) guest under Qemu on their Apple M1 hardware.
What is HP-UX ? Well it is one of the UNIX systems that was designed by HP (thus it is called HewlettPackard Unix) and runs on PA-RISC and IA64 CPU architectures. Here we will only focus on the PA-RISC1.1 simulation under Qemu
HP-UX can run under qemu-system-hppa simulator but only the PA-RISC1.1 versions and up to 11.11 Since the latest release of Qemu (from git April 2021)
QEMU emulator version 5.2.92 (v6.0.0-rc2-66-gc1e90def01-dirty)
Copyright (c) 2003-2021 Fabrice Bellard and the QEMU Project developers
The only version of HP-UX that installs and boots is HP-UX 11.11 2005-09-MCOE release, possibly the HP-UX 11.11 2006-12-MCOE (but I have not tested this one) I have tried to install/run on the Apple M1 10.20 and 11.00 and 11.11 from pre 2005 but none of them installed and qemu crashed (this could be an issue with Qemu)
So here we will use the verified HP-UX 11.11 2005-09-MCOE disk images and procedures to get almost full 32bit HP-UX experience on your modern Apple M1 hardware.
Prerequisites
- Working instance of fresh qemu (recent git clone from https://github.com/qemu/qemu)
- XQuartz 2.8.1 for M1 ARM64 (https://www.xquartz.org/releases/index.html)
- Approximately 20 GB of disk space on the Apple M1 SSD
- A lot of patience and time (installation of HP-UX takes time)
- HP-UX 11.11 ISOs
- Telnet client on the M1 MacOS (I compiled one from pkgsrc, or you can use Putty)
Step 1 Preparation
Lets start by setting up the simulation environment on the Apple M1 for the HP-UX 11.11 and dedicate a working directory $HOME/HPPA/HPUX for the qcow2, ISOs and install/loader scripts
We create a 20GB qcow2 disk image to hold the HP-UX system
$ qemu-img create -f qcow2 disk.img 20G
Download the ISOs (there are 4 ISOs to install HP-UX from and all are needed)
wget 'http://tenox.pdp-11.ru/hpux/OS/11.11/2005-09%20MCOE/hp-ux-1of4.iso'
wget 'http://tenox.pdp-11.ru/hpux/OS/11.11/2005-09%20MCOE/hp-ux-2of4.iso'
wget 'http://tenox.pdp-11.ru/hpux/OS/11.11/2005-09%20MCOE/hp-ux-3of4.iso'
wget 'http://tenox.pdp-11.ru/hpux/OS/11.11/2005-09%20MCOE/hp-ux-4of4.iso'
Prepare the install.sh script to load the installation (graphical install )
qemu-system-hppa \
-boot d \
-drive if=scsi,bus=0,index=6,file=disk.img,format=qcow2 \
-m 512 \
-d nochain \
-cdrom hp-ux-1of4.iso \
-net nic,model=tulip \
-net user
Prepare the run.sh script to run the simulation
qemu-system-hppa \
-smp cpus=2 \
-accel tcg,thread=multi \
-boot c \
-drive if=scsi,bus=0,index=6,file=disk.img,format=qcow2 \
-monitor telnet::4441,server,nowait \
-m 512 \
-d nochain \
-cdrom hp-ux-1of4.iso \
-nographic -vga none \
-net nic,model=tulip \
-net user,hostfwd=tcp::2222-:22
Make both the install.sh and run.sh executable (make sure qemu-system-hppa is in your $PATH)
The contents of you $HOME/HPPA/HPUX directory should have these files now
-rw-r--r-- 1 user staff 642865152 Oct 6 2020 hp-ux-1of4.iso
-rw-r--r-- 1 user staff 357793792 Oct 6 2020 hp-ux-2of4.iso
-rw-r--r-- 1 user staff 648380416 Oct 6 2020 hp-ux-3of4.iso
-rw-r--r-- 1 user staff 309100544 Oct 6 2020 hp-ux-4of4.iso
-rw-r--r-- 1 user staff 196928 Apr 20 23:47 disk.img
-rwxr-xr-x 1 user staff 195 Apr 18 20:22 install.sh
-rwxr-xr-x 1 user staff 287 Apr 19 20:17 run.sh
Step 2 Installation
Now run install.sh and after a few moments you should see the installer program. Please note that you can use the TAB and arrow keys to move around the menu.
IMPORTANT – The VGA emulation in HPPA is labelled as artist and you need to use a zoom-to-fit and fullscreen mode to see the whole display if you use MacBook Air M1. However what worked better for me is to keep the artist display windowed and move it slightly to a corner of the desktop, since the installer does not take the whole screen.
The console curses interface text gets corrupted during the installation menu/process so we will not use this since it gets really unreadable later on. The final X11/CDE session does not work properly in the artist (VGA) for me – the mouse cursor cannot move the edge of the right side of the desktop, only to some imaginary wall in the middle. I also found out that the mouse gets erratic if you switch between the host MacOS and the HP-UX VM a lot so be prepared for that. It might be a bug in the current qemu-system-hppa git build) so for the final HP-UX we will use the console curses based loader and connect to CDE via ssh tunnel and Xnest for best experience.
install.sh output (To exit from Full screen Qemu-Artist on Mac press Ctrl+Option+g to get a mouse cursor back, and then Command+f)
Chose the keyboard type 62 and confirm by <ENTER>
Here we will choose the default values (unless you want to setup custom partition layouts, filesystems, etc …) since the defaults are quite safe for the qemu-system-hppa simulation, you can use TAB, arrow keys to navigate in the installer.
Hit Next
Keep hitting Next
Keep hitting Next
Keep hitting Next
Keep hitting Next
Keep hitting Next
Keep hitting Next
Keep hitting Next
Keep hitting Next
And finally hit Finish to begin the actual installation, here we need to return to full screen again since the installer will use the full display.
Now this next process will take approx 1 hour during which swinstall extracts content from CD1
When we finish with the CD1 we need to swap the ISOs
Change to the
The ISO swapping will happen over the QEMU monitor server this can be done
And point to the $HOME/HPPA/HPUX directory and choose the hp-ux-2of4.iso once done hit <ENTER> in the Qemu artist main console window (Please note that we will have to do this for all the 4 CD ISOs so be patient)
The installer will continue with CD2
Go on and finish the installation (with CD2/3 and 4 its much faster than with CD1) .. eventually the installed gets to the part when the kernel gets built
Once all is done system reboots to the next stage install, yet again be patient for the installer to chew through the 2nd stage setup (it takes some time)
IMPORTANT:
Now the next step during the installation seems to look like the whole system is stuck infinitely – CIM Repository is being built – please be patient
Now you have two choices now, first to be patient, second to break this and move on – break in the console by CTRL+c if you dont do this it can take a few hours but it will eventually finish (its up to you – I left it running to finish) There will be a FAIURE message and the system will reboot yet again
Again choose the keyboard type 62
Now the semi-functional X11 will load – it works but is really ugly and leaves artifacts behind – get a grip of a weird mouse movement and interaction (keyboard helps here :)
Try to choose English language option with TAB and <ENTER> mouse interaction seems to be broken
Hit Finish (with TABs and <ENTER>) and close the GEO CUSTOMS window
Next we will setup networking (DHCP)
So answer Yes (remember that arrow keys work here )
And we choose Yes for DHCP (Qemu on Apple M1 can only do -net user network)
Confirm Yes is above looks the same for you
Next we chose a hostname (keep it max 8 characters and simple)
Hit Yes
Next chose your time-zone
Hit Yes
If time is OK hit Yes (you can always change this stuff later)
Next setup your root password
If all went well you should get the above
And finally an important message about the disk space on the LVM keep this in mind (we used a 20GB qcow2 disk image remember ?)
Hooray – we got to the end finally !
So wait for the system to boot up, login as root
And shut down the system
Once the shutdown procedure gets to this stage you can power-off the Qemu VM
Congratulations you made it to the next stage !
Step 3 Running HP-UX
OK, we are now ready to start the HP-UX, remember the loader script run.sh ? We will use that now to load the system.
$ ./run.sh
NOW BE VERY CAREFUL NOT TO HIT CTRL+C in this session, otherwise you will kill the whole Qemu simulator, it is better to connect over SSH to the host once the system comes up and keep this window open just for emergency operations
So now you are ready to do some HP-UX hacking !
POST INSTALL THINGS TO CONSIDER
In order get to the Qemu monitor console which is needed for the ISO swapping and other useful task use telnet (or putty) on the MacOS to connect to localhost 4441 (keep this in mind if you are on a public WiFi network !!!!! and use a Firewall)
First thing after logging to the HP-UX 11.11 I modified the /.profile for root user
export TERM=vt100
export DISPLAY=macos:1
stty erase ^?
The macos is an alias to 10.0.2.2 host that we need to make sure we define for the Xnest to work over SSH
Create the following file on the HP-UX /etc/nsswitch.conf and add
hosts:files [NOTFOUND=continue] nis[NOTFOUND=continue] dns
And then add macos to /etc/hosts
10.0.2.2 macos
You dont want to run everything as root, so create some users. Keep in mind that on HP-UX 11.11 root is allowed to SSH to the machine by default !
SSH login to HP-UX from MacOS
Since MacOS (BigSur) cannot use tun/tap interfaces we are stuck with the -net user networking, so in order to use SSH a Qemu port forwarding has to be used. In the run.sh script we ports forward the HP-UX TCP 22 to MacOS TCP 2222 (change accordingly)
Also keep in mind that this opens up SSH TCP 2222 on your Mac to the rest of the surrounding network so you can login to HP-UX from other systems in the LAN – so keep this in mind if you are in a public network full of evil hax0rs and setup your firewall accordingly
By default SSH is enabled and running on the HP-UX but it is old so one needs to allow for older weaker algos in their SSH client config (On MacOS $home/.ssh/config I have the following)
Host localhost
KexAlgorithms +diffie-hellman-group1-sha1
HostKeyAlgorithms +ssh-dss
This way you can then SSH to the HP-UX Guest from your Mac, but even better is to allow X forwarding so we can use Xnest from XQuartz ! I connect to the HP-UX from the Mac as follows :
ssh -XC -p 2222 user@localhost
Then on the MacOS I run Xnest as follows (save it as a script on your Mac)
/opt/X11/bin/Xnest :1 -listen tcp -ac :1.0
And from the above ssh session on HP-UX run the following (save it as a shell script in your home user directory)
export DISPLAY=macos:1
/usr/dt/bin/Xsession
You should now catch the CDE session on your Mac – this is much more comfortable way of working that with the unstable artist VGA buffer on Qemu
Installing some useful software
I have put together a small collection of useful tools you can download/upload to HP-UX and play around with. These include the GCC compiler , GNU debugger, bash and links web browser
http://45.76.81.249/HPPA/HP-UX-11.11/
gcc-3.4-32-11i-hppa1.1.tar
gdb-6.2.1.tar.gz
Extract in /usr/local
Set $PATH to include new GCC
/usr/local/pa11_32/bin
Once you have GCC and GDB installed you can compile some code (which works out of the box without source modification on the HP-UX 11.11) and I leave this to the reader to exercise on
http://45.76.81.249/HPPA/HP-UX-11.11/Tools/
Shutting down the system
As root got to the / directory and run
# shutdown -h now
When it is safe to power down the simulator either kill -$PID Qemu process or enter monitor console via telnet localhost 4441 and quit
Known Issues:
If the qemu-system-hppa gets stuck during boot, kill the VM either from shell kill -$PID or from telnet monitor console. If by any chance a disk corruption happens then you would need to run fsck upon next successful boot of HP-UX
Xephyr is probably better to use than Xnest – but for me the session dies within a minute and I have not figured out yet why (if you know please let me know)
Xnest display needs updating if screen-saver hits from CDE session (so right-click on the CDE desktop and refresh) and setup a large timeout for screensaver in CDE (2 hours)
Reference:
https://en.wikipedia.org/wiki/HP-UX
https://parisc.wiki.kernel.org/index.php/Qemu#HP-UX_booting_up
http://mirrors.develooper.com/hpux/downloads.html
https://supratim-sanyal.blogspot.com/2019/11/hpux-11i-v1-hpux-1111-pa-risc-guest.html