Installing Gentoo Linux on Alphavm

Please regard this article as something of a work journal rather than exact steps instructions. Definitely not for someone not familiar with Linux/UNIX environment  – but then again who the hell would want to run Alpha Linux on a Simulator if not skilled already ?

The fastest supercomputers based on Alpha processors:

  • Sunway TaihuLight at Chinese National Supercomputing Center in Wuxi. Machine: Sunway TaihuLight MPP. CPU: 40,960 SW26010 (256+4 cores/CPU, 1.45 GHz). Rmax=93PFlops, Rpeak=125PFlops.

Sharing my experience during this interesting exercise installing Gentoo Linux on a simulated Alpha environment. Since Getnoo is the only Linux distribution that supports the Alpha architecture and alphavm can boot and run the Gentoo LiveCD (for Alpha) I have decided to install it onto an emulated SCSI disk and run locally. Now this took some time to finalize and I had to redo a couple of steps due to some slightly misleading documentation on the official Gentoo Alpha Handbook https://wiki.gentoo.org/wiki/Handbook:Alpha

Prerequisites

  1. 64bit Linux system that can run Alphavm_free
  2. 6 GB disk space for dka0 simulated SCSI drive
  3. Minimal Installation CD from Gentoo (Alpha)
  4. Tru64 UNIX 5.1B – Disk 1 Operating System [DEC Alpha]   here
  5. A general knowledge how to setup UNIX on emulated Alphas
  6. https://astr0baby.wordpress.com/2017/02/20/unix-os-archaeology-tru64-unix-part-2/
  7. https://astr0baby.wordpress.com/2014/04/07/running-tru64-unix-inside-a-vm-for-metasploit-testing/
  8. A lot of patience and time

Section 1.1  – Setting up the Alphavm_free environment to run Gentoo Linux

So we will use a dka0 disk.dd which needs to be carefully prepared in order to be usable by the Gentoo installation LiveCD (dka400)

First we prepare a blank 6 GB disk.dd file by a simple dd command

dd if=/dev/zero of=disk.dd bs=1024 count=6M

Gentoo Live CD for Alpha cannot create a BSD disk label on the blank disk.dd file unfortunately so we need to create it from some other system that can do this (Tru64 5.1 / OSF1 or NetBSD for example) In this example we will use the standard Tru64 5.1B installation procedure to install a minimal system that will hold a valid BSD disklabel that we will then use in our Gentoo installation.

Section 1.1.1 Setting up the disk.dd with BSD Disklabel

We will use the Tru64 5.1B ISO provided from Winworld here https://winworldpc.com/product/tru64/51b

Download the Tru64 UNIX 5.1B – Disk 1 Operating System [DEC Alpha]   here

Lets create a temporary directory for Tru64 disk.dd preparation so we can use the disk.dd afterwards for the Gentoo installation. Plase all the required files into this directory (including the freshly creaded 6GB disk.dd)  I keep mine in Digital folder and here is an example of the verified working Tru64 config.emu

system {
 
 type = ds20l_833;
 reported_type = default;
 num_cpus = 1;
 ssn = 'EmuVM-00-000-001';
 interval_clock_freq = 100;
 
memory {
 size = 512;
}
 
cpu {
 server = basic;
 
jit {
 async = yes;
}
}
 
serial com1 {
 server = socket;
 port = 3000;
}
 
scsi_controller qla0 {
}
 
scsi_disk dka0 {
 scsi_bus = 0;
 scsi_id = 0;
 scsi_lun = 0;
 file = 'disk.dd';
 caching = no;
 write_through = yes;
}

scsi_cdrom iso {
 scsi_id = 4 ;
 file = 'tru64-5.iso';
}
 
ether eth0 {
 type = dec21040;
 server = dummy;
 mac_address = 0x08002B000001;
}
 
ether eth1 {
 type = dec21040; 
 server = tap;
 interface = 'tap0'; 
 mac_address = 0x08002B000002;
}
}

