A Newbie’s Guide to

T. R. Shemanske November 16, 2006

This document is really just a small supplement to very good installation guides for Debian Linux such as http://www.debian.org/releases/woody/installmanual http://www.debian.org/doc/manuals/quick-reference/index.en.html

1 Partitioning your disk

There are many thoughts on the matter, and to some extent the decisions you make depend upon how many users will have accounts on your machine, and to what degree you want the rest of the world to have access to parts of your machine. You need at least a root (/) partition and a swap partition, though I would strongly recommend at least a separate /home partition. The reason for this is that in the event you need to reinstall the (meltdown, whim, whatever), you will no doubt reformat the root partition. With a separate home partition, you will leave untouched all your personal files. • The swap partition is your “virtual memory”. If you have the space, make it twice the number of MB of RAM you have, but no more than 2048M is usually necessary. You can have multiple swap partitions if you do huge number crunching activities. • You need a root partition. If you are cavalier, this can be the only partition you create, though I would recommend against it. Other partitions that you might create are /usr, /var, /home. All of the public software you install goes into /usr. It should therefore be a sizeable partition with respect to the others (5G minimum). One advantage to making /usr its own partition is that you may want to mount it read only (I don’t, but paranoid sysadmins do). /var holds things like print and mail spools, system logs, and TEX fonts created by Metafont as well as postscript fonts, and it is also the temporary repository for all Debian packages when downloading from the Debian mirror. Thus at times there is a large demand for space, while at other times it is underutilized. It needs read/write permissions in general. It should be at least 1G. Then comes /home which contains the home directories of all users who have accounts on your machine. For most setups in which the Linux box is not going to have lots of users, the following might be reasonable.

1 Note your root partition will contain many important directories/mount points in- cluding: /etc (where all the config files are kept), /bin (some system binaries), /boot(kernels and system maps), /lib (among other things all the modules for each kernel), /root (root’s home directory), /sbin (more sensitive sysadmin binaries), /tmp (globally writable temp space). For a 10G drive:

– swap: 1G – /: 1G – /usr: 4G – /var: 1G – /home: 3G

For a 40G drive with only a few users:

– swap: 2G (or multiple 2G partitions) – /: 2G – /usr: 15G – /var: 5G – /home: 15G

If you have lots of users (and user files), you may want to put /usr at 10G and increase /home accordingly.

2 Setting up the Network:

The first thing you need to access is whether you need a fixed IP address, or can get by with a dynamically assigned IP address. In general, you should try to use a dynamic address unless you are providing services: running various servers (e.g. web. print, mail, etc) where a fixed address is important to clients. If your mail is delivered to another machine (BlitzMail or the department mail server), you don’t need a fixed IP address. You should not need to run your own print server (that too routes through the department), and unless you want to run your own web site and not use the department pages, you don’t need a web server. So most workstations can get by just fine with a dynamic IP address. However, if you really need one, you apply for one by filling out the form at http://www.dartmouth.edu/~network/hostmaster.html If you are using a dynamic IP address the networking information will be setup automat- ically by the linux installer program. If you are setting up a fixed IP, you will need a name and some networking information. Once you decide on a name, fill out the form mentioned above, and you will be given the following type of information:

2 • IP address: 129.170.147.xxx

• Netmask: 255.255.255.0

• Network address: 129.170.147.0

• Broadcast address: 129.170.147.255

• Gateway address: 129.170.147.1

In addition, you need the Domain Name server addresses: 129.170.16.4 and 129.170.17.4

3 LILO

To be able to boot multiple operating systems, you need a loader which will load the desired operating system. LILO (LInux LOader) works well. Below is a typical lilo.conf file which I have annotated for some clarity. The reasons for having multiple Linux entries are mentioned below in the section on kernel building.

# /etc/lilo.conf - See: ‘lilo(8)’ and ‘lilo.conf(5)’, # ------‘install-mbr(8)’, ‘/usr/share/doc/lilo/’, # and ‘/usr/share/doc/mbr/’.

