---------------------------------------- LRP Hard Disk HOWTO ---------------------------------------- Written by: Charles Steinkuehler Version: 1.4 Last Revised: 03/30/2001 Revision History: 1.4: Added section on running LRP with root on a HDD partition 1.3: Fixed several typo's & spelling errors Added comments about using extended format (ie 1680K) LRP disks Expanded the booting LRP from a HDD section Changed to GNU Documentation license Added details on using a SCSI RAID array 1.2: Added procedure for using Win 95/98 boot disks Released under GNU General Public License 1.1: Added warnings re windows 95/98 boot disk & syslinux Some minor text clarifications & updates 1.0: Initial release License: Copyright (c) 2000 Charles Steinkuehler Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license may be found at: http://www.gnu.org/copyleft/fdl.txt Disclaimers: I am attempting to document some of the things I have done with my Materhorn LRP package, so you don't have to learn everything the hard way. While I have tried to explain things so most anyone can understand how to do this, I cannot be responsible if you accidentally format, partition, or otherwise destroy any data you might have on your hard disk, or even if you just wind up wasting an evening or weekend trying to get things working. It is assumed you are smart enough to adapt some of the commands to your particular environment. For example, if this HOWTO says to perform the command: insmod /lib/modules/mymodule.o and you are trying to load support for your Adaptec SCSI card, you would actually type something like: insmod /lib/modules/aic7xxx.o It is further assumed that you know the basics of setting up hard disks on a PC, and that you are familiar with concepts like disk partitions, linux device numbering, mount points, and other such basic linux concepts. If you don't understand any of these things, try to track down some HOWTOs, or read through the first couple of chapters of a linux users guide or installation manual. Most of these will cover linux device numbering and hard disk partitioning enough for you to get through this HOWTO. WARNING: Adding a hard disk, or any other storage media that cannot be physically write protected fundamentally makes your LRP system less secure. In addition to a hacker being able to store data across a reboot, you will be running more software, in the form of device drivers and file system support, than a basic LRP system. While this software is fairly safe in the general scheme of things, every additional piece of code you run has the potential of adding security holes to your system. It is up to you to determine if the risk is worth the reward in your system and setup. Conventions: For clarity, commands you should type in, filenames, screen output, and other such items are either on their own line: Like this or enclosed in single quotes 'Like this'. You should not type in the single quotes when entering commands or filenames, or expect them to be on screen output. ---------------------------------------- Useful LRP related links: http://lrp.steinkuehler.net/ http://www.c0wz.com/ http://linuxrouter.sourceforge.net/ http://www.linuxrouter.org/ http://beta-linuxrouter.razorsedge.com/ http://lrp.plain.co.nz/ http://wpkgate.kc.com.my.cpwright.com/lrp/ The basics: Method 1: Booting LRP from a hard disk Method 2: Mounting a Hard Disk at runtime Adding a kernel module: Advanced Procedures: Using SCSI/RAID or other devices ---------------------------------------- The basics: ---------------------------------------- This HOWTO goes over two ways to use a hard disk with your LRP system. The first method replaces the boot floppy with a small MSDOS partition. This give you the space to load all those LRP packages you have been drooling over and makes your system boot much faster, but LRP still runs entirely out of the ramdisk once it is booted. The second method is for mounting a hard disk partition to be used by LRP when it is running. You might want to do this to store web pages, run a small e-mail server, or other functions that really require a fair amount of online storage to run. Both methods fundamentally make your system less secure than booting from a write protected floppy, but this might be an acceptable trade off for you. I would suggest keeping your primary internet access point a simple router that boots from a floppy, but using LRP for a small web/ftp/dns/mail server is probably more secure for most folks than trying to strip down one of the standard distributions (which load up your disk with a few hundred megs of junk hackers can use to exploit your system), and has the benefit of not having to learn the quirks of a new distribution if you are already running LRP. Note that you can use the two methods together, so you could boot off a hard disk, and then mount a (separate) partition that might contain web data, or be a storage area for a mail server. ---------------------------------------- Method 1: Booting LRP from a hard disk ---------------------------------------- This is really very easy, so if you've been itching to use that spare HDD in your LRP box, let's get going. BEFORE YOU GET STARTED: You will need a few things, so try to track them all down before you get started. I have tried to collect most of the files needed on my web site at http://lrp.steinkuehler.net 1) A hard disk and controller (duh). Just about any size drive will work here, remember, you were using a 1.44M floppy, so even an old 50 Meg drive will seem HUGE. NOTE: This document assumes you will be using an IDE hard disk. While it is possible to use a scsi disk and controller, or other device (like a flash disk), anything but IDE will require you to add 'bootstrap' module support to LRP, which is described below in the section on using SCSI hard disks. NOTE: You can use just about any IDE device (zip, LS120, etc), as long as it can be made to look like drive C: to dos (and the BIOS in your computer). 2) A DOS boot disk (floppy), you can also use a windows 95/98 boot (startup) disk. 3) Copies of the DOS fdisk and format commands on floppy, and a DOS based editor you know how to use that does not 'wrap' long lines. TODO: Insert good editor choices here 4) A copy of the syslinux.com program on a floppy disk. You can find this at some of the LRP sites listed above, or get the latest version at http://www.kernel.org/pub/linux/utils/boot/syslinux/ 5) A disk image for the version of LRP you want to run, copied onto a floppy. 6) An LRP kernel with IDE support compiled in. You should be able to find this at one of the LRP sites listed above if you are using a standard distribution. If you wish to boot of a device that does not have kernel support built-in (ie anything other than an IDE or floppy disk), this is still possible. See the section on SCSI drives, below. NOTE: All of the above files need to be on floppy disks, so you can access them on your LRP machine. GETTING STARTED: It is assumed at this point that you have properly assembled the LRP machine you are running on, and set up the BIOS to properly recognize your hard disk. Partition and Format your hard disk: NOTE: If you plan on mounting partitions on your hard disk after boot, rather than just booting from the hard drive, I suggest you partition your disk using linux instead of DOS, as you will have MUCH more control over the partition types, numbering, etc. See "MAKING A PARTITION" in the section: "Mounting a Hard Disk at runtime" for some information on using the linux fdisk instead of DOS based fdisk. If all you want to do right now is boot LRP, using DOS for partitioning is probably easier for most folks than the linux alternative. 1) Boot your LRP machine from the DOS disk. 2) If you are running from a windows 95/98 startup disk, you have to run 'lock' to allow low-level access to the hard drive. If you do not do this, syslinux will be unable to install the boot loader on the hard disk, and you will be unable to boot. You can skip this step if you are running a 'real' version of dos instead of a windows startup disk. 3) Run the fdisk program. You should delete any partitions that already exist (unless you really know what you are doing) to avoid confusion regarding device numbers. !!-WARNING-!! This will destroy any data currently on the hard disk! 4) Create a 'primary dos partition for LRP. I make mine about 10-20 Meg, which seems big enough. 5) Mark the partition as 'active', or 'boot' 6) If required, save the changes to disk 7) Exit fdisk, you machine should reboot from the DOS disk 8) Run 'format c:' to format the new partition At this point, you should have a working MSDOS drive c: You should be able to do a 'dir c:' command, and see an empty directory with lots of free space. INSTALLING THE SOFTWARE: Now it's time to put LRP on your freshly made partition. 1) Put the disk with syslinux.com in the drive (if it's not on your DOS boot disk) 2) Run 'syslinux -s c:' to install the syslinux bootloader 3) Put your LRP boot disk into the drive. WARNING: DOS will only recognize 1.44 Meg floppy disks. If your LRP system is on a 1.68 Meg or other non-standard size floppy, you will either have to copy the files to a 1.44 meg disk so dos can access them, or copy the files to your hard disk using LRP (which can access the high-density formats) instead of dos. 4) Copy all the files except for 'ldlinux.sys', which is already on your hard disk. 5) Delete the file 'linux' from the hard disk (or just rename it if you want to start wasting all that space you've got now :-). This is the old linux kernel without hard disk support. 6) Copy the new kernel you downloaded that has IDE support compiled in onto the hard disk. Rename it 'linux' if it is not named that already. You now have installed LRP onto your hard disk, but don't try to reboot yet! LRP is still set up to look for the LRP files on the floppy disk. CONFIGURING THE SOFTWARE: You need to know the partition you installed LRP onto for this step. This is almost always /dev/hda1, which is used in the text, but could be something else. If /dev/hda1 doesn't work for you, try to find the 'partition check:' part of the kernel messages that spit out on boot. If it scrolled by, you can press and keys to scroll through the messages 'above' the screen. On the line(s) after 'partition check:' the kernel will list all valid partitions it sees on the various hard drives you have attached. One of them should be where you installed LRP. 1) From a dos prompt, edit the file c:\syslinux.cfg 2) Change 'boot=/dev/fd0,msdos' to 'boot=/dev/hda1,msdos' 3) You might also want to make your ramdisk a bit larger, especially if you plan on using all your new HDD space to load lots of LRP modules. To do this, change the 'ramdisk_size=xxxx' parameter. Note that xxxx is the size of the ramdisk in K bytes (ie 'ramdisk_size=4096' is a 4 Meg ramdisk). 4) Make sure that your editor does not 'wrap' or truncate the line. Everything from 'append=' on should be on a single line, with no carriage returns or line feeds. 5) Save the file You are now ready to boot LRP from your hard disk! BOOTING FROM THE HARD DRIVE: It's time to cross your fingers and watch LRP boot from the hard disk. 1) Remove any floppies from the disk drive. 2) Press or toggle the power to reboot 3) LRP should boot, and you should see the familiar login: prompt. If you don't get to the login prompt, something went wrong. See below for some trouble-shooting ideas. NOTE: If you had custom boot software on your HDD previously (like LILO, system commander, etc), you may have to replace the Master Boot Record (the MBR) on your hard disk so your system will boot 'normally'. You can typically do this with the DOS command 'fdisk /mbr' (an un-documented command line switch), but it depends on which version of DOS and fdisk you're running. The /mbr switch seems to work with Win 95/98 boot (aka startup) disks, as well as the actual MS-DOS fdisk. SOMETHING WENT WRONG: Oh No! Your new LRP hard disk is a high-tech paperweight...LRP refuses to boot. Here are a few things to check: 1) Make sure you have an LRP kernel that has IDE support compiled into the kernel. If your kernel has IDE support, you should see a message like the following sometime during the boot sequence, followed by a message for hda (or hdb-hdd), listing the drive type and parameters. ide0 at 0x1f0-0x1f7,0x3f6 on IRQ 14 2) If the kernel has IDE support, look for the partition check: line in the kernel boot messages. Following this line the kernel displays all valid partitions on your hard disk. Try using each partition listed as the boot device in syslinux.cfg...one of them should work. 3) Make sure you copied the LRP files from a valid boot disk. Try booting the LRP floppy in your machine. If this doesn't work, you will probably not be able to get HDD booting until you fix whatever the problem is. 4) If you are really stuck, try getting plain old DOS to boot from the hard disk. If this doesn't work, you have something basic wrong with your BIOS, hard disk, MBR, partitioning, etc. Once you can get DOS booting, syslinux should run without problems. Make sure you have a clean MBR and the partition you want to boot is marked active. You can install a new MBR from dos with the command 'fdisk /mbr' MIGRATING FILES FROM AN EXTENDED CAPACITY FLOPPY DISK: If your LRP system is currently using a non-standard format (like 1.68 Meg), you may need to copy them to a 1.44 Meg disk so you can get them on your hard disk with dos. There are other ways to do this, including copying the files directly from LRP. If you're enough of a guru to know how to do this, feel free to get the LRP files on your boot partition using whatever method you feel is most convenient. 1) Get two 1.44 Meg blank formatted floppies. 2) Boot your LRP system from the floppy disk. 3) Mount the LRP floppy disk. Be sure to use the correct device. Most LRP systems have a /dev/boot device that is the format of your boot floppy, but you may have to use an explicit device, like /dev/fd0u1680): mount -t msdos /dev/boot /mnt 4) Clear the /tmp directory: rm /tmp/* 5) Copy all files from the floppy disk to /tmp: cp /mnt/* /tmp/ 6) Unmount the floppy: umount /mnt 7) Remove the LRP disk, and insert one of the blank 1.44 Meg disks. 8) Mount the disk and copy root.lrp: mount -t msdos /dev/fd0 /mnt cp /tmp/root.lrp /mnt/ 9) unmount the floppy: umount /mnt 10) Delete root.lrp and ldlinux.sys from the /tmp directory: rm /tmp/root.lrp /tmp/ldlinux.sys 11) Insert the second 1.44 meg disk, mount it, and copy the rest of the files: mount -t msdos /dev/fd0 /mnt cp /tmp/* /mnt/ umount /mnt 12) Use the two 1.44 Meg floppies in the above steps when copying files to your hard disk. ---------------------------------------- Method 2: Mounting a Hard Disk at runtime ---------------------------------------- This is a little more complicated than booting off a hard disk, but it's not too hard if you're familiar with computers in general. Even if you're a linux hard disk wizard, you should read through the procedures as there are some steps peculiar to LRP. BEFORE YOU GET STARTED: You will need a few things, so try to track them all down before you get started. For your convenience, I have put most of the files (for standard IDE support) on my web site: http://lrp.steinkuehler.net/Packages/HardDisk.htm 1) A hard disk and controller (duh). See previous section for details. 2) A working LRP system with the hard disk and controller installed 3) A set of linux hard disk utilities for your version of LRP. I run the Materhorn version of LRP, and used the hdsupp.lrp package available at the Materhorn site under packages. 4) Kernel support for your disk controller. This can be in the form of a loadable module, or can be compiled in to the kernel. If you are using IDE, you should be able to find a kernel with support compiled in available from some of the LRP links, above. If you are using SCSI, you will need the loadable module for your controller, as well as the kernel scsi modules (scsi_mod.o and sd_mod.o at a minimum). 5) The ext2.o kernel module for your LRP kernel version. This should be available from the same place you got the IDE support module or kernel, above. 6) (optional) The hdsupp_s.lrp package, which is used to check ext2 data partitions at boot time (and doesn't include the disk formatting utilities for size/security reasons). This is available at the Materhorn site as well. GETTING STARTED: It is assumed at this point that your LRP machine is running and properly configured, and you have your hard disk and controller physically installed. If this is not the case, stop here and fix whatever is wrong. Add support to LRP for your disk controller: If you want to boot LRP from your hard disk, go through the previous method (Booting LRP from a hard disk) first, and you can skip this step. If you are using an IDE drive, or compiled a kernel with your hard disk driver included, follow procedure A, Replacing the kernel. If you want to use a loadable kernel module driver for your hard disk controller, follow procedure B, Adding a kernel module. A) Replacing the kernel: If plan to use a kernel with compiled in support for your disk controller (this is most likely the case if you are using an IDE controller), you just need to replace the linux kernel on your boot device with the new kernel that includes support for your controller. 1) Delete the kernel (it should be named 'linux') from your boot disk (note: You might want to make a copy first, in case something goes wrong) 2) Copy the kernel with hard disk support to the file 'linux' on your boot disk. From your windows command line, you would type something like this: copy my-downloaded-kernel a:\linux 3) Reboot your linux system to enable hard disk support B) Adding a kernel module: 1) Follow the 'adding a kernel module' procedure below to add your drive controller module to the system. You might want to combine this step with the next one, and add the ext2.o module at the same time. 2) Make sure you backed up the modules package 3) Make sure the module is loaded by either rebooting or manually loading the module. If you load the module by hand, make sure to watch carefully on the next reboot to make sure it is being correctly loaded automatically. Adding support for the ext2 file system: 1) Follow the adding a kernel module procedure below to add ext2.o to your LRP system. 2) Make sure you backed up the modules package 3) Make sure the module is loaded by either rebooting or manually loading the module. If you load the module by hand, make sure to watch carefully on the next reboot to make sure it is being correctly loaded automatically. Adding the HDD tools to your LRP environment: You now have all the software in place to get LRP to talk to your hard disk, but you will need some tools to create and format partitions. If you are a linux drive guru, you can partition and format your hard disk on a full linux machine, and skip down to the 'USING YOUR HARD DRIVE' section. Data partitions should be type 83, linux native, formatted with ext2. Swap partitions should be type 82, linux swap. Don't forget to format the swap partition with mkswap. IMPORTANT: While it might be tempting to put the hard disk support package on your boot device, especially if you are booting off a hard disk, I strongly advise against it. They are just taking up space 99% of the time, they easily fit on a floppy, and you don't want tools that could destroy your entire drive in a heartbeat sitting around for a hacker to use if your system ever gets broken into. 1) Mount the floppy disk with the hdsupp.lrp (or equivalent) package: mount -t msdos /dev/fd0 /mnt 2) cd to the floppy disk cd /mnt 3) Load the LRP package. IMPORTANT: The LRP file needs to be in the current directory, and you should omit the '.lrp' from the filename lrpkg -i hdsupp 4) cd out of the floppy disk mount directory (so it can be unmounted), and unmount the floppy: cd / umount /mnt MAKING A PARTITION: It is assumed in the following that you know enough about hard drive partitions, and linux device and partition numbering schemes to adjust the procedures for your particular system. You might want to read the partition mini-HOWTO, available at: http://www.linuxdoc.org/HOWTO/mini/Partition.html I have also found the O'Reilly books "Running Linux" and "Linux in a Nutshell" to be excellent references. Note that since LRP runs from a ramdisk mounted as root, and is not really intended to be used as a workstation, most of the partitioning schemes in the various linux install guides are not really appropriate, but the basic concepts are still the same. I boot my LRP system with a hard disk off a small primary partition, added a primary swap partition just for grins, and put all data into extended partitions. This works for me. Your mileage may vary. 1) Run fdisk to create a partition: fdisk /dev/hda 2) Type 'p' to see a list of partitions. If you are booting off this disk, there should be a small DOS partition defined. It's device will probably be '/dev/hda1', and will match whatever you had to enter in syslinux.cfg to get your system to boot. MAKE SURE YOU DO NOT DELETE THIS PARTITION. 3) If there is nothing on the disk you need to save, you should delete any partitions that are already defined, using the 'd' command. 4) Verify you have deleted all the partitions you don't need, and you did not delete any partitions you wanted to keep. If you accidentally delete a partition you didn't mean to, don't panic, just quit 'q', and run fdisk again. No changes are saved to disk until you explicitly command the partition table be written out. 4) Use the 'n' command to create an extended partition 5) Select the partition type you want. I suggest creating an extended partition (e). 6) Select the partition table entry to use for this partition. This can be any number from 1-4 that does not appear in the partition list. The software will prevent you from using an entry that is already defined. If this happens, just start over at step 4 with the 'n' command. 7) Enter the starting cylinder for the extended partition. The default is usually OK here. 8) Enter the ending cylinder or size of the extended partition. The default will be as big as possible. 9) Use the 'n' command to create a logical partition. If you created a primary partition in the step above, you can skip to step 12. 10) Select the 'logical' partition type (l) 11) Enter the starting cylinder, and ending cylinder or size you want for your partition. 12) Type 'p' again to see a partition list. Examine this closely to see if it is what you want/expect. Verify the type of your data partitions is 83 (linux native). 13) If you are planning on using a swap partition, make sure it is type 82 (linux swap). You can change partition types with the 't' command. 14) List the partitions using 'p', and make extra doubly sure that everything is correct, especially if there is data on the drive you don't want destroyed. 15) Jot down the partition info, and tuck it into the notebook you keep of all your LRP system settings. Make note of the device settings and fill in the use or mount point in your system. My list looks like this: Device Size Use /mountpoint /dev/hda1 20.2 Meg MSDOS LRP Boot partition /dev/hda2 32.2 Meg Linux Swap partition /dev/hda3 274.5 Meg Extended partition /dev/hda5 100.1 Meg /storage As you can see, I have some spare space in my extended partition for future needs, and I even have a spare primary partition left (#4) in case I need it for something. 15) Save the changes and exit using the 'w' command. 16) Reboot so linux can see your changes. I'm sure there's a way around rebooting, but I don't know what it is. FORMATTING THE PARTITION: Now you have to format the partitions so they can be used by LRP. VERY IMPORTANT: Do not blindly type in the devices listed below, but replace them with the devices appropriate to your system! The devices listed match my disk setup, which is listed above. If you are even a little bit unsure about which device you need to format, run fdisk again and print out the partition table. 1) Since you rebooted, you need to re-load the hard disk tools. Follow steps listed above under: Adding the HDD tools to your LRP environment: 2) If you created a swap partition, format it using the command: mkswap -c /dev/hda2 The optional -c switch checks for bad blocks during format. 3) If you created a data partition, format it using the command: mke2fs -c /dev/hda5 The optional -c switch checks for bad blocks during format. USING YOUR HARD DRIVE: You are now ready to begin using you hard drive with LRP. You will need to configure a few system files to make everything work smoothly. Creating mount points: 1) Create a mount point for your data partitions (swap partitions don't need a mount point). A mount point is an empty directory that you can 'attach' a device to. I mount my data drive as /storage, so the command I ran was: mkdir /storage You can use whatever name you want, and you can have different mount points for the different partitions. Mount points do not need to be at the root level, so you could make something like /var/www for web files if you wanted. Adding your new partitions to the fstab file: 1) Run lrcfg 2) Edit the file system mounts file (menu 2-2) 3) You should see entries for the two file systems LRP uses by default, the proc file system (kernel information), and the ramdisk (/dev/ram0). 4) You will need to add a line for each device you want to mount. The syntax is: is the appropriate device ie /dev/hda1 is where to mount the partition (use none for swap partitions) is the filesystem type, either ext2 or swap a comma separated list of options to use with the -o switch to the mount command. is a flag for the dump utility (a hard disk backup program) Unless you are running dump (unlikely) just set this to '0' is a flag for the fsck file system checker. The ramdisk and swap file should be '0', while you should enter '1' for any ext2 data partitions you add The lines I added to my /etc/fstab file (again, these match my hard disk setup, not what you need to add): /dev/hda2 none swap sw 0 0 /dev/hda5 /storage ext2 rw 0 1 I also added the and flags (both set to '0') to the ramdisk partition 5) Backup etc from lrcfg (menu b-2) to save the changes made to /etc/fstab 6) You might want to try mounting your partitions. For each data partition, execute the command: mount -t ext2 -o rw /dev/hda5 /storage 7) You can check disk usage with the 'df' command. Make sure the size of the partitions matches what you expect for each new mount point. 8) To test your swap partitions, use the command: swapon /dev/hda2 9) You can check your swap memory statistics with the 'free' command Preventing LRP from backing up your hard disk: At this point, you might think you're done, but you have not saved your mount points yet, which will prevent things from working automatically next time you boot. The mount points are saved as part of the root package, which is sort of a 'catch-all' for anything that is not part of another LRP package. This presents an additional problem, because root will try to back up your hard disk to your boot media (probably a floppy) if you don't tell it to do otherwise. 1) Verify you have created mount points for all your data partitions 2) Edit the root.exclude.list. This is a list of files the root package should NOT backup ae /var/lib/lrpkg/root.exclude.list 3) For each one of your mount points, add a line like: /storage/* Note you should start with the mount point, and add a '/*' to the end. This allows the root package to back up the mountpoint directory (/storage in this case), but prevents it from backing up anything actually in that directory (which is OK, because that stuff's on the hard disk anyway). 4) Run lrcfg and backup root (menu b-1) Checking the partition automatically: (optional, but highly recommended) It is a good idea to have LRP check any ext2 partitions at boot, in case the machine did not shut down cleanly (ie power went down, you accidentally hit the reset switch, or some other unexpected event). 1) Mount the floppy disk with the hdsupp_s.lrp package: mount -t msdos /dev/fd0 /mnt 2) cd to the floppy disk: cd /mnt 3) Load the LRP package. IMPORTANT: The LRP file needs to be in the current directory, and you should omit the '.lrp' from the filename lrpkg -i hdsupp_s 4) Leave the /mnt directory and unmount the floppy cd / umount /mnt 5) Backup the hdsupp_s package using lrcfg. This will store the package on your boot device. 6) Mount your boot device so you can edit syslinux.cfg mount -t msdos /dev/boot /mnt 7) Edit syslinux.cfg and add hdsupp_s to the list of packages to load ae syslinux.cfg 8) Unmount the boot device umount /mnt 9) Verify something like the following is spit out the next time you boot. This is what my system outputs. Your system will be similar, but some numbers will be different: Checking all filesystems... Parallelizing fsck version 1.12 (9-Jul-98) /dev/hda5 clean 31/25688 files, 3697/102504 blocks REBOOTING THE SYSTEM: You are *finally* ready to try rebooting your LRP system. Any swap and data partitions you created should be loaded automatically on reboot. 1) You might want to put a few test files in each of your data partitions, so you can see if they are still there on reboot. 2) Reboot your machine 3) Watch closely as the system boots. You want to note any errors that might show up. You also want to verify the partition is checked, if you installed hdsupp_s.lrp (recommended). 4) Login and run 'df' to see if your partitions are mounted. Run 'free' if you added a swap partition to check its status. 5) Check for the test files you created under each mount point. 6) If everything is OK, pat yourself on the back, and take a break. Your eyes are starting to get crossed from staring at that monitor so long. SOMETHING WENT WRONG: Sadly, everything doesn't always work correctly the first time around. Some things to check: 1) Double check the changes you made to the fstab file, and verify you backed it up (any changes you make without backing up are lost on reboot). 2) Verify the mount points you list in the fstab file exist, and are either empty or have a disk partition mounted to them (use the 'df' command to see what's mounted). If your mount points don't exist, you forgot to back up root.lrp before rebooting. If your mount points exist, but are not empty (and don't have a hard disk mounted to them), you didn't get root.exclude.list modified correctly. You CANNOT mount a partition to a directory that has something in it. If your mount points are empty and there is no disk partition mounted to them, you probably have an error in your fstab file. Double check all device listings, spelling of your mount point, etc. If your mount points are empty and there is a disk partition mounted to them, everything is probably working OK, you just didn't make any test files, although you should still see the 'lost+found' directory, which is created when you format the partition. ---------------------------------------- Advanced Procedures: Using SCSI/RAID or other devices ---------------------------------------- Advanced LRP users may wish to boot LRP from a SCSI drive, RAID array, flash disk, or some other device that does not have support directly compiled in as part of the kernel. There are two possible ways to do this: 1) Re-compile the LRP kernel, including support for the desired device 2) Since LRP boots with an initial ramdisk (root.lrp), module support for the desired devices can be added at runtime, if everything required is archived as part of root.lrp. I will cover the second method here. OVERVIEW: The key to booting LRP from a SCSI disk, RAID array, or anything else that is not supported by the kernel without modules is folding the required files into the initial ramdisk (root.lrp) and adding support for the necessary devices before the kernel tries to access them. This is actually why initrd (initial ramdisk) support was first added to the linux kernel...the fancy footwork LRP does to turn the initial ramdisk into a full blown file system came later. The fact that LRP makes use of a simple .tgz file for the initial ramdisk actually makes the task of supporting odd hardware much easier. All you have to do is add some files to your running LRP system and back them up as part of root.lrp. BEFORE YOU GET STARTED: Setting up a RAID array on an LRP system is about as complex as drive configuration gets under linux. I assume if you're attempting this, you have a solid understanding of linux block devices (especially IDE and/or SCSI drives), and are very familiar with disk partitioning. I also assume you are familiar with setting up hard disks for LRP, have gone through at least one of the two procedures outlined above, and thoroughly understood what you did. You will need a few things, so try to track them all down before you get started. 1) The Software-RAID-HOWTO. Download this, print it out, and read it completely before you go any further. Then read it again. 2) A working LRP system with the hard disk and controller installed. 3) Hard disk support utilities (fdisk, fsck, mke2fs, and the like). Typically packaged as hdsupp.lrp 4) The RAID tools package (raid.lrp). 5) A kernel compiled with RAID support. 6) Kernel modules to support your HDD controller, SCSI support (if your HDD is SCSI), and the RAID modes you plan to use. For my Adaptec SCSI controller running RAID1 (mirrored), I needed: scsi_mod.o - Kernel SCSI support sd_mod.o - SCSI Disk support aic7xxx.o - Adaptec SCSI driver raid1.o - Raid 1 personality NOTE: The RAID kernel does not include built-in IDE support. If you are using IDE drives, you will have to load IDE support as a module, just like the SCSI support listed above. 7) The ext2.o kernel module for your LRP kernel version. This should be available from the same place you got the IDE support module or kernel, above. 8) The hdsupp_s.lrp package, which is used to check ext2 data partitions at boot time (and doesn't include the disk formatting utilities for size/security reasons). PRELIMINARIES: Setup and configure a conventional floppy based LRP distribution of your choice. This will be the basis for your new SCSI+RAID system. MAKE ONE OR MORE BACKUPS OF YOUR LRP DISK. You will be heavily modifying the startup scripts on one of these disks. If you mess anything up, LRP will crash horribly (no /etc directory, no inittab file, no boot) and you will have to boot from one of your backup disks. Clearly label your original, backup, and (soon to be) RAID floppies, so you don't get them confused later. ADDING BOOTSTRAP MODULE SUPPORT: Replace the kernel on your RAID LRP floppy with the RAID kernel and reboot. You will see a lot of errors about kernel-module version mismatches, but you should get to a login prompt. You'll update the modules later to get rid of the errors. NOTE: If you don't have enough room on your disk for the new kernel, delete some of your LRP packages or modules.lrp to get some elbow room. You've got backups, and can add the packages back later when you're booting off the HDD. Create a directory where you would like to put the boot-strap modules. I've put mine in various locations, but finally settled on /boot/modules. Copy the modules required for SCSI+RAID (or whatever your odd boot device is) to the directory you just created. Verify everything works by loading the modules manually using insmod. If you have any problems at this point, fix them before continuing. For my system, I ran the following commands (you may need to supply parameters to some of the modules...adjust accordingly): insmod /boot/modules/scsi_mod.o insmod /boot/modules/sd_mod.o insmod /boot/modules/aic7xxx.o insmod /boot/modules/raid1.o If the above worked, you need to create a file that tells the init scripts which modules to load. I used the file /boot/modules/modules.conf, with the same format as the /etc/modules you should already be familiar with. Now, it's time to configure linuxrc to load the modules when LRP boots. I added the following lines to /linuxrc just before the code that queries the kernel command line for the 'boot' option: # # Load any modules required to boot # MODDIR=/boot/modules if [ -r $MODDIR/modules.conf ] ; then # Loop over every line in modules echo 'Loading modules:' (cat $MODDIR/modules.conf ; echo) | # make sure file ends with LF while read module args do case "$module" in \#*|"") continue;; esac echo " ${module}:" /sbin/insmod $MODDIR/${module%.o}.o $args done echo " Done" fi Check to make sure the /dev directory contains all the devices you need for your hardware. You may also need to update /var/lib/lrpkg/root.dev.mk to create additional device nodes. I added the following lines on my system to support the newly added RAID functionality: # RAID Devices makedevs md b 9 0 0 15 >null 2>&1 At this point, double check everything, then backup root.lrp. Double check everything again, and as a final test, remove the modules you manually added (using rmmod), and run the linuxrc script manually. This will re-install all the LRP files except root, which shouldn't hurt anything, load the bootstrap modules, and create any new devices you added. If linuxrc won't run, doesn't load the modules, or doesn't create the devices, try to figure out why and fix it. Back up root.lrp when you're done. Reboot your machine. If you got everything correct, your system should boot off the floppy and load the bootstrap modules prior to the loading the LRP packages. You can verify the modules all loaded by looking at /proc/modules once the system is booted. If you goofed and the modules didn't load, fix whatever's wrong. If you really goofed and the linuxrc script didn't run (or crashed with syntax errors), your system will not boot, and you'll have to start over (you did make backup disks, right?). FINISHING UP: Now that your system is properly loading bootstrap modules, you can partition your disks, create RAID arrays, format filesystems, and generally make use of your drives. You can even do things like load all your LRP files off a RAID5 ext2 partition if you want. The only requirement is that syslinux, the linux kernel, and root.lrp are available on a FAT partition syslinux can boot from, and even this is not mandatory if you use a different boot loader (grub, lilo, ldlinux, etc). To get your system booting off your new device, see Method 1: Booting LRP from a hard disk, above. Creating a RAID array: First, partition your drives, creating appropriate (typically equal sized) partitions with a partition type of 0xFD (raid-autodetect). Load the raid.lrp package, editing /etc/raidtab as appropriate (see the Software-RAID-HOWTO). Backup raid.lrp to save your changes to /etc/raidtab. Make the raid devices using mkraid. At this point you can treat the newly created md device like any other harddisk partition. Format it using mke2fs (see the Software-RAID-HOWTO for some RAID-specific mke2fs parameters). You can load LRP packages from it by setting the PKGPATH kernel parameter, and mount the partition at run-time either manually or using /etc/fstab entries. See Methods 1 and 2, above, for details. Booting LRP from a RAID array You can setup LRP to boot from a RAID1 (Mirrored) array if you so desire. For additional background on the following procedure, see the Boot + Root + Raid + Lilo : Software Raid HOWTO. Basically, you get LRP booting of a hard disk, then migrate the single hard disk partition to a RAID1 Mirror. I will describe the system I setup, which boots from a mirrored array (/dev/md0) made up of two partitions, /dev/sda1, and /dev/sdb1. First, setup LRP to boot off your hard disk. This is covered in Method 1, above. Make sure you partition /dev/sda and /dev/sdb identically (at least for the two partitions you plan to mirror). If you don't have two identical drives, you can used unmatched drives, but make sure the partition on your secondary drive (/dev/sdb in this case) is at least as large as the partition on the primary drive (/dev/sda), or you will be unable to add it to the RAID array later. Create an /etc/raidtab entry for a RAID1 array with a bad drive. My raidtab file looked like: raiddev /dev/md0 raid-level 1 nr-raid-disks 2 nr-spare-disks 0 chunk-size 4 persistent-superblock 1 device /dev/sda1 raid-disk 0 device /dev/sdb1 failed-disk 1 MAKE SURE NONE OF THE PARTITIONS INVOLVED ARE MOUNTED! Run fdisk and change the partition type on /dev/sda1 to 0xFD Make the raid device: mkraid /dev/md0 Delete /dev/boot, and replace it with a link to /dev/md0. This is required so you don't accidentally backup data to just /dev/sda1, which would corrupt the array. rm /dev/boot ln -s /dev/md0 /dev/boot Run fdisk and change the partition type on /dev/sdb1 to 0xFD Add /dev/sdb1 to the raid array: raidhotadd /dev/md0 /dev/sdb1 Edit /etc/raidtab and changed 'failed-disk' to 'raid-disk' Edit /etc/raidboot.conf and set RAIDBOOT=YES and RAIDBOOTDEV=/dev/md0 so the boot device will be switched to /dev/md0 the next time you boot. Backup raid.lrp NOTES: You still set boot=/dev/sda1,msdos in syslinux.cfg. This is because when linuxrc runs, the RAID arrays are not autodetected yet (this happens after linuxrc exits). If one of your disks dies, you may have to edit syslinux.cfg on the working disk, but you should be able to boot off either disk. While it's important you NEVER write data directly to a partition that is part of a RAID array (use the proper md* device instead), it's OK for syslinux and linuxrc to READ data from a single disk when booting. As long as you're only reading data, you're not in danger of corrupting your RAID array. TESTING: You might want to test loosing a drive (just unplug it from the SCSI or IDE cable) and booting off the other disk before you get too far along in installing LRP (in case you accidentally loose your data). After you verify you can boot with one disk 'failed', hook everything back up. When you reboot, your raid should automatically rebuild itself, as indicated in /proc/mdstat. You might also want to test manually rebuilding your array, which you would have to do if a disk actually died and was replaced with a new, unformatted disk. A good way to test this without having a spare third disk is to 'wipe' your current disk by running the following commands (count is the number of blocks on the partition as reported by fdisk). Shutdown the array, so we can play with the individual partitions: raidstop /dev/md0 Wipe all data from one of the disks. This will look like a failed disk to the kernel RAID support, since the RAID superblock got trashed: dd /dev/sdb1 bs=1024 count=21488 Restart the RAID array. You should see errors indicating /dev/sdb1 is not available. The array should run, but will be in degraded mode. You are now the proud owner of a RAID array with a broken disk. Take a look at /proc/mdstat to see the differences between the degraded RAID and how things normally look. I used the following procedure to recover from this (NOTE: If you actually were starting with a 'new' disk, you would first have to create an appropriate partition with a type of 0xFD): raidhotadd /dev/md0 /dev/sdb1 This adds /dev/sdb1 back to the array. You can verify this by looking at /proc/mdstat, which should list sbd1[1] and sda1[0] as part of md0, and will indicate the mirror reconstruction is in progress (or complete). Verify the listing in /proc/mdstat matches your /etc/raidtab file so you won't have any unpleasant surprises in the future. On my system, the files look like: /proc/mdstat: Personalities : [raid1] read_ahead 1024 sectors md0 : active raid1 sdb1[1] sda1[0] 21376 blocks [2/2] [UU] unused devices: /etc/raidtab: raiddev /dev/md0 raid-level 1 nr-raid-disks 2 nr-spare-disks 0 chunk-size 4 persistent-superblock 1 device /dev/sda1 raid-disk 0 device /dev/sdb1 raid-disk 1 Make sure that the device & raid-disk settings in /etc/raidtab match the device[raid-disk] settings in /proc/mdstat: mdstat: raidtab: ------------------------------------- sda1[0] device /dev/sda1 raid-disk 0 ------------------------------------- sdb1[1] device /dev/sdb1 raid-disk 1 ------------------------------------- If you ever need to re-construct your RAID array, the raid-disk numbers are important, especially if you are running anything other than RAID1 (like RAID0 or RAID5). ---------------------------------------- Advanced Procedures: Running with root on a HDD ---------------------------------------- It may seem odd, but with LRP, which is intended to run using a ramdisk as it's root filesystem, getting root on a hard-disk partition is actually a bit tricky. This is an attempt to document how I got an LRP 2.9.8 system (with a 2.2.x kernel) running with a hard disk partition as the root filesystem. You might want to do this if you intend to use LRP as a very thin server-OS, where you need a HDD for other reasons. My system actually combines several advanced techniques, including booting off a SCSI disk, using software RAID. Before you attempt this, go through a few more conventional setups first (you'll have to anyway). You should be comfortable with the general LRP boot and configuration process, and you should have setup LRP to boot off a hard-disk (with root still on a ramdisk) before attempting this procedure. NOTE: You'll need several things besides an LRP disk image to get this to work. Most files can be found from the HardDisk packages page of my website: http://lrp.steinkuehler.net/Packages/HardDisk.htm You'll need: boot.tgz - Contains updated linuxrc & the /boot directory hddroot.tgz - Contains chroot & updated checkroot.sh init script modules - You'll need modules for your hard disk controller that match your kernel revision. 1) I started with a 2.9.8 LRP "idiot" image setup for a 2.2.x kernel: idiot-image_1440KB_FAT_2.9.8_Linux_2.2 2) The first thing I did was replace the kernel on the disk with a kernel that supports 486 CPU's (the default kernel requires a Pentium) and includes software RAID support. The kernel I used is available here: http://lrp.steinkuehler.net/files/kernels/2.2.16-1-RAID/ I also increased the size of the ramdisk from the default 4 Megs to 16 Megs, so I'd have room for lots of packages. 3) Boot the new disk 4) Create and populate the /boot directory. The easiest way to do this is to uncompress my boot.tgz file, which includes modules for an Adaptec SCSI controller and RAID 1 (mirroring) by using the following commands (after mounting a floppy containing boot.tgz): cd / gunzip - null 2>&1 makedevs sdb b 8 16 0 8 s >null 2>&1 into: #SCSI makedevs sda b 8 0 0 15 s >null 2>&1 makedevs sdb b 8 16 0 15 s >null 2>&1 #RAID makedevs md b 9 0 0 15 >null 2>&1 8) Edit /var/lib/lrpkg/root.version to set the version ID for the core LRP packages (I used 2.9.8-CS). 9) Add any required modules (NIC drivers and what-not) to /lib/modules (this can be done later if you want). 10) Backup root.lrp and modules.lrp 11) Partition your hard-disk and setup LRP to boot off the hard-disk using the methods described above. Use the boot disk you just made as a starting image. I setup my system to boot off /dev/md0, which is a RAID1 array of two SCSI disks. See the RAID section above, for details on how to set this up. 12) Take a breather. At this point, you should have a fairly basic LRP 2.9.8 system booting off the hard-disk. Now's a good time to take a break, grab a beer (or coffee), go to sleep, or whatever. 14) With the system booting off a hard-disk partition, but still using a ramdisk as the root partition, you should configure the system as much as possible. Copy any required LRP packages to the boot partition, add them to syslinux.cfg, and configure them (if required). You'll probably need at least: hdsupp.lrp -or- hdsupp_s.lrp raid.lrp (if you're using RAID arrays) NOTE: There's not a hdsupp.lrp specifically for LRP 2.9.8. I've used the ones for Materhorn and Eiger without trouble. You should also configure any packages you want running, like sshd, rsyncd, dhcpd, and any applications you need, like a web or dns server. If you don't have enough RAM to boot with everything configured, try to temporarily add enough to your system...you'll only need it until your hard-disk root partiton is created and working, and it's much easier to experiment with things running from the ramdisk. Remember, if you mess up configuration with root in a ramdisk, just reboot and you're back to where you were...with root on a hdd, you have to be able to undo anything that breaks your system, and at this point, you're probably not making regular backups. 15) Now things begin to get intersting. With a working LRP system booting off the HDD and running out of ram, it's time to build your new root filesystem. First, you need to partition and format your disks. If you want to have multiple partitons (for /var, /tmp, and the like), or you want to run off of RAID arrays, now's the time to get everything setup. Once you've got everything partitioned and formatted, mount your new filesystem someplace like /tmp/newroot in preperation for copying files. Remember to mount any additional partitions you intend to use as well, or you'll have to move everything around later. I wound up with the following setup: device use size current mount point /dev/md1 / 64M /tmp/newroot /dev/md2 /var 64M /tmp/newroot/var /dev/md3 /tmp 64M /tmp/newroot/tmp /dev/md4 /usr 256M /tmp/newroot/usr 16) With your new filesystem mounted, and completely empty (except for the directories you had to create to be able to have mount points for any extra partitions you're using), your're ready to start filling it. The first step is to uncompress root.lrp into the new root area with the following commands: mount -t msdos /dev/boot /mnt cd /tmp/newroot gunzip - proc /proc proc noauto 0 0 /dev/md1 / ext2 rw 1 1 /dev/md2 /var ext2 defaults 1 2 /dev/md3 /tmp ext2 defaults 1 2 /dev/md4 /usr ext2 defaults 1 2 21) You also need to update the /etc/init.d/checkroot.sh file, since the default file shipped with LRP doesn't check the root filesystem (not much point in checking a ramdisk filesystem you just built). I just took the script from a Debian 2.1 (Slink) distribution (which LRP is based on), and added the RCDLINKS variable for LRP. You can get this file from my website, and just copy it to /etc/init.d/checkroot.fs 22) Now things begin to get a bit ugly. You might think you're ready to reboot, but but you're not. If you look at the /etc/rc?.d/ directories, you'll find they're empty! LRP by default uses a nifty script that builds the rc?.d links at boot, but this won't work properly with root on a hard-disk for several reasons: 1) The update-rc.d script is in /usr/sbin, which may not be mounted at boot 2) At boot, the root filesystem is mounted read-only, creating a chicken & egg problem. The /etc/rc?.d links can't be created until root is writable, and root won't be writable until the checkroot.sh script runs, which is run from a link in rcS.d To avoid these problems, you need to disable the automatic link generation: ae /tmp/newroot/etc/default/rcS change: DYNARCD=no to: DYNARCD=yes 23) You still need to get all those links into your rc?.d directories, but luckly, this is pretty easy. Just run the following commands: cd /tmp/newroot chroot /tmp/newroot usr/sbin/update-rc.d -faw Make sure the links were actually made (and put in the right place) by: ls -l /tmp/newroot/rc?.d In the future, if you add any LRP packages, you'll need to run the update-rc.d script manually, to create any links that might be required. You probably won't want to use the -a (all) or -w (wipe) switches, especially if you've installed any non-LRP packages that don't have RCDLINKS variables in their init.d scripts. 24) NOW, you're ready to reboot, and your LRP system should cleanly boot into your new root partition. If something went wrong, or you're getting errors, read CAREFULLY through everything above...there's a lot of detail, making it easy to miss something or skip a step. 25) If something's broken, try to see what you did wrong. It may be possible to fix your existing filesystem, or you may have to rebuild it from scratch. With a working LRP boot floppy and your configured LRP system on the hard-disk, it's really not too hard to re-format your new partition(s) and start over. I did this MANY times before I got everything working properly and the above procedure documented. 26) BACKUPS - I recommend backing up your new system using conventional linux backup methods, but there is that very handy boot partition with all your configured LRP files on it that's not doing much anymore. It's possible to use the lrcfg backup scripts to store your running configuration on the boot partition, but I wouldn't rely on this as your only backup. For one, it's probably on the same physical hard-disk as the rest of the system, and your hard-disk is the most likely thing to die. Also, if you backup some of the packages (like etc and root), there's the potential to break the LRP system that's on the boot partition, meaning it's floppy time if you ever need to repair anything on your new filesystem. I'd at least keep a copy of the LRP files around on the boot partition (maybe in a sub-directory), in case you ever need to get back to your 'as-installed' state. ---------------------------------------- Adding a kernel module: ---------------------------------------- 1) Mount the floppy disk containing the module you need to support your hard disk controller: mount -t msdos /dev/fd0 /mnt 2) Copy the module file to '/lib/modules': cp /mnt/mymodule.o /lib/modules 3) Unmount the floppy: umount /mnt 4) Run 'lrcfg' 5) Edit the kernel modules file (menu 3-2-1) 6) At the end of the file, enter the name of the module, without the '.o'. If your module file is 'mymodule.o', add 'mymodule' to the end of the modules file. 7) Make sure there is at least one blank line between your module name and the '<< EOF >>' marker 8) Save the file -w and exit the program -q 9) Press 'q' until you return to the lrcfg main menu 10) Put your LRP boot disk back in the floppy drive 11) Press 'b' to backup the ramdisk 12) Select 'Modules', which should be choice 5 13) Exit lrcfg and return to the command line 14) Load the new module by hand, using the command: insmod /lib/modules/mymodule.o 15) Make sure the module loaded successfully. If you get lots of unresolved symbol errors, either your module and kernel versions don't match, or the module depends on another module that you haven't loaded yet. If the module complains about something (like it can't find the hardware it's supposed to talk to) you may need some command line options for the module, or you may need to check your hardware configuration. Fix any problems before you continue. 16) You might want to reboot to make sure the module will automatically load correctly.