Here is the content of the Temporary Digital folder

-rwxr-xr-x 1 root root 3241128 Apr 10 23:05 alphavm_free
-rw-r--r-- 1 root root 742 Jun 3 00:43 config.emu
-rwxr--r-- 1 user user 50 Apr 10 23:05 connect.console.sh
-rwxr--r-- 1 root root 407 Apr 10 23:11 networking.sh
-rw-r--r-- 1 root root 19 Jun 4 00:49 rtc.dat
-rwxr--r-- 1 root root 26 Apr 10 23:11 run.sh
-rw-r--r-- 1 root root 323 Jun 4 00:48 srm.dat
-rw-r--r-- 1 root root 655974400 May 8 2014 tru64-5.iso
-rw-r--r-- 1 root root 6048186368 Jun 10 21:15 disk.dd

connect.console.sh, networking.sh and run.sh  content can be found here

So lets boot Tru64 installation and prepare the disk ! (from the Digital directory)

# ./alphavm_free config.emu

And connect to the console

socat -,raw,echo=0,escape=0x1c tcp:127.0.0.1:3000

After a while press 1 to run an English language setup

Add some root password (not needed later as we only need the valid BSD disklabel)

Set some hostname

Set some timezone

Next select only the Mandatory only software installation to speed up the setup process

No LVM

Default filesystem layout

UFS

So we should finally get to the installation phase (this takes a couple of minutes)

So after the system installs and reboots into the fresh Tru64 environment you can safely ctrl+c in the main Alphavm_free console window to terminate the simulation

Our disk.dd is now ready with a nice shiny BSD disklabel to be used in the next step for Gentoo installation

Setion 1.2 Installing Gentoo on Alphavm_free

Create a new config.emu to simulate the Alpha ds20e 833 MHz inside a Gentoo directory

system {
 
 type = ds20e_833;
 reported_type = default;
 num_cpus = 1;
 ssn = 'EmuVM-00-000-001';
 interval_clock_freq = 1000;
 
memory {
 size = 1024;
}
 
cpu {
 server = basic;
 
jit {
 async = yes;
}
}
 
serial com1 {
 server = socket;
 port = 3000;
}
 
scsi_controller qla0 {
 scsi_id = 1;
}
 
scsi_disk dka0 {
 scsi_bus = 0;
 scsi_id = 0;
 scsi_lun = 0;
 file = 'disk.dd';
 caching = no;
 write_through = yes;
}

scsi_cdrom iso {
 scsi_id = 4;
 file = 'gentoo.iso';
}
 
ether eth0 {
 type = dec21040;
 server = dummy;
 mac_address = 0x08002B000001;
}
 
ether eth1 {
 type = dec21040; 
 server = tap;
 interface = 'tap0'; 
 mac_address = 0x08002B000002;
}
}

Add the following network.sh script into the Gentoo directory (this is for networking)

#Setup tap and bridge 
tunctl -t tap0 -u user
ifconfig tap0 up
brctl addbr br0
brctl addif br0 eth0
brctl setfd br0 0
ifconfig eth0 10.0.2.1 up 
ifconfig br0 10.0.2.2 netmask 255.255.255.0 broadcast 10.0.2.255 up
brctl addif br0 tap0
ifconfig tap0 0.0.0.0
sysctl net.ipv4.ip_forward=1
iptables -A FORWARD --in-interface eth0 -j ACCEPT
iptables --table nat -A POSTROUTING --out-interface wlan0 -j MASQUERADE

Place the modified disk.dd from the previous step into the Gentoo directory as well as the Gentoo Live CD iso and name accordingly  disk.dd and gentoo.iso

