LINUXKNOW-HOW USER SchlagwortLinux on sollteSPARC hier stehen

Putting on a Sun SPARC machine THE SPARC DIFFERENCE

We all know Linux works smoothly on PCs, but the PC’s x86 archictecture is just one of a range of platforms Linux supports. This article gives you a head start with setting up Linux on a Sun SPARC machine. BY ARMIJN HEMEL

uring the .com era, nearly every and you’ll find lots of SPARCstation 10 •Debian GNU/Linux: the longest living company was running on Sun and 20 available, for exam- SPARC distribution Dsystems, and the Sun SPARC ple, on eBay. There is also a good chance •Gentoo platform was also a big part of the mar- people in your local LUG or university • Splack: Slackware for SPARC. ket share in academia. This abundance might have old Sun machines they want All these distributions come with man- of SPARC machines means you can pick to get rid of. agement tools that are also available on up a SPARC for not much money – you The (32-bit) SPARC was one of the x86 (RPM and yum for Aurora, apt for might even have an under-used SPARC first (if not the first) platform Linux was Debian, portage for Gentoo, pkgtools for sitting around your office. ported to after x86. Various vendors, Splack). In addition to the distributions I Linux has supported the SPARC plat- such as Red Hat, used to have boxed sets just mentioned, a few smaller distribu- form for many years, and SPARC is still with CDs for SPARC systems about 6 tions also support SPARC. one of the most popular alternative plat- years ago, but the market share of Linux forms for Linux. In many ways, Linux on on SPARC has never been big. The com- INFO a SPARC is very similar to Linux on a PC, mercial distributions quickly ceased [1] Sun systems overview: but if you want your SPARC installation development, because it simply was not http://sunsolve.sun.com/handbook_ to go smoothly, there are some differ- financially viable to maintain a separate pub/Systems/ ences you should keep in mind. This version for SPARC. Nowadays all the [2] SPARC CPU names guide: article describes some SPARC systems major distributions for SPARC are com- http://www.sparcproductdirectory. that work with Linux, some Linux sys- munity driven. com/sparccpu.html tems that work with SPARC, and some Popular SPARC Linux distributions [3] Aurora Linux Hardware Compatibility: details you’ll need to know if you’re include: http://auroralinux.org/cgi-bin/wiki. putting Linux on a Sun. •Aurora Linux: the first versions were pl?HardwareCompatibility based on Red Hat 7.3, but work is [4] SILO bootloader: Linux and SPARC being done to bring the current ver- http://www.sparc-boot.org/ Sun hardware isn’t that hard to get (see sion into sync with the latest Fedora [5] Wikipedia pages about byte endian- “Box 2: Finding a Sun machine.”). The Core release and eventually merge it ness: http://en.wikipedia.org/wiki/ Sun SPARCstation series sold really well, into Fedora Core. Endianness

56 ISSUE 54 MAY 2005 WWW.LINUX- MAGAZINE.COM Linux on SPARC KNOW-HOW

The oldest of the SPARC machines, sun4, kering, and Linux will most probably not A disk in a SPARC system is a bit dif- is largely unsupported by Linux. Later work on them anyway, although there ferent. There can be 8 partitions in total SPARCs are supported with varying are reports that Linux boots on some on a disk. The third partition represents degrees of success. Some machines only mid-range servers, such as the Enter- the whole disk. There are also some work reliably in uniprocessor mode and prise 4500. restrictions with respect to the layout, not in SMP mode. For some machines, such as that a partition that uses its first different subtypes are not supported, for Installing Linux on SPARC sector (such as swap) should not start at example, the SPARCstation 5 with a 170 We tested Aurora SPARC Linux on an disk cylinder 0 because it will destroy MHz CPU is not supported, whereas Ultra 10 machine. The Ultra 10 has IDE the disk label. Furthermore, if you want other SPARCstation 5 machines are sup- disks and a PCI bus, with an UltraSPARC ported. The reason for this is that the IIi CPU, and it is very well supported by Box 1: Endianness 170 Mhz used a CPU from another man- Linux. The Aurora install isn’t that much All SPARC chips are big endian, whereas ufacturer. more difficult than Red Hat on a “nor- x86 CPUs are little endian. On big endian A lot of the current development is mal” PC, as the installer does a lot of the systems, the most significant byte is done on newer UltraSPARC desktop nasty work for you. But there are some stored first. On little endian systems the machines with PCI. Because of this, the fundamental differences between the least significant byte is stored first. In 32-bit SPARC machines and SBus-based two architectures you should know some cases, this might be an issue; for UltraSPARC machines sometimes lag a about when things go awry. example, with programs that use a spe- bit. New kernels don’t always want to One of the differences between a Sun cial binary format for datafiles. Some run properly on these machines, and it machine and a normal PC is the way programs expect their data to be in takes a few kernel versions to fix the harddisks are partitioned. A PC system some specific byte order. The cases are problems. can have up to 4 primary partitions on a pretty rare – I have only seen a few cases of it, mainly with old MacOS programs, The high-end servers are too expen- disk, one of which can be an extended such as MacWrite II – but it can happen. sive and generally not available for tin- partition with more logical partitions in it.