# +------+ # | !! Reminder !! | # | | # | Don’t forget to run ‘lilo’ after you make changes to this | # | conffile, ‘/boot/bootmess.txt’, or install a new kernel. The | # | computer will most likely fail to boot if a kernel-image | # | post-install script or you don’t remember to run ‘lilo’. | # | | # +------+

# Enable map compaction: # Tries to merge read requests for adjacent sectors into a single # read request. This drastically reduces load time and keeps the # map smaller. Using ‘compact’ is especially recommended when # booting from a floppy disk. It is disabled here by default # because it doesn’t always work. # # compact

3 # Support LBA for large hard disks. # lba32

# boot=/dev/sda (for the first scsi drive) boot=/dev/hda map=/boot/map install=/boot/boot.b ## Puts up a prompt to choose which OS to boot prompt ## Times out in 5 seconds to the first (default) OS timeout=50 vga=normal default=linux #append="hdd=ide-scsi" image=/vmlinuz label=linux root=/dev/hda2 read-only image=/vmlinuz-2.4.18-pre6 label=linux-2.4.18-p6 root=/dev/hda2 read-only image=/vmlinuz.old label=linux-old root=/dev/hda2 read-only optional

# If you have another OS on this machine to boot, you can uncomment the # following lines, changing the device name on the ‘other’ line to # where your other OS’ partition is. # other=/dev/hda1 label=win table=/dev/hda

4 The format is fairly simple. The image=/vmlinuz refers to a link in your / directory which points to a compressed kernel in /boot. The label is the label by which you want lilo to refer to this kernel, and which you will select at the LILO boot: prompt.

4 X server tidbits

The installer for XFree86 has become much better, but you need to know some information about your video card. Much can be autodetected, but it is worth your while to gather as much information as you can before hand. Most cards are on the PCI bus, and typing lspci will scan the display and give you some information about the devices on the bus. For example, you might see:

01:00.0 VGA compatible controller: nVidia Corporation Riva TnT2 [NV5] (rev 11)

This indicates not only the this is an nVidia Riva TnT2 card, but also that its bus address is “PCI:01:00:0”. If you don’t know, you may be able to find out how much memory the video card has by reading the BIOS messages when the machine first boots. Alternatively, many of these values will be probed and determined by reading the /var/log/XFree86.0.log file. To test X, you will need to install at least the following debian packages:

xserver- xbase-clients xfonts-base xfonts-75pdi

When you install these (in particular xserver-xfree86) you will be asked a series of ques- tions about your video card, and display device. Answer as well as you can, you can always redo it. If you don’t know the name of the driver to use (for example “nv” for the nVidia card), consult the driver status page at http://www.xfree86.org/. To test the configuration type startx from a (root) console. If you get a grey screen with an X that moves with your mouse, you are doing well. Hit CTRL-ALT-BACKSPACE to kill the Xserver. You can read the logs as mentioned above /var/log/XFree86.0.log to look for problems. You might also check root’s home directory for a .xsession-errors file. If the Xserver didn’t start, read the logs. You can try to use the standard configurer for X: /usr/bin/X11/xf86cfg. This will ask you lots of questions about your video card, and monitor specs, but it will provide a little more help. Next you need a (e.g. , , sawfish, etc), and perhaps a session manager (e.g. , ). I am rather a fan of gnome, so I will tell you how to get that going, and you can play from there. Install the packages:

5 gnome-session gnome-terminal -gnome

After they are installed, once again type startx and see whether a gnome-session starts up. If it looks good, go on to add a few more things. If not, . . . . Supposing it went well, hit CTRL-ALT-BACKSPACE to kill the Xserver, and install gdm -engines* gnome-applets gnome-audio gnome-media

The most important package is gdm (gnome display manager) which will (at reboot) start the xserver automatically and put up a login window. You are not by default allowed to log in as root. Log in as yourself and su to root. Now you can play with the desktop configuration. Before you do much else, edit your /.bashrc file and include the line: export XAUTHORITY=’/home//.Xauthority’