-rwxr-xr-x 1 user user 3241128 May 30 22:17 alphavm_free
-rw-r--r-- 1 user user 759 Jun 3 23:10 config.emu
-rwxr--r-- 1 user user 50 May 30 22:27 connect.console.sh
-rw-r--r-- 1 root root 6048186368 Jun 10 21:15 disk.dd
-rw-r--r-- 1 user user 224665600 May 31 23:14 gentoo.iso
-rwxr--r-- 1 user user 407 Jun 3 22:35 networking.sh
-rw-r--r-- 1 root root 19 Jun 10 21:15 rtc.dat
-rwxr--r-- 1 user user 26 May 30 22:22 run.sh
connect.console.sh  – socat -,raw,echo=0,escape=0x1c tcp:127.0.0.1:3000
run.sh – ./alphavm_free config.emu

So lets boot up the Gentoo Live CD and start the installation from the Gentoo directory

# ./networking.sh 
# ./alphavm_free config.emu
./socat -,raw,echo=0,escape=0x1c tcp:127.0.0.1:3000

Once inside the SRM environment select the SCSI cdrom to boot

Welcome to EmuVM hardware emulator.
 � Copyright 2010 - 2012, Artem Alimarin. All rights reserved.
 Please visit http://emuvm.com for more information.

>>> boot dka400

Once you boot into the Gentoo live CD now comes the Gentoo Alpha guide which I will comment so that we can successfully install the Gentoo onto dka0 SCSI disk.

Setting up network is really simple run the following to get everything going

# ifconfig enP1p1s9 10.0.2.11 up 
# route add default gw 10.0.2.1 
# echo 'nameserver 8.8.8.8' > /etc/resolv.conf

First section that we are going to cover is the Alpha/Installation/Disks as it is covered here  https://wiki.gentoo.org/wiki/Handbook:Alpha/Installation/Disks

You can follow the guide but once you get to the slice configuration please use the below information (I have spent some days getting this done correctly) What you need to do via fdisk /dev/sda is to remove all the slices except C.  Here are some screenshots from the disklabel edit

Disk /dev/sda: 5.6 GiB, 6048186368 bytes, 11812864 sectors
Geometry: 206 heads, 224 sectors/track, 256 cylinders
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: bsd

Slice Start End Sectors Size Type Fsize Bsize Cpg
a 500 205300 204801 100M ext2 0 0 0
b 205302 1253878 1048577 512M swap 0 0 0
c 0 11812863 11812864 5.6G unused 0 0 0
d 1253880 11812860 10558981 5G ext2 0 0 0

Partition table entries are not in disk order.

Command (m for help):

Here is the fdisk script that can be used to load the proper disklablel info

alpha ~ # cat disk.read 
label: bsd
device: /dev/sda
unit: sectors

/dev/sda1 : start= 500, size= 204801, type=8
/dev/sda2 : start= 205302, size= 1048577, type=1
/dev/sda3 : start= 0, size= 11812864, type=0
/dev/sda4 : start= 1253880, size= 10558981, type=8

Although we dont need the separate /boot partition for Alpha aboot stuff I have still added it there as a buffer zone, please feel free to experiment as you like :)

Just keep in mind that the slice A has to start on some higher sector (500 is safe) so the aboot can fit at the start of the disk. Also the D slice should end by on sector lower than the actual full sector size. (Thas a bug and it is documented on the Gentoo/Alpha/Disks page)

Once all is done dmesg should show the following new disk info

Create ext2/ext3/ext4  (I have used ext2)  filesystems mkfs.ext2 /dev/sda1  and mkfs.ext2 /dev/sda4  and mkswap /dev/sda2  and swapon /dev/sda2

Mount the root partition

mount /dev/sda4 /mnt/gentoo

And we move onto the next Installation Stage and Installation Base  –  https://wiki.gentoo.org/wiki/Handbook:Alpha/Installation/Stage

plus  https://wiki.gentoo.org/wiki/Handbook:Alpha/Installation/Base

Make sure to set some sane date ;) and pretty much follow the guide

Then run the emerge –sync

nano -w /etc/locale.gen 

Next we move onto configuring the kernel https://wiki.gentoo.org/wiki/Handbook:Alpha/Installation/Kernel

