Running HP-UX 11.11 on the Apple M1

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 can be done via Cocoa menu “Machine” section as seen below or in qemu-monitor over <Ctrl+Alt+Shift+2> – there you need to run “info block” to get the CDROM id and change it like this “change scsi0-cd2 /path/to/iso/cd2.iso”

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

About astr0baby

Please run Adblock or similar... we have been told to do so since Carl Sagan wrote the Contact .
This entry was posted in Uncategorized. Bookmark the permalink.

19 Responses to Running HP-UX 11.11 on the Apple M1

  1. Anatoly Sova says:

    Great guide, thank you! Is there a way to reduce CPU usage on the HP-UX VM (by stopping some services, for example)?

  2. Anatoly Sova says:

    New question from me – any chance to run HP-UX 11.31 too?

  3. nb says:

    Nice guide. It’s good to see the RISCs of old run on the RISCs of… new?

    Anyway, to add something of substance: the installer can only handle 1 GB of primary swap. This is a problem if you give the VM more than 1 GB of memory, since it will auto-compute more than 1 GB of swap, and then promptly fail when trying to format the disk. So take care to manually set the swap to 1 GB if it’s over that limit.
    Secondary swap that can be set up from the Advanced Installation is not affected by this, and can be as large as you want.

  4. SchLikA says:

    Thanks for the inspiration, I finally tried to virtualize an old HPUX 10.20 app on qemu … I could dump the original hd’s to raw files, fired qemu-system-hppa but the lvm setup is not happy about having to boot from lowest scsi id. Is there a way to force SeaBIOS to boot from highest scsi id ? It seems to be the standard on hpux. THANKS !

  5. timmerman says:

    Hello! How did you build QEMU in macOS? The ones available in brew/macports can only emulate x86_64/i386 and ARM.

    I am trying to build it myself with support for PPC, HPPA, SPARC and Alpha besides the regular i386/x86_64 and ARM. The QEMU page didn’t tell a lot about how to build it. I installed all the required dependencies (libffi, gettex, glib, pkg-config, autoconf, automake, pixman and ninja) from homebrew. Indeed the system couldn’t find the ninja installation, and I needed to specify it manually in ./configure, but it went fine after that.

    While running make, it crashed in the following error:
    https://pastebin.com/tj11H1dj

    When I try with the standard macOS’ make it also crashes over there. Did you use any script to build it? Not sure what else can I do to get it compiled.

    Thanks in advance!

    • astr0baby says:

      Just compile qemu-6 (current) from source as it is in git – bear in mind that I never used brew – i compiled everything from source myself – so you need to go step by step – first get all the qemu dependencies and then build qemu – there is a good build script included with the UTM (https://github.com/utmapp/UTM) – namely the https://github.com/utmapp/UTM/blob/master/scripts/build_dependencies.sh – you can use this to build a solid base – then just git clone the latest qemu-git and build it

      • timmerman says:

        Thank you very much for the tips. I initially thought it would be difficult to build manually all the dependencies — I was thinking that glib would require something, and this something would require something else, you know.

        Anyway mostly of the dependencies builds just fine with no external requirements. The only “extra” thing I did was add –prefix=/opt/qemu, where I built everything.

        After that I tried to build QEmu 6.5.0 once again, but it also crashed with the same error message I was having before. So, I tried to build it from git as you suggested. It compiled just fine!

        At last I just compressed the /opt/qemu folder and sent it over to my personal laptop, it worked fine indeed. I’m already playing here with Solaris 8 SPARC. Soon will try the HP-UX here. I still have my old AIX 5.1.1 CD Roms, but as they’re old, I’m not sure whether they will still read.

        Thank you very much for the help!

  6. Dwordcito says:

    Hi astrobaby! I’m trying to run hpux ia64 system with qemu to later compile gcc and g++ in version 9, I am interested in this since I want a security software to be able to compile for hpux! do you have an iso of 11.31?

  7. danwaterloo says:

    I am running into an issue with qemu and the qcow2 partition sizes. I create the disk.img using the command listed in your guide, and it’s supposed to be 30G …, as verfied below: the virtual size is 30G, the actual disk file is 3G. I ran the qemu-img size on the host computer…

    % qemu-img info disk.img
    image: disk.img
    file format: qcow2
    virtual size: 30 GiB (32212254720 bytes)
    disk size: 3 GiB
    cluster_size: 65536
    Format specific information:
    compat: 1.1
    compression type: zlib
    lazy refcounts: false
    refcount bits: 16
    corrupt: false
    extended l2: false

    From inside the virtual machine, I run the following command:

    # df -k
    /home (/dev/vg00/lvol5 ) : 24576 total allocated Kb
    8280 free allocated Kb
    16296 used allocated Kb
    66 % allocation used
    /opt (/dev/vg00/lvol6 ) : 2482976 total allocated Kb
    944776 free allocated Kb
    1538200 used allocated Kb
    61 % allocation used
    /tmp (/dev/vg00/lvol4 ) : 203224 total allocated Kb
    200720 free allocated Kb
    2504 used allocated Kb
    1 % allocation used
    /usr (/dev/vg00/lvol7 ) : 2276624 total allocated Kb
    1139824 free allocated Kb
    1136800 used allocated Kb
    49 % allocation used
    /var (/dev/vg00/lvol8 ) : 1554072 total allocated Kb
    1355000 free allocated Kb
    199072 used allocated Kb
    12 % allocation used
    /stand (/dev/vg00/lvol1 ) : 269032 total allocated Kb
    246648 free allocated Kb
    22384 used allocated Kb
    8 % allocation used
    / (/dev/vg00/lvol3 ) : 203872 total allocated Kb
    121248 free allocated Kb
    82624 used allocated Kb
    40 % allocation used
    This shows that the /home partition/disk is 66% full!

    using the script listed on this page:
    http://www.snapdba.com/2012/10/readable-df-h-output-in-hp-ux/#.Yikptri-n0o
    I got a more friendly readout:
    # ./dfscr.sh
    Filesystem Mount Point Total GB Avail GB Used GB Used
    ——————————————— ————————- ———- ———- ———- —–
    /dev/vg00/lvol5 /home 0.02 0.01 0.02 67%
    /dev/vg00/lvol6 /opt 2.37 0.90 1.47 62%
    /dev/vg00/lvol4 /tmp 0.19 0.19 0.00 2%
    /dev/vg00/lvol7 /usr 2.17 1.09 1.08 50%
    /dev/vg00/lvol8 /var 1.48 1.29 0.19 13%
    /dev/vg00/lvol1 /stand 0.26 0.24 0.02 9%
    /dev/vg00/lvol3 / 0.19 0.12 0.08 41%

    From inside the HPUX VM, the OS only sees a total disk size of 6.7GB… not 30GB!
    What I would like to do is expand the /home to consume another 10GB… (/dev/vg00/lvol5)
    Do you have a recommended procedure/command to do so? I thought the qcow2 disk would be expanded automatically until it reached a max of 30G… but that is not happening.

    Thanks!

    • astr0baby says:

      I think it depends on how you initially setup the disks during the install – as for the VG expansion you should refer to the HP-UX documentation.

      • danwaterloo says:

        Thanks astr0baby, I finally figured out that by running SAM (the HP UX System Administration Module… open a terminal, su to root, and type ‘sam’), under the Disks and File Systems, Logical Volumes, you can select the volume you want to alter, and then ‘Actions’, ‘Increase Size’… specify the final size, and then ‘ok’. Note that a volume has to be unmounted before you can change the size.

        I also found that to ftp to the HPUX qemu machine from the host computer (in this case my mac mini running macOS Monterey, you need to open the ftp ports (21) and use filezilla with some special settings.
        Here’s what I changed on the startup ‘run.sh’ script to open the ftp port: (the -net user line)
        -net nic,model=tulip \
        -net user,hostfwd=tcp::2222-:22,hostfwd=tcp::2221-:21
        and for the filezilla configuration:
        this page: https://xqemu.com/tips/
        It’s assumed you’re using Filezilla. If not, look for the respective settings in your client. Fire up Filezilla and set the following options:

        Filezilla > Settings > Connection > FTP > Active mode
        Active mode IP, “Use the following IP address:” 10.0.2.2
        Make sure “Don’t use external IP address on local connections.” is NOT checked

        Then create your new “Site” with IP address 127.0.0.1 and port 1021. Under Transfer Settings, check Active.

      • astr0baby says:

        Glad you got it working :)

  8. danwaterloo says:

    Can someone help me with a run script? I would like to boot the HP UX 11.11 guest computer, and then run the CDE ‘native’ on that virtual machine. I have running software on an old hppa machine, and I’d like to get it running on the new, virtual machine.

    I’m running into a problem with the license manager for the software I need to use, and exporting the desktop to the host machine and running xwindows that way confuses the license manager. I need to run the license manager on 10.0.2.15, and the desktop on 10.0.2.15. then everything should work ok. When I export the desktop to the host machine, the software license manager sees the ip of my xwindows as the ip address of the host computer (on my lan).

    This is a ‘feature’ of the qemu lan and gateway….

    To get around this, the simplest way would be for the ‘run’ command to turn on the computer, with graphics, and boot to the CDE login screen… I tried ‘init 4’, and removing the ‘no graphics’ line in the run script. The computer boots, to the console login, but not to CDE.
    Any suggestions? Thanks!!!!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.