Box 2: Finding a Sun machine

Not every Sun machine has a SPARC FibreChannel and hot-swappable PCI, UltraSPARC clones, such as Solair and chip inside. Sun machines up until ver- but moved to PC technology on the Tadpole. These machines are identical to sion 4 were based on Motorola’s 68000 market. The Ultra 5 and Ultra normal Sun machines on the inside. chips, and there were a few machines 10 desktop machines were the first Often you will see references to things with Intel 386 chips as well. If you want machines that commercially shipped like sparcv8 or sparc64. The former to run a free on the with a PCI bus, IDE disks, and VGA con- describes the version of the SPARC archi- Motorola machines, NetBSD would be nectors (either onboard or as an expan- tecture. There are 3 versions that can be your best choice, with either the sun2 or sion card). found in the wild: sun3 port. These machines are from the Since 1996, the UltraSPARC chip has •sparcv7: version 7 of the SPARC archi- 1980s and are quite useless by today’s been used in almost all machines, with tecture, 32 bits standards. Sun has also shipped x86 the notable exception of various incarna- •sparcv8: version 8 of the SPARC archi- chips in their Cobalt machines and has tions of the JavaStation, Sun’s failed thin tecture, 32 bits recently started using AMD Opteron client. The JavaStation used a SPARC •sparcv9: version 9 of the SPARC archi- chips for servers and workstations. chip on a board with PC components (PC tecture, 64 bits The SPARC chip has been used since memory, PCI bus). Newer versions have more possibilities 1987, when Sun introduced version 4 of To make things even more interesting, that a program can take advantage of their machines. Version 4 became know not every SPARC chip is made by Sun. during run time. Most Linux distributions as “Sun4.” Some of the Sun4 subtypes The SPARC standards are maintained by compile for sparcv7, but for some pack- are shown in Table 1. a separate company, SPARC Interna- ages, in particular openssl, it is benificial The first generation of Sun4 machines tional. The standards are freely down- to use special optimization flags during used the VMEbus, which was also used loadable and can be implemented with- compilation. Some distributions, like in Motorola-based Sun . Later, out having to pay royalties to SPARC Aurora, ship special precompiled pack- Sun switched to the SBus bus, which International or Sun. There is a SPARCv8 ages for openssl for sparcv8 and was used in all subsequent SPARC certified chip designed at ESA that has a sparcv9. machines. Quite a few machines also design released under the LGPL. Designs have MBus slots, which can be used to for this chip, called LEON SPARC, can be Terms like sparc32 and sparc64 do not add extra CPUs to the machine. downloaded from http://www.gaisler. describe chips in particular but, instead, describe environments. Early UltraSPARC-based computers, com/. such as the and 1e and the Ultra In Japan, Fujitsu has made its own •sparc32: a 32-bit SPARC environment 2, used SBus for connecting expansion SPARC and UltraSPARC versions. •sparc64: a 64-bit SPARC environment cards, Sun specific memory and SCA Recently, Sun and Fujitsu made a deal It is quite normal to have a sparc32 envi- disks. Sun stayed with these technolo- about cooperating on designing future ronment running on a 64-bit SPARC chip. gies for most servers, with new high-end versions of their SPARC chips. There are In fact, this is the default for most Linux servers also using new technologies like also a few companies that have made distributions.

WWW.LINUX- MAGAZINE.COM ISSUE 54 MAY 2005 57 KNOW-HOW Linux on SPARC