emerge --ask sys-kernel/gentoo-sources

If you need pciutils then do the following emerge --ask sys-apps/pciutils otherwise proceed

Now a little deviation from the Gentoo documentation comes. Instead of figuring our what needs to be in the kernel and what not we simply take the current running LiveCD Gentoo kernel (that works well with Alphavm_free) config from proc and use that to build a custom kernel :)

# zcat /proc/config.gz > /usr/src/linux/.config
# cd /usr/src/linux 
# make oldconfig

Answer N or n on all the new options the newer kernel will ask (or do whatever you want if you know the Linux kernel stuff for 4.9.x branch)

root #make && make modules_install

This will take some time so please be patient (mine took approx 1 day to finally build)

root #cp arch/alpha/boot/vmlinux.gz /boot/
root #emerge --ask sys-kernel/genkernel
Again this will take some time to build
root #genkernel --install initramfs
Exit chroot and copy the bootlx from the LiveCD /boot directory to /mnt/gentoo/boot/
Enter chroot again in /mnt/gentoo

You /boot should look like this

-rwxr-xr-x 1 root root 80896 May 23 01:46 bootlx
-rw-r--r-- 1 root root 3982172 Jun 9 10:22 initramfs-genkernel-alpha-4.9.6-gentoo-r1
drwx------ 2 root root 4096 May 23 00:33 lost+found
-rw-r--r-- 1 root root 29696 May 23 00:33 net_aboot.nh
-rw-r--r-- 1 root root 3453359 Jun 9 10:01 vmlinux.gz

P.S Don’t use the following recommendation from the Gentoo documentation – it does not work on the Alphavm

Alternative: Using genkernel

If a manual configuration looks too daunting, then using genkernel is recommended. It will configure and build the kernel automatically.

Move on with the next stage setup https://wiki.gentoo.org/wiki/Handbook:Alpha/Installation/System

You can skip the next stage setup https://wiki.gentoo.org/wiki/Handbook:Alpha/Installation/Tools

Now comes the important part that can screw up the whole effort in one command so be careful :) https://wiki.gentoo.org/wiki/Handbook:Alpha/Installation/Bootloader

root #emerge --ask sys-boot/aboot
swriteboot -f3 /dev/sda /boot/bootlx
abootconf /dev/sda 4
Add this to /etc/aboot.conf
0:4/boot/vmlinux.gz initrd=/boot/initramfs-genkernel-alpha-4.9.6-gentoo-r1 init=/linuxrc root=/dev/sda4 dokeymap console=ttyS0

Next make sure you have a sane /etc/rc.conf

# /etc/conf.d/rc: Global config file for the Gentoo RC System

# This is the number of tty's used in most of the rc-scripts (like
# consolefont, numlock, etc ...)

RC_TTY_NUMBER=11

# Set to "yes" if you want the rc system to try and start services
# in parallel for a slight speed improvement. NOTE: When RC_PARALLEL_STARTUP
# is enabled, init script output is replaced with simple "service foo
# starting/stopping" messages so that output is not mixed up.
# You can stop this from happening on the command line by passing --verbose
# to the init script or by setting RC_VERBOSE="yes" below.

RC_PARALLEL_STARTUP="no"

# Set RC_INTERACTIVE to "yes" and you'll be able to press the I key during
# boot so you can choose to start specific services. Set to "no" to disable
# this feature.

RC_INTERACTIVE="yes"

# Do we allow services to be hotplugged? If not, set to RC_HOTPLUG="no"
# NOTE: This does not affect anything hotplug/udev related, just the
# starting/stopping of the init.d service triggered by hotplug.

RC_HOTPLUG="yes"

# Dynamic /dev managers can trigger coldplug events which cause services to
# start before we are ready for them. If this happens, we can defer these
# services to start in the boot runlevel. Set RC_COLDPLUG="no" if you don't
# want this.
# NOTE: This also affects module coldplugging in udev-096 and higher
# If you want module coldplugging but not coldplugging of services then you
# can set RC_COLDPLUG="yes" and RC_PLUG_SERVICES="!*"