You’ll need this to open displays on your machine when you ssh to another machine or even when you su to root.

5 Kernel Building

• Open a terminal and su to root. Install a kernel source package, e.g., apt-get install kernel-source-2.4.18. The tar and bzipped kernel will be in /usr/src. Uncompress the tar ball and you should get a directory called kernel-source-2.4.18. You should be a little careful if you install a kernel from ftp://ftp.us.kernel.org/pub/linux/kernel/v2.4 as it will uncompress into a directory call linux. Usually after uncompressing the kernel-source package you make a symbolic link from the kernel-source directory to linux, that is ln -s kernel-source-2.4.18 linux. The best way to build a kernel is with Debian’s kernel-package (apt-get install kernel-package).

• If you need to patch an existing kernel source, save the patch in /usr/src/, then cd /usr/src/linux and use the command patch -p1 < ../

• Type cd /usr/src/linux

6 • Next you need to configure your kernel. Usually there is a config file (e.g., config- 2.4.17) in /boot from the last installed kernel which you can use as a reference if you get confused. Or even better, steal one from another machine like yours with the newer kernel version.

• Type make xconfig (or make menuconfig or make config). xconfig will require the Debian packages tk and tcl, but it’s a much nicer interface. When the kernel configurator first starts you will see an option to Load Configuration from file. At this point you can grab the older config file. If the config file corresponds to this version, before starting xconfig you can rename this file .config (see the leading dot?) in the /usr/src/linux directory. In either case, this will give you a good starting point. Now you go through and look at the various things that are selected reading through the help options to get a sense of things. Note: building a kernel for the first (or second or third) time can be quite daunting because you know so little of what things really mean. Do I need iptables (of course!) How about Socket Filters? Well, yes especially if you expect DHCP to work. So you see the advantage of starting with something that works. Now the one thing you may need to do is tweak the sound options, perhaps the information about the ethernet card, scsi info, and so on. When you have completed this process, save and exit.

• Type make-kpkg clean

• Type make-kpkg --revision=yourhostname.1.0 kernel image You may end up compiling the kernel several times, especially if you are fussing with something like sound. You can name subsequent updates yourhostname.1.1, yourhostname.1.2, and so on.

• Some older machines have trouble with the bzImage generated. If yours is one of them try make-kpkg --zimage --revision=yourhostname.1.0 kernel image • Your machine will then compile the kernel (hopefully without errors). Depending upon the processor speed, this could take 5 - 30 minutes.

• Next you should make sure that lilo is configured in such a way that you will not be hosed if the new kernel fails to boot (Of course you have a boot floppy for your old system just in case). If you are not sure, look at /etc/lilo.conf to see your current lilo configurations. If you make changes, don’t forget to rerun lilo to write those changes to the boot record. When you install a new version of the kernel, the links in / will change. vmlinuz.old will point to the old kernel, while vmlinuz will point to the newly installed kernel. Thus you need to make sure that you have a vmlinuz.old entry in lilo.conf. More importantly, if you compile and install more than one kernel, vmliunz.old will point to a new (and probably undesirable) kernel. I like to hardwire the label of a working kernel. For example:

– While in / directory, type ln -s /boot/vmlinuz-2.4.17 vmlinuz.2.4.17

7 – Then add an entry in your /etc/lilo.conf file like image=/vmlinuz.2.4.177 label=linux-2.4.17 root=/dev/hda3 (or whatever the correct partition is) read-only

– Then type lilo to update lilo. Now when you reboot and get the lilo prompt, you can always say linux-2.4.17, and you will get your working 2.4.177 kernel.

• Finally you are ready to install you new kernel. Type cd /usr/src. There you should find a Debian package (if for example you compiled kernel 2.4.18) kernel-image-2.4.18 yourhostname.1.0 i386.deb . To install, type dpkg --install kernel-image-2.4.18 yourhostname.1.0 i386.deb. You will be asked if you want to write a new lilo record. Presumably you want to say yes, but if you’re in trouble, say no and you can still boot from your old system (I think). Also, the kernel package asks if you want to write a new boot floppy. This is a great idea. If this feature of the kernel package is broken, make your own boot floppy after you boot the system via lilo.

