Installing Gentoo Linux
On a Sun Ultra-1 Creator3D System

John Simpson <jms1@spamcop.net> 2002-08-13
I was recently given a Sun Ultra-1 with the Creator3D video card to use as a workstation in the office. It had Solaris pre-loaded on it, and over the course of about twenty minutes I was reminded of everything I've ever hated about Solaris as a workstation. I have been running Linux on various platforms (including RedHat 6.2 for sparc) for years, and Solaris just "feels" wrong to me. Nothing technical against Solaris, this is just my personal preference.

I tried Debian 3.0 for Sparc, but the version of kmail that it installed is not able to work correctly with my mailboxes (connecting via IMAP4 over SSL.) I know that the newer versions of kmail are able to work with these mailboxes correctly because my old workstation was an Intel machine running RedHat 7.3 and it works just fine, but there was no newer kmail package available (or any KDE3 packages available) at the time.

I downloaded the ISO file from the Gentoo-Sparc download site because I couldn't find any mirrors that had the ISO files.

I started the installation procedure by following the excellent Gentoo Sparc/Sparc64 Linux Installation Guide by Maarten Thibaut and adjusted the directions to match my situation.

One of the first things it tells you to do is to read through the Gentoo x86 Installation Guide. DO IT. It contains a functional overview of how the Gentoo installation system is structured, and if you've installed Linux before it illustrates the differences between Gentoo and most other distributions out there.

Following is a line-by-line list of the commands I used in order to get the system running. Note that the cyan-colored text is what I actually typed. Other colors appearing below reflect the actual colors of what I saw on the screen.


Power on the machine, hit STOP-A (i.e. press and hold the STOP key at the top-left corner of the keyboard, press A, and release both keys) when the machine starts to boot (i.e. when the monitor starts receiving a signal and the monitor's power light changes from yellow to green.)

ok boot cdrom
Boot device: ...
SILO
-- Welcome to Gentoo SPARC Linux --
boot: ramdisk

The Linux kernel loads itself, and eventually ends up with a root shell prompt. The first thing I did was moved the mouse a little bit (more to prevent its "initialized" message from showing up by surprise later on than anything else) and pressed ENTER to get another prompt.

init started: BusyBox v0.60.3-pre (2002.01.22-00:19+0000) multi-call binary
You are running "ash", a Bourne-shell clone. The root filesystem is
a RAM disk. The editor available to you is "nano-tiny".

To install gentoo, mount the cdrom and chroot into a root dir:
  # mount -t iso9660 -o ro /dev/cdroms/cdrom0 /mnt
  # chroot /mnt/root-`uname -m` bin/bash
  # source /etc/profile

Then mount the partition you want to use as gentoo's new "/" and
unpack one of the stage tarballs (this is an example - don't copy!)
  # mount -n /dev/hda2 /mnt/gentoo; cd /mnt/gentoo
  # bunzip2 -c /stage2-sparc-1.1a.tbz2 | tar xvpf -

There is mor information in the README.maintainer on the CD and at
http://www.gentoo.org/doc/build.html

# sunmouse: Successfully adjusted to 1200 baud.

#
The typo above ("There is mor information") was actually present on the CD. I have simply copied what the screen said, word for word.

The documentation wasn't entirely clear on this, but before you do anything else you need to make sure the machine has a working IP connection. When I set up the machine it was on a private network inside my office, behind a firewall.

After configuring the card, wait a few seconds for the ethernet card to announce that it's working, and then press ENTER.

# ifconfig eth0 192.168.0.88 netmask 255.255.255.0 up
# eth0: Link is up using internal transceiver at 100Mb/s, Full Duplex.

#

Once the card is up, make sure you can reach your gateway, and then set the machine's default route. The default route should point to a live Internet gateway machine, because we will be using it later to download the Gentoo packages.

# ping 192.168.0.1
PING 192.168.0.1 (192.168.0.1): 56 data bytes
64 bytes form 192.168.0.1: icmp_seq=0 ttl=255 time=0.5 ms
64 bytes form 192.168.0.1: icmp_seq=0 ttl=255 time=0.2 ms
CONTROL-C
--- 192.168.0.1 ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 0.2/0.3/0.5 ms
# route add default gw 192.168.0.1
#

The next step is to create and initialize the disk partition which will become the root of your Gentoo system.

# fdisk /dev/sda

My system has a 36GB sda and a 9GB sdb. I actually ran fdisk twice- once for /dev/sda and once for /dev/sdb. I started by deleting all of the existing partitions and creating sda1 as a Linux (type 83) partition covering the entire disk. I also created a 2GB sdb1 partition for swap (type 82) and used the remainder of the second drive as sdb2, another Linux (type 83) partition.

Note: On SPARC machines, each physical disk will have a partition #3 with type 5, "Whole disk". DO NOT DELETE THIS PARTITION. The SPARC boot loader needs to see this partition in order to work with the disk. BAD THINGS WILL HAPPEN if you delete this partition. You have been warned.

The next step is to format the filesystems.

# mke2fs -j /dev/sda1
# mkswap /dev/sdb1
# mke2fs -j /dev/sdb2

Mount the CD-ROM file system.

# mount -t iso9660 -o ro /dev/cdroms/cdrom0 /mnt

Start a new shell inside the installation system itself.

# chroot /mnt/root-sparc64 bin/bash

Your prompt will change. The next command sets your path so that you will have access to the installation tools.

bin/bash-2.05a# source /etc/profile

Your prompt will change again. You are now running inside the Gentoo installation environment.

(none) / #

The next step is to mount the partition which will become your root filesystem and extract the installer image. Note that the image supplied on the CD contains stage-1, stage-2, and stage-3 images for the 32-bit "sparc" architecture only. Since I'm running a "sparc64" machine (and because I like the idea that every program running on my system was compiled on my system) I choose to go with the stage-1 image. This is the longest process because everything that ends up on your finished system is compiled from source. I'm not sure if the stage-2 or stage-3 images would also work on my machine- I would imagine they would, but it may leave you with a 32-bit-only kernel or something silly like that...

(none) / # mount -n -t ext3 /dev/sda1 /mnt/gentoo
kjournald starting. Commit interval 5 seconds
EXT3 FS 2.4-0.9.17, 10 Jan 2002 on sd(8,2), internal journal
EXT3-fs: mounted filesystem with ordered data mode.
(none) / # cd /mnt/gentoo
(none) gentoo # tar xvjf /stage1-sparc-1.1a.tbz2
...
...
...
./bin/uname
./bin/sleep
./bin/tar
./bin/cat
./README.maintainer
(none) / #

We need to set up the system's /etc/resolv.conf so that DNS names can be resolved, which makes it possible to find the download servers.

Note: Obviously you need to put in your own nameserver's IP address. Also, note that the file name here does NOT have a "/" in front of "etc".

(none) gentoo # echo nameserver 192.168.0.4 > etc/resolv.conf
(none) gentoo # chmod 644 etc/resolv.conf

We also need to set up /etc/make.conf, which controls how Gentoo builds the packages which will become your system. The stage-1 image contains this file, we simply need to customize it to match our machine.

Note that this file name also does NOT have a "/" in front of "etc".

(none) gentoo # nano etc/make.conf

The first change is to configure where to get the packages. Either I was using a development version of the CD, or Gentoo has moved their package repository since mastering the CD... anyway. Find the line containing:

SYNC="rsync://cvs.gentoo.org/gentoo-x86-portage"

Change the hostname and directory name to:

SYNC="rsync://rsync.gentoo.org/gentoo-portage"

The other changes tell the compiler what kind of machine you have and what flags need to be in place when compiling the packages. You will see a bunch of commented-out blocks defining CHOST, CFLAGS, and CXXFLAGS. Somewhere in the file we need to add these three lines, but NOT commented out (i.e. no "#" in front of them.)

Note that there should be exactly ONE set of these lines which is NOT commented. Their placement within the file is not really important.

Also note that the "-O3" contains a capital letter "O" after the dash, not a number zero.

CHOST="sparc-unknown-linux-gnu"
CFLAGS="-O3 -pipe"
CXXFLAGS="-O3 -pipe"

Save your changes. We are now ready to start compiling packages.

The documentation I was referring to containted a mount command for /proc at this point, followed by the chroot command which will lock the compiler into what will be our finished system. However, the mount command didn't seem to do anything, and the "makedev" package later on complains about not being able to read /proc/devices to figure out which /dev nodes to create.

Further investigation showed that the intent of the mount command was to have a live /proc filesystem accessible from within the chroot jail. This is the correct sequence of commands to set this up:

(none) / # mount -n -t proc proc proc
(none) gentoo # chroot . bin/bash

We are now running inside the stage-1 environment. The next step is to prepare the linker's cache and download the list of packages.

(none) / # env-update
>>>Note: /etc/make.profile isn't available; an 'emerge sync' will probably fix this.
>>>Regenerating /etc/ld.so.cache...
(none) / # emerge rsync
>>>Note: /etc/make.profile isn't available; an 'emerge sync' will probably fix this.
>>>starting rsync with...

At this point the computer downloads a list of the package installers (not the actual packages) which make up the Gentoo distribution. This took about two minutes over a cable modem.

Watch these messages- the name rsync.gentoo.org actually points to several machines around the world, all of which are mirroring the packages. I happened to hit a mirror in Portugal which sent the first 450K or so and then unexpectedly closed the connection. Running emerge rsync again caused it to choose a different mirror (this time in Germany) and I was able to download the list in full.

When this step completes correctly, you will see a summary of the process- how many files were downloaded, the total bytes downloaded, and so forth.

The next step is to update the build system. The older versions of Gentoo used a file called /etc/make.profile to configure the build process. Newer versions use a set of files inside a directory with the same name.

The stage-1 environment (which was downloaded with "emerge rsync" above) contains a directory pre-configured for the sparc build environment. We need to remove the existing file and make the name into a symlink to the right directory.

...
...
wrote 265621 bytes read 21658407 bytes 78721.82 bytes/sec
total size is 20497010 speedup is 0.93
(none) / # rm etc/make.profile
(none) / # cd etc
(none) etc # ln -s ../usr/portage/profiles/default-sparc64-2.0 make.profile

We can now run the stage-1 script, which does the following:

Note that THIS WILL TAKE A LONG TIME (it took my system nine hours to finish.) When I started this process I went home and went to sleep (well, actually I started typing up this document while catching up on email in another window, and four hours after starting the compile process I went home and went to sleep.)

(none) etc # /usr/portage/scripts/bootstrap.sh

When this process is done, the system is a Stage 2 Gentoo, and we can download and compile the next set of packages. THIS WILL ALSO TAKE A LONG TIME (on my system this took 5 1/2 hours.)

(none) etc # emerge system

When this process is done, the system is a Stage 3 Gentoo, and we can download and compile our kernel. However, before we can build the 64-bit kernel (which the Sun Ultra series uses,) we need to compile and install the 64-bit compiler.

(none) etc # emerge egcs64-sparc

The next step is to get the actual kernel itself. However, because there are problems with the sparc64 kernel available through the Gentoo "portage" system, the document recommends that you download your kernel directly from kernel.org and compile it by hand.

(none) etc # cd /usr/src
(none) src # wget ftp://ftp.kernel.org/pub/linux/kernel/v2.4/linux-2.4.18.tar.bz2
--15:10:24-- ftp://ftp/kernel.org/pub/linux/kernel/v2.4/linux-2.4.18.tar.bz2
    => `linux-2.4.18.tar.bz2'
Resolving ftp.kernel.org... done.
Connecting to ftp.kernel.org[204.152.189.116]:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done.    ==> PWD ... done.
==> TYPE I ... done.  ==> CWD /pub/linux/kernel/v2.4 ... done.
==> PORT ... done.    ==> RETR linux-2.4.18.tar.bz2 ... done.
Length: 24,161,675 (unauthoritative)

100%[================================================>] 24,161,675 212.20K/s ETA 00:00

15:12:16 (212.20KB/s) - `linux-2.4.18.tar.bz2' saved [24161675]

I then expanded the source tree. The documentation tells about using the default configuration by copying arch/sparc64/defconfig to .config and then gives a convoluted sed command to customize the kernel.

Instead of manually doing this, I chose to manually configure the kernel in order to get rid of a lot of extras that my machine doesn't need (i.e. support for Sun SCSI controllers which aren't in my system, support for PCI, IDE, PCMCIA, USB, etc.) and to add modules to support just about every type of filesystem known to mankind (or "linux-kind"... my job involves reading and converting data from several other types of systems and it never hurts to have the modules available to support other filesystem types.)

If you customize your kernel, MAKE SURE TO INCLUDE SUPPORT FOR THE "devfs" AND "tmpfs" FILESYSTEMS. Gentoo's system boot scripts will not work without these two items enabled. When setting the options for "devfs", make sure to enable the "mount the /dev filesystem at boot" option, and disable the "devfs debugging" option.

(none) src # tar xvjf linux-2.4.18.tar.bz2
(none) src # mv linux linux-2.4.18
(none) src # ln -s linux-2.4.18 linux
(none) src # cd linux
(none) linux # cp arch/sparc64/defconfig .
(none) linux # make ARCH=sparc64 menuconfig
(none) linux # make ARCH=sparc64 oldconfig dep vmlinux modules modules_install

The kernel and modules took a little over an hour to build. Once the kernel itself was built, the documentation said to check and make sure it's not bigger than 3.6MB due to a limitation of SILO. I'm not 100% sure what this is about, but it doesn't hurt anything to look.

(none) linux # ls -l vmlinux
-rwxr-xr-x    1 root     root      2385308 Aug 14 23:14 vmlinux

We now need to compress the kernel for SILO, place it where SILO will find it, and set up SILO to be able to boot it.

(none) linux # gzip -c9 vmlinux >vmlinux.gz
(none) linux # cp vmlinux.gz /boot/vmlinuz-2.4.19
(none) linux # cp System.map /boot/System.map-2.4.19
(none) linux # cd /etc
(none) etc # mv silo.conf silo.conf.dist
(none) etc # cp silo.conf.dist silo.conf
(none) etc # nano silo.conf

My finished file contained:
partition = 1
root = /dev/sda1
timeout = 50
image = /boot/vmlinuz-2.4.19
  label = linux

The next step is to run silo to install the boot loader.
(none) etc # /sbin/silo
/etc/silo.conf appears to be valid

At this point the machine should be bootable. Time to try it out.

(none) etc # exit
exit
(none) gentoo # exit
exit
# umount /mnt/root-sparc64/mnt/gentoo
# umount /mnt
#

Eject the CD-ROM, and then press STOP-A.

Type 'go' to resume
ok boot

This should reboot the machine, and when it boots it should boot into your new Gentoo Linux system.

For what it's worth, this is the point where I discovered that Gentoo requires the devfs and tmpfs options in the kernel. Luckily the core system was in place and I was able to manually rebuild the kernel. (Note that I did NOT use clean on the make line this time.)

Press Control-D to continue,
or enter root password for system maintenance:
# mount -n -o remount /
# cd /usr/src/linux
# make menuconfig
# make oldconfig dep vmlinux modules modules_install
# gzip -c9 vmlinux > vmlinux.gz
# cp vmlinux.gz /boot/vmlinuz-2.4.18
# cp System.map /boot/System.map-2.4.18
# exit

The SUN boot monitor takes over and reboots the machine into the new kernel... the problem is now that the kernel's idea of the keyboard is totally wrong... time to boot the rescue kernel (the kernel on the CD is sorta rescue... it at least reads the keyboard correctly.)

Insert CD. STOP-A.

Type 'go' to resume
ok boot cdrom
Boot device: /sbus/SUNW,fas@e,8800000/sd@6,0:f File and args:
SILO -- Welcome to Gentoo SPARC Linux --
boot: vmlinuz root=/dev/sda1
...
...
localhost login:

Here again I tried to log in as root and it wouldn't read the keyboard correctly. In addition, while it booted there was a message complaining about not being able to find /lib/modules/2.4.18/modules.dep.

At this point I did another STOP-A...

Type 'go' to resume
ok sync
...
ok power-off

I waited about thirty seconds and turned the machine back on... it booted right into Gentoo by itself, and now was able to read the keyboard correctly for some reason. Who knows...

Since then, I have started using Aurora Linux on the machine, but this "war story" was too good not to hang on to.


[hacker emblem] Copyright 2002-2003 John M. Simpson <jms1@spamcop.net>
Last updated 2003-07-22