RC_COLDPLUG="yes"

# Some people want a finer grain over hotplug/coldplug. RC_PLUG_SERVICES is a
# list of services that are matched in order, either allowing or not. By
# default we allow services through as RC_COLDPLUG/RC_HOTPLUG has to be yes
# anyway.
# Example - RC_PLUG_SERVICES="net.wlan !net.*"
# This allows net.wlan and any service not matching net.* to be plugged.

RC_PLUG_SERVICES="net.enP1p1s9"

# RC_NET_STRICT_CHECKING allows some flexibility with the 'net' service.
# The following values are allowed:
# none - The 'net' service i
# s always considered up.
# no - This basically means that at least one net.* service besides net.lo
# must be up. This can be used by notebook users that have a wifi and
# a static nic, and only wants one up at any given time to have the
# 'net' service seen as up.
# lo - This is the same as the 'no' option, but net.lo is also counted.
# This should be useful to people that do not care about any specific
# interface being up at boot.
# yes - For this ALL network interfaces MUST be up for the 'net' service to
# be considered up.

RC_NET_STRICT_CHECKING="no"

# RC_DOWN_INTERFACE allows you to specify if RC will bring the interface
# completely down when it stops. The default is yes, but there are some
# instances where you may not want this to happen such as using Wake On LAN.

RC_DOWN_INTERFACE="yes"

# RC_VOLUME_ORDER allows you to specify, or even remove the volume setup
# for various volume managers (MD, EVMS2, LVM, DM, etc). Note that they are
# stopped in reverse order.

RC_VOLUME_ORDER="raid evms lvm dm"

# RC_VERBOSE will make init scripts more verbose. Only networking scripts
# really use this at this time, and this is useful for trouble shooting
# any issues you may have.
# This is also used to re-enable init script output for init scripts
# started or stopped from the command line.

RC_VERBOSE="no"

# RC_BOOTLOG will generate a log of the boot messages shown on the console.
# Useful for headless machines or debugging. You need to emerge the
# app-admin/showconsole package for this to work. Note that this probably
# won't work correctly with boot splash.

RC_BOOTLOG="no"

# Set to "yes" if you want to benchmark system boot with bootchart.
# You'll need to emerge the app-benchmarks/bootchart package for this to work.

RC_BOOTCHART="no"

# RC_USE_FSTAB allows you to override the default mount options for the
# standard /proc, /sys, /dev, and /dev/pts mount points. Note that this
# is the new way for selecting ramfs/tmpfs/etc... for udev mounting.

RC_USE_FSTAB="no"

# RC_USE_CONFIG_PROFILE allows you to have different /etc/conf.d files
# based on your runlevel - if a conf.d file for your profile does not exist
# then we try and use the default one.
# To enable runlevel selection at boot, append "softlevel=foobar" to your
# kernel line to change to the foobar runlevel. Here we would search for
# /etc/conf.d/<service>.foobar config files before trying to use the default
# /etc/conf.d/<service>.
# Note that it is only active if 'softlevel' was specified via the kernel line,
# and it is intended to use for different grub/lilo entries to specify config
# changes for say laptops between home and work, where you would have setup
# 'work' and 'home' runlevels, with /etc/conf.d/*.<runlevel> as needed.

RC_USE_CONFIG_PROFILE="yes"

# RC_FORCE_AUTO tries its best to prevent user interaction during the boot and
# shutdown process. For example, fsck will automatically be run or volumes
# remounted to create proper directory trees. This feature can be dangerous
# and is meant ONLY for headless machines where getting a physical console
# hooked up is a huge pita.

RC_FORCE_AUTO="no"

# Use this variable to control the /dev management behavior.
# auto - let the scripts figure out what's best at boot
# devfs - use devfs (requires sys-fs/devfsd)
# udev - use udev (requires sys-fs/udev)
# static - let the user manage /dev (YOU need to create ALL device nodes)

