Sunday, 8 August 2021

Slackware Linux 3.0 on QEMU

Slackware

Established back in 1993, Slackware (The Slackware Linux Project; Wikipedia) is the oldest surviving Linux distribution...

Slackware Linux 3.0 was the first Slackware release to have an official CD-ROM distribution and support installation from CD-ROM. Released in November 1995, the same month as the Pentium Pro, it doesn't have support for a lot of the more modern hardware emulated by QEMU...


QEMU

The default QEMU i386 system emulation ('pc') is based on Intel's "Natoma" (Intel 440FX & PIIX3) chipset for Pentium Pro and Pentium II processors, which was released in 1996 (List of Intel chipsets - Wikipedia):

  • Model: "pc" - Intel 440FX & PIIX3 "Natoma"
  • CPU: "qemu32" - QEMU Virtual CPU (default)
  • RAM: 128 MiB default, 2 GiB max.
  • Bus: PCI and ISA
  • Storage controller: IDE (PIIX3)
  • Network interface: "e1000" - Intel 82540EM Gigabit Ethernet Controller, 1,000 Mb/s ethernet
  • Graphics: "std" - Standard VGA (with Bochs VBE)

Since the kernels included with Slackware 3.0 are older than this, they don't recognize the hardware and use generic methods to run on the system. Distributions based on the Linux 2.0 series or later kernels would be a better choice for the 'pc' machine (Linux Version 2.0 | Linux Journal).

Fortunately QEMU has a generic ISA based PC system profile ('isapc') which provides an option that is more in keeping with the hardware available when Slackware 3.0 was released:

  • Model: "isapc" - ISA bus PC
  • CPU: "486" - Intel i486DX/4
  • RAM: 128 MiB default, 2 GiB max.
  • Bus: ISA
  • Storage controller: IDE
  • Network interface: "ne2k_isa" - NE2000 ISA, 10 Mb/s ethernet (IRQ 9, I/O 0x300)
  • Graphics: "cirrus" - Cirrus GD-5446 VGA ISA
This isn't ideal, given that PCI based 486 and Pentium based systems existed at the time, but QEMU doesn't provide the appropriate chipsets for those systems, so exploration of those options will have to be on real hardware, or using other emulators (e.g. Bochs, PCem, etc.).