• That’s it. Hopefully, the new kernel does what it is was supposed to.

6 Sound

Sound can be a real pain to get working. You might first try the package sndconfig which is a RedHat package which autodetects sound cards in many cases. Maybe you will be lucky. You can try the OSS modules in the kernel or the alsa modules which are Debian packages. If you don’t feel like wasting your time, and don’t mind spending $20, then I would suggest http://www.4front-tech.com/linux-x86.html. You can download a demo version which works for a few hours. If you like it, you can pay for it and keep it. If not, you may be able to gain enough information about your card (try cat /dev/sndstat) to figure out what to do with Alsa or OSS.

7 Setting up Network Printers

• Add entries to your /etc/printcap file for each printer you want to use. For example, for EmmyWriter I have added the following:

lp|ew|LaserWriter 16/600 PS in 104 Kemeny Hall:\ :lp=:\ :rm=gauss.dartmouth.edu:\ :rp=ew:\

8 :sd=/var/spool/lpd/ew:\ :mx#0:\ :sh:

• Create corresponding entry in /var/spool/lpd, e.g., mkdir ew. I think that’s it.

8 TeX upgrades and configuration info

When TEXupgrades, you often have to retweak a couple of files. Certainly for a new install, you have to do a few things since the defaults are A4 paper and no postscript fonts. Go to /etc/texmf/dvips. Edit the upmap file so that ps fonts can be used. #type1_default=false type1_default=true Then run the upmap script ./upmap. This regenerates the psfonts.amp file. Now edit config.ps moving the A4 information below the letter information as in @ letterSize 8.5in 11in

@ letter 8.5in 11in @+ %%BeginPaperSize: Letter @+ letter @+ %%EndPaperSize

@ A4size 210mm 297mm @+ %%PaperSize: A4 Next, edit /etc/texmf/pdftex/pdftex.cfg and change the papersize there as well. %page_width 210 true mm %page_height 297 true mm page_width 8.5 true in page_height 11 true in Finally, edit /etc/X11/app-defaults/XDvi changing a4 to us.

9 Useful commands

• lsmod (list kernel modules loaded)

• modprobe (used to install or remove modules)

9 • df -h (How much space is free on my partitions?)

• apt-cache search Find all the debian package containing the word ¡name¿.

• dpkg -l

10 Start up items rc files in /etc 11 Formatting a floppy disk

If you don’t yet have a functional Linux system, use a PC running W95 or even a Mac to format your disks with an MS-DOS file system. If you do have your Linux system up, then proceed as follows. Install the Debian package fdutils. When installed, write a small script named something reasonable like formatfloppy:

#!/bin/sh

superformat /dev/fd0 hd exit 0

Insert your unformatted floppy into the drive and execute the script. The first time you do this will take a while as superformat will determine the characteristics of your drive. It will then tell you to create or modify the file /etc/driveprm to reflect these parameters. At this point you will have an MSDOS file system on the floppy. If you then want another file system (say ext2), just run mke2fs on /dev/fd0 using the preformatted floppy.

12 Boot Floppies

I know of three ways to make a boot floppy:

• First decide from which kernel you want to boot. That means look in /boot. You should see at least one compressed kernel, e.g. vmlinuz-2.4.18.

• Method 1: Install the package debianutils (probably already installed). Issue the command mkboot /boot/vmlinuz-2.4.18 /dev/fd0

• Method 2: You may be able to boot off your rescue disk/CD, and elect the create boot floppy option from the menu. Presumably, it copies /vmlinuz which is a link to a kernel in /boot.

10 • Method 3: The easiest way that I have been told to make a boot floppy for any Linux file system on your hard drive follows. Insert a preformatted (DOS or EXT2) floppy disk into your drive, and type cat /boot/vmlinuz-2.4.18 > /dev/fd0. Now you are safe. Of course, you could be paranoid and test to make sure it really does boot your system before doing anything drastic.

11