RC_DEVICES="auto"

# UDEV OPTION:
# Set to "yes" if you want to save /dev to a tarball on shutdown
# and restore it on startup. This is useful if you have a lot of
# custom device nodes that udev does not handle/know about.

RC_DEVICE_TARBALL="no"

# RC_DMESG_LEVEL sets the level at which logging of messages is done to the
# console. See dmesg(8) for more info.

RC_DMESG_LEVEL="1"





#
# Controlling start-stop-daemon behavior

# Set to "yes" if start-stop-daemon should always retry killing the
# service with sig KILL if it fails the first time.

RC_RETRY_KILL="yes"



# Set the amount of seconds start-stop-daemon should wait between
# retries.

RC_RETRY_TIMEOUT=1



# Set the amount of times start-stop-daemon should try to kill
# a service before giving up.

RC_RETRY_COUNT=5



# Set to "yes" if start-stop-daemon should fail if the service
# is marked as started, but not actually running on stop.

RC_FAIL_ON_ZOMBIE="no"



# Set to "yes" if start-stop-daemon should attempt to kill
# any children left in the system.
# Be careful with this as it really does what it was on the tin.
# fex, if you're in an ssh process and you restart a service on which ssh
# depends then your terminal will be killed also.

RC_KILL_CHILDREN="no"



# Set the amount of seconds start-stop-daemon waits after starting
# the daemon to check it is still running. If it's not then we
# try and stop any children if possible.
RC_WAIT_ON_START="0.1"



##############################################################################
# SERVICE CONFIGURATION VARIABLES
# These variables are documented here, but should be configured in
# /etc/conf.d/foo for service foo and NOT enabled here unless you
# really want them to work on a global basis.

# Some daemons are started and stopped via start-stop-daemon.
# We can launch them through other daemons here, for example valgrind.
# This is only useful for serious debugging of the daemon
# WARNING: If the script's "stop" function does not supply a PID file then
# all processes using the same daemon will be killed.
#RC_DAEMON="/usr/bin/valgrind --tool=memcheck --log-file=/tmp/valgrind.syslog-ng"





# strace needs to be prefixed with --background as it does not detach when
# it's following
#RC_DAEMON="--background /usr/sbin/strace -f -o /tmp/strace.syslog-ng"

# Pass ulimit parameters
#RC_ULIMIT="-u 30"

##############################################################################



#
# Internal configuration variables
#
# NB: These are for advanced users, and you should really
# know what you are doing before changing them!
#

# rc-scripts dep-cache directory
#
# NOTE: Do not remove the next line, as its needed by the baselayout ebuild!
#
# svcdir="/var/lib/init.d"

svcdir="/var/lib/init.d"

# Should we mount $svcdir in a ram disk for some speed increase
# for slower machines, or for the more extreme setups ?

svcmount="no"

# FS type that should be used for $svcdir. Note that you need
# $svcmount above set to "yes" for this to work ... Currently
# tmpfs, ramfs, and ramdisk are supported (tmpfs is the default).

svcfstype="tmpfs"

# Size of $svcdir in KB. Note that ramfs doesn't support this
# due to kernel limitations.

svcsize=2048

Then you can unmount / reboot the system and load the dka0

cdimage ~#cd
cdimage ~#umount -l /mnt/gentoo/dev{/shm,/pts,}
cdimage ~#umount -R /mnt/gentoo
cdimage ~#reboot

Hopefully you will be able to boot to Alpha Gentoo on the Alphavm simulator

Also dont forget to setup ntpd, sshd and all that you need to be available in runlevel 3 :)

Here is a video of the dka0 boot process

 

 

P.S I can provide the disk.dd installed image if there would be interest, its only 6 GB :P

Advertisements
Gallery | This entry was posted in Uncategorized. Bookmark the permalink.

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 )

Google+ photo

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

Connecting to %s