to transplant a hard disk from a Linux (SILO) is used. SILO has support to boot If you need an alternative that is truly PC and use it in a Linux SPARC machine Solaris, SunOS, and Linux from disk. A open, it’s worth considering the BSD with all data intact, you should make variant of SILO called TILO for network variants. NetBSD has had SPARC support sure the kernel can handle PC disk booting. SILO is like GRUB in that it for a long time. OpenBSD has excellent labels, because PC disk labels might not knows the layout of some filesystems SPARC support. A lot of OpenBSD work by default. and, unlke LILO, it doesn’t need to be development is done on UltraSPARC Listing 1 shows a sample disk configu- reinstalled after a change to the configu- machines. Newer UltraSPARC III ration for a SPARC Linux system. ration. Configuration of SILO can be a machines are not supported by If you want to boot Linux from CD on bit tricky, but the manual is very clear. OpenBSD due to Sun’s unwillingness to a system that has SCSI, such as an Ultra make specifications available under 1, you have to make sure the CD player Alternatives acceptable licensing terms. can handle a blocksize of 512 bytes. The If you don’t want to run Linux on a The FreeBSD port to SPARC is pretty default for most CD players is to have a SPARC machine, there are various alter- recent. The developers only target Ultra- blocksize of 1k. On a good SCSI CD natives. Of course, you can use Solaris. SPARC machines, not the 32-bit SPARC player, the blocksize can be set with a Sun will release Solaris 10 under a machines. Not all machines work. and jumper. license (CDDL) that is, depending on support for things like graphics cards is The installation of Linux is completely who you talk to, open. not complete yet. ■ transparant for machines like the Ultra 10. For older machines with SBus or a Table 1: Sun4 Subtypes 32-bit chip, the situation can be differ- Machine type Bits Bus Machines (incomplete) ent. Before you install Linux, you should sun4 32 VMEbus Sun-4 check with your distributor regarding sun4c 32 SBus SPARCstation SLC/ELC/IPC/IPX/1/2 which hardware actually is supported. A 32 SBus SPARCcenter SPARCserver good starting point is Aurora’s hardware compatibility list. sun4m 32 SBus SPARCstation 4/5/10/20; SPARCstation LX/ZX/Voyager; SPARCclassic The Boot Process sun4u 64 SBus/PCI Ultra; Blade; Enterprise; Fire; Fujitsu SPARC64 A big difference between the PC and SPARC platform is the booting proce- Listing 1: SPARC Linux Disk Configuration dure. The PC uses a very simple BIOS to 01 Disk /dev/hda (Sun disk label): 16 heads, 63 sectors, 17660 initialize hardware, find the bootloader cylinders and start it. On SPARC machines the 02 Units = cylinders of 1008 * 512 bytes OpenBoot PROM (OBP) is used. OBP 03 Device Flag Start End Blocks Id System offers a very rich set of commands for booting a kernel (disk, tape, cd, net- 04 /dev/hda1 0 102 51408 1 Boot work), as well as a lot of diagnostics 05 /dev/hda2 102 16620 8325072 83 Linux native commands. 06 /dev/hda3 0 17660 8900640 5 Whole disk To boot Linux, a special bootloader 07 /dev/hda4 16620 17660 524160 8 Linux swap called SPARC Improved boot LOader

Box 3: 64-bit Architecture

One of the more interesting parts of the should not worry too much about this the size of pointers. On 32-bit systems, UltraSPARC architecture is the ability to and just use the vendor supplied utilities. such as the PC, the size of a pointer in C/ run 64-bit binaries. Like a lot of 64-bit In a lot of documentation about Linux on C++ is defined as 32 bits. The size of an architectures, it is not completely pure, UltraSPARC, you will see that you need integer value is 32 bits as well. Quite because UltraSPARC can run 32-bit the special “egcs64” compiler for com- often, integers are used in the place of SPARC binaries as well. This was done piling the kernel. Nowadays this is no pointers. Even though this is not correct, on purpose, so Sun customers would longer true; you can just use a recent the C compiler only warns about it and still be able to run old 32-bit binaries on GCC. As a user, you don’t need to speci- does not report it as an error. new 64-bit computers. fiy any special switches. The kernel con- On 64-bit platforms, it is a different story. figuration process takes care of choosing So far, Linux on UltraSPARC has been a Pointers are 64 bit, while integers are still the right compiler for you. hybrid of 64-bit and 32-bit. The kernel is 32 bit. Assigning a 64 bit pointer to a 32 completely 64 bit, but userland is usually Some user applications will not benefit bit integer will essentially chop off the 32 32 bit. This split also has some conse- from being compiled as 64 bit binaries – most significant bits, which can lead to quences for the toolchains (e.g., gcc plus they may in fact become slower – but “interesting” results. binutils) used for compiling programs, as there is another reason you may want to Most distributions only install the 32-bit you have to be able to compile both 32- try a 64-bit userland on Linux: portability. userland environment by default, but the bit and 64-bit binaries. Unless you are 64-bit has some rules that are different 64-bit environment is often available as making your own distribution, you from the rules of 32 bit mode, especially an add-on package.

58 ISSUE 54 MAY 2005 WWW.LINUX- MAGAZINE.COM