Installation

  1. Fetch the Slackware Linux 3.0 CD-ROM image from Archive.org (https://archive.org/details/Slackware_Linux_3.0_Walnut_Creek_October_1995), for installation we only need CD 1.
  2. Sadly the CD is not bootable (the El Torito CD-ROM specification was released in 1995), so we need to use floppy boot images. We need a boot and a root image.
  3. For the 'isapc' and 'pc' machines the 'idecd' and 'color.gz' floppy images are what we are looking for to get IDE CD-ROM support and nice menus for installation.
    1. On Linux:
      mkdir tmp_mnt
      fuseiso slackware3_cd1.iso tmp_mnt # Mount the ISO
      cp tmp_mnt/bootdsks.144/idecd ./  # Boot disk (only 600KB)
      truncate -s 1440K idecd           # Pad boot disk to 1.44MB
      cp tmp_mnt/rootdsks/color.gz ./   # Root disk (already 1.44MB)
      guestunmount tmp_mnt/             # Unmount the ISO
      rmdir tmp_mnt
  4. And a disk image for the install, a 2 GB disk will be more than enough: qemu-img create -f qcow2 hda_Slackware3.qcow2 2G
  5. Now we can boot the system for installation. In QEMU 5.2.0, the floppy support in 'isapc' appears to be broken, so we have to use 'pc' for installation:
    qemu-system-i386 \
        -machine type=pc \
        -cpu 486 \
        -m size=512M \
        -fda idecd \
        -fdb color.gz \
        -hda hda_Slackware3.qcow2 \
        -cdrom slackware3_cd1.iso \
        -net nic -net user \
        -device sb16 \
        -boot order=a \
        -no-reboot \
        -name "Install Slackware Linux 3.0 on pc/486"
    
  6. Since we're using boot and root floppies in different drives, use "ramdisk root=/dev/fd1" as detailed on the boot screen.
  7. The hard drive is blank, so once we've logged in as "root", we need to partition the disk: fdisk /dev/hda
    1. Use 'm' to familiarize yourself with the options.
    2. Since we have plenty memory we can skip having a swap partition. For illustration I will create one, but the whole disk can be used as root instead.
    3. New 'n', primary partition 'p', partition '1', from cylinder '1' to '504'
    4. New 'n', primary partition 'p', partition '2', from cylinder '505' to '520' (at ~4 MB per cylinder, 16 cylinders is about 64 MB).
    5. Type 't', partition '2', type list 'L', type '82' (Linux swap).
    6. Write changes to disk 'w'
  8. With the disk partitioned, run setup to continue the installation and follow the prompts...
    1. If your plan to use the manual pages (man) be sure to install GNU troff (gtroff)
    2. The QEMU 'cirrus' display will work with the SVGA XFree86 server
    3. The QEMU mouse is PS/2
    4. For QEMU user networking the IP addresses are (from Documentation/Networking - QEMU):
      • Host: 10.0.2.15
      • Gateway: 10.0.2.2
      • Netmask: 255.255.255.0
      • DNS: 10.0.2.3
    5. In order to use the configured 512 MiB RAM, remember to tell LILO to use "mem=512M" as a kernel parameter
  9. After packages are installed, and the system shutdown, we can switch to an 'isapc':
    qemu-system-i386 \
        -machine type=isapc \
        -cpu 486 \
        -m size=512M \
        -hda hda_Slackware3.qcow2 \
        -cdrom slackware3_cd1.iso \
        -net nic -net user \
        -device sb16 \
        -boot order=c \
        -no-reboot \
        -name "Slackware Linux 3.0 on isapc/486"
  10. Once logged in you can give 'root' a password (passwd), add a regular user account (adduser), enable serial port login (/etc/inittab) and configure the X server (xf86config)
    1. When configuring the X server, you can assume the monitor is the most capable option each time. The emulated card is a Cirrus Logic GD-5446 VGA ISA with 4MB RAM, so any of the Cirrus Logic cards will do, I used the "Cirrus Logic GD543x" option.

With the system installed further exploration will involve hitting the documentation:

System Information

So what does Slackware Linux 3.0 have to say about the 'isapc' system...

uname

Operating system release information:

$ uname -a
Linux q-slack3 1.2.13 #1 Wed Aug 23 00:34:56 CDT 1995 i486

A "Linux" kernel, on a node named "q-slack3", kernel release "1.2.13", version "#1 Wed Aug 23 00:34:56 CDT 1995", on a "i486" machine.

/proc/cpuinfo

Processor information:

$ cat /proc/cpuinfo
cpu		: 486
model		: DX/4
mask		: Unknown
vid		: GenuineIntel
fdiv_bug	: no
math		: yes
hlt		: yes
wp		: yes
Integrated NPU	: yes
Enhanced VM86	: no
IO Breakpoints	: no
4MB Pages	: yes
TS Counters	: no
Pentium MSR	: no
Mach. Ch. Exep.	: no
CMPXCHGB8B	: no
BogoMips	: 516.22

So QEMU's '486' processor is an Intel 486DX/4 (from other Linux versions the CPUID is: family 4, model 8, stepping 0). The CPUID (Wikipedia) feature flags are shown in order, starting with "Integrated NPU" for the first 8 bits. Interestingly it appears that a real Intel 486DX/4 would set the "Enhanced VM86" flag for VME support (Virtual-8086 Mode Extensions), and not set the "4MB Pages" flag for PSE (Page Size Extension).

From the BogoMips result we can estimate the processor clock to be:

516 * 2 = 1,032 MHz = 1.0 GHz

That shows how far Intel processors have come... Intel's fastest 486 was the 486DX/4 100 MHz, and here we are running an emulated 486 on an i7 860 2.80 GHz and we get a ridiculously fast 486.

/proc/meminfo

Memory information:

$ cat /proc/meminfo 
        total:   used:    free:   shared:  buffers:
Mem:  533798912  5627904 528171008  4648960  2146304
Swap: 66056192        0 66056192

So 512 MiB RAM, with 64 MB of swap.

Linux 1.2 used the BIOS to get RAM size, and that only reported up to 64 MiB, for larger memory systems Linux needed to be told about the available memory via the "mem" kernel parameter. This is likely also the reason that the swap partition size for Linux 1.2 could be no larger than 64 MB, for larger swap multiple partitions were required. The small swap configured here is to allow idle memory pages from the kernel and system daemons to be swapped out if necessary.

dmesg

System log:

$ dmesg
Console: colour EGA+ 80x25, 1 virtual console (max 63)
bios32_init : BIOS32 Service Directory structure at 0x000f6820
bios32_init : BIOS32 Service Directory entry at 0xfd34f
pcibios_init : PCI BIOS revision 2.10 entry at 0xffa40
Probing PCI hardware.
Calibrating delay loop.. ok - 516.22 BogoMips
Serial driver version 4.11 with no serial options enabled
tty00 at 0x03f8 (irq = 4) is a 16550A
lp1 at 0x0378, using polling driver
PS/2 auxiliary pointing device detected -- driver installed.
ftape: allocated 3 buffers aligned at: 00370000
hda: QEMU HARDDISK, 2048MB w/256KB Cache, LBA, CHS=520/128/63, MaxMult=16
hdc: QEMU DVD-ROM, ATAPI, CDROM drive
ide1: secondary interface on irq 15
ide0: primary interface on irq 14
Floppy drive(s): fd0 is 2.88M AMI BIOS
FDC 0 is a post-1991 82077
scsi : 0 hosts.
scsi : detected total.
lance.c: PCI bios is present, checking for devices...
Memory: 521292k/524288k available (840k kernel code, 384k reserved, 1772k data)
This processor honours the WP bit even when in supervisor mode. Good.
Swansea University Computer Society NET3.019
Swansea University Computer Society TCP/IP for NET3.019
IP Protocols: ICMP, UDP, TCP
PPP: version 0.2.7 (4 channels) NEW_TTY_DRIVERS OPTIMIZE_FLAGS
TCP compression code copyright 1989 Regents of the University of California
PPP line discipline registered.
SLIP: version 0.8.3-NET3.019-NEWTTY (4 channels) (6 bit encapsulation enabled)
CSLIP: code copyright 1989 Regents of the University of California
NE*000 ethercard probe at 0x300: 52 54 00 12 34 56
eth0: NE2000 found at 0x300, using IRQ 9.
ne.c:v1.10 9/23/94 Donald Becker (becker@cesdis.gsfc.nasa.gov)
Checking 386/387 coupling... Ok, fpu using exception 16 error reporting.
Checking 'hlt' instruction... Ok.
Linux version 1.2.13 (root@bigkitty) (gcc version 2.7.0) #1 Wed Aug 23 00:34:56 CDT 1995
Partition check:
  hda: multiple mode turned off
  hda: hda1 hda2
VFS: Mounted root (ext2 filesystem) readonly.
Adding Swap: 64508k swap-space
Max size:331555   Log zone size:2048
First datazone:68   Root inode number 139264
ISO9660 Extensions: RRIP_1991A

Here we see the results of hardware detection, in the days before hardware told you what it was (Plug & Play), things work pretty well here with most of the installed hardware being picked up as expected.

Alternative - /proc/cpuinfo

Just for fun the /proc/cpuinfo for QEMU's 'pentium' processor:

$ cat /proc/cpuinfo 
cpu		: 586
model		: 4
mask		: C
vid		: GenuineIntel
fdiv_bug	: no
math		: yes
hlt		: yes
wp		: yes
Integrated NPU	: yes
Enhanced VM86	: no
IO Breakpoints	: yes
4MB Pages	: yes
TS Counters	: yes
Pentium MSR	: yes
Mach. Ch. Exep.	: yes
CMPXCHGB8B	: yes
BogoMips	: 488.06

From other versions of Linux we know the CPUID information is: family 5, model 4, stepping 3. Which is what we see here with cpu "586" (family 5), model "4" (model 4) and mask "C" ("C" = 43, so "C" - "@" => 43 - 40 = 3; stepping 3). This means the processor is an Intel Pentium MMX (see CPUID - Intel - WikiChip), which didn't start shipping till 1997.

Like the emulated '486', the "Enhanced VM86" flag for VME (Virtual-8086 Mode Extensions) would be set on a real Pentium MMX processor.


No comments: