Previous Next Table of Contents

4. How do I get SparcLinux running?

First, make sure you are trying this on a supported architecture! See the previous section for more info on which Sun platforms are currently supported.

4.1 Get the Tools in Place

This is a very rough guide to getting things working:

4.2 How to build a SparcLinux Kernel

(The following was contributed by David Miller.)

There is only a certain build environment that is guarenteed to work at this point for building the kernel from stock snapshot sources. This is:

This is the environment I stick to, mostly to avoid problems when debugging where I have to consider it a posibility that a compiler and/or linker bug could be causing problems. Binutils-2.6 is known to produce improper kernel images if a bug it tickled in the GNU linker. I am working on helping the binutils people fix this bug. Gcc-2.6.3 is just what I use, it hasn't caused me any problems and I have grown to trust it on the Sparc. The kernel build process will absolutly need the bash shell available for the configuration of the kernel to work at all. GNU Make is also mandatory.

There is some leeway however. It is possible to use the recommended compiler and binutils versions under solaris if one is careful and uses Peter Zaitcev's (zaitcev@ithil.mcst.ru) elf2aout utility to convert the kernel at the end. Please contact Peter with specific questions concerning this setup, he has seen much success with it, I do not use it however so I cannot comment unfortunately.

Some advice on the configuration process. I will go over each section, one at a time and explain things. This information is current as of Jan. 19, 1996.

Type make config at the top level of your untarred sources. Note that most of the defaults are very sane for a stock system.

General Setup

Block Devices

Network Options

I will be brief here, basically you want to enable (that is, answer 'y') to only two options in this section of questions, the others you want to disable (answer 'n'). Enable, "TCP/IP networking" and "Drop source routed frames". If you have 16mb of ram or more in your sparcstation you may want to enable "Allow large windows" as it will cause the networking to be more efficient in some circumstances. This option is not recommended for small memory configurations (for example my test box has 8mb of ram, so I don't enable this option).

SCSI Support

If you plan on making filesystems, or using this kernel to boot on an already created ext2 sparclinux setup on one of your scsi drives, you will want to enable scsi support. If not, answer 'n' and make your kernel a bit smaller.

(the following only applies if you answered 'y' to scsi-support)

Network Device Support

Filesystems

Kernel Hacking

Kernel profiling support: Unless you really know what you are doing, answer 'n' here.

Building it

At this point you are done configuring your SparcLinux kernel. Type 'make dep; make clean', this will build the dependencies for the kernel build. When that finishes type 'make vmlinux' and the kernel will be built for you. It will be left under the name:

linux/vmlinux

when the build completes. This is the kernel images you will use to boot with. (note, refer to section above concerning elf2aout program written by Peter if you are doing this under Solaris)

4.3 How to Boot with an NFS root filesystem

Since a couple of versions ago, Linux supports an nfs-based root file system. The easiest way to get it working (Alan has been improving this on the past revisions of the kernel) is to type in your prom command line:

boot le()vmlinux nfsroot=server-ip-address:/root-nfs-dir

Populate your /root-nfs-dir with a nice root directory (/etc, /dev, /tmp, /usr, /bin). A /usr collection is also available on the FTP site (including a Linux/SPARC gcc compiler/libc + some nifty tools (setfont :-)).

You will also need to be able to get your networking information via rarp. I won't go into too much detail here, but you need to add a rarp entry to a rarp capable machine on your network (Linux on an Intel can do this if the kernel is configured for it). It would look something like:

rarp -s IP_OF_SPARC_MACHINE HARDWARE:ADDRESS:OF:SPARC

rarp -s 199.183.24.60 A8:B9:CA:DB:00:50

Then you need to be able to get your kernel image via tftp. You will need to do this on the machine answering your rarp request. Under Linux, tftp is in one of the NetKit packages. Use man tftp to see how to use it. Basically, you need to edit /etc/inetd.conf to enable in.tftpd and limit it to a certain directory. It might look something like this:

tftp    dgram   udp     wait    root    /usr/sbin/tcpd  in.tftpd /tmp/tftp

This is my line from a Red Hat Linux machine. This would mean that the kernel needs to go in /tmp/tftp.

Huge problem here. The tftp from the NetKit on a Linux machine will not work. It forces you to include the entire path to the file, even though it will allow you to restrict the paths. So, even if you let tftp have access to /, tftp wants you to use /filename. You can't request a file this way from the Sun PROM, so this does us no good. To get around it here, we hacked tftpd.c to do a chdir() to the directory specified on the command line. The patch is as follows:


--- NetKit-B-0.06/tftpd/tftpd.c.bad     Sat Feb 24 18:12:48 1996
+++ NetKit-B-0.06/tftpd/tftpd.c Sat Feb 24 18:12:51 1996
@@ -270,19 +270,24 @@
        int     fd;
        char *cp, **dirp;
 
-       if (*filename != '/')
-               return (EACCESS);
+       syslog(LOG_ERR, "tftpd: trying to get file: %s\n", filename);
+
+       if (*filename != '/') {
+               syslog(LOG_ERR, "tftpd: serving file from %s\n", dirs[0]);
+               chdir(dirs[0]);
+       } else {
+               for (dirp = dirs; *dirp; dirp++)
+                       if (strncmp(filename, *dirp, strlen(*dirp)) == 0)
+                               break;
+               if (*dirp==0 && dirp!=dirs)
+                       return (EACCESS);
+       }
        /*
         * prevent tricksters from getting around the directory restrictions
         */
        for (cp = filename + 1; *cp; cp++)
                if(*cp == '.' && strncmp(cp-1, "/../", 4) == 0)
                        return(EACCESS);
-       for (dirp = dirs; *dirp; dirp++)
-               if (strncmp(filename, *dirp, strlen(*dirp)) == 0)
-                       break;
-       if (*dirp==0 && dirp!=dirs)
-               return (EACCESS);
        if (stat(filename, &stbuf) < 0)
                return (errno == ENOENT ? ENOTFOUND : EACCESS);
        if (mode == RRQ) {

Now, what do we name it? The Sun PROM will use rarp to find out it's address, then it will use the machine that answered the rarp request to tftp to and get the kernel. It will look for a file named by a standard convention. The name is the IP address of the sparc in hex with no dots followed by ``.SUN4C'' and in all caps. An example for a machine with IP 194.77.26.181 would be:

C24D1AB5.SUN4C

This is actually just ``vmlinux'' renamed, or it can be the sun boot loader file. If the latter is the case, you can then use the boot loader to load your kernel. Most people will probably just want to load the kernel, however.

Doing all of this will let you get your kernel booted via the network. You will still need a root directory via NFS that should be populated with a minimal set of utils to let your machine boot to a shell prompt.


Previous Next Table of Contents