======================================= Linux configuration on a removable disk ======================================= -IAN! idallen@idallen.ca In this file: * Booting root= configuration * Fixing /etc/fstab (booting single-user) * X11 configuration Booting root= configuration --------------------------- If you get a "cannot find init" error when booting, or errors about checking file systems or swap space after booting, read on. "Cannot find init" errors come from having a GRUB kernel boot line with an incorrect root= partition specified. That's the partition where Unix looks for the first "init" process. In the labs, your caddy is either hda or hdb (on the first IDE controller). At home, it might be on the second IDE controller and thus end up as hdc or hdd. You can do the following to make a temporary edit to a GRUB boot line: When you boot at home and get the GRUB menu, arrow key down to the Mandrake Mini line and hit "e" for edit. You will see two lines, one for kernel and one for initrd. Hit "e" again to edit the first of the two lines (edit the kernel line) and use the right/left arrow keys to change "root=/dev/hda5" to whatever hard disk letter (hdc, hdd) is correct for your caddy installed in your home system: Primary IDE, Master - hda Primary IDE, Slave - hdb Secondary IDE, Master - hdc Secondary IDE, Slave - hdd ... etc for other controllers ... Push RETURN when you are done editing the root= on that line, to return to the two-line menu. Verify that the top line (the kernel line) is edited. Now type "b" to boot the edited line. Unless you change the GRUB menu on disk, or add a GRUB menu entry that has the correct root= line, you will have to do this edit every time you boot at home. (The edits are done in memory, for that boot only - the edits are not saved to disk.) Fixing /etc/fstab (booting single-user) --------------------------------------- For full functionality, entries in your /etc/fstab in your booted partition will also have to be changed from hda,hdb to be hdc,hdd as well. To do that, you need to edit /etc/fstab in your booted partition (and change it whenever you move your caddy to different hardware). You can usually bring up a "single-user" Linux system that will let you edit /etc/fstab even if /etc/fstab is wrong. (If that doesn't work, you can boot Knoppix, mount your partition, edit /etc/fstab, save it, unmount it, and reboot.) To boot "single user", add the word "single" to the end of the GRUB kernel line when you edit and boot. (You can do this at the same time as you fix the root= entry on that line.) It might also help to get rid of the vga= parameter on the kernel line, so that you operate in pure text-mode during the boot process (no graphic splash screen). Booting in single-user mode, the system should boot to a root shell prompt that will let you use vim on /etc/fstab to fix your hda,hdb to hdc,hdd. Maintenance or Repair mode: If you find yourself facing a "Maintenance" or "Repair" prompt (because /etc/fstab isn't usable), say "yes" to get to a root shell. You will find you can't edit anything, because the system has mounted your root file system "read only". (You can see this by looking directly at the kernel mount table /proc/mounts and seeing "ro" beside the root entry.) You have to "remount" the root read/write to be able to edit /etc/fstab, using some options to the mount command: # mount -o rw,remount / # cat /proc/mounts You should now see "rw" beside the root, and "vim /etc/fstab" should work properly. When you are finished the edit of /etc/fstab in single-user mode, probably the best thing to do is reboot the system (with the fixed /etc/fstab file). Type "shutdown -r now" or "reboot" to reboot. (Note: You can also type "exit" or CTRL-D to quit the single-user shell and let the system come up multi-user; but, the system won't have re-mounted things or set up swap space using your new /etc/fstab. There are ways to have the system do those things without doing a reboot; but, the reboot is simplest.) You will have to undo the /etc/fstab edits when you bring the caddy back into the T111 Lab and the drive appears again as hda or hdb. You could keep two copies of /etc/fstab, one for home and one for lab, and simply copy whichever one you need onto /etc/fstab as needed. There are awkward ways of scripting your boot sequence so that differnet GRUB menu entries select different /etc/fstab files. Since removable drives aren't too common, stock Linux distributions don't have an easy way of automating all this yet. With the increase in numbers of bootable USB keys, this should become easier over the course of the next year. X11 configuration ----------------- Moving your hard drive caddy among different machines that have different monitors and video displays creates a challenge for the X11 window system. (This is why you should always boot to text mode and use "startx" to start your window system, if you need it - edit /etc/inittab as needed.) Most Unix/Linux systems were designed to check the hardware *once* at install time, and they configure for whatever hardware was found at that time (and never look again). They weren't designed to be moved around on a removeable disk caddy, where every boot might present a different video card and monitor. Some Linux distributons do attempt to reconfigure your system on every boot. The Mandrake distribution has "harddrake" which keeps track of your hardware and attempts this for you. It isn't well-tested (not many people run Linux on removable hard drives), and it doesn't always work. In particular, you may find that the X11 system reconfigures correctly for your home video card and monitor, but then fails to boot in the T111 lab because "harddrake" is too dumb to put things back the way they were for the Lab video card and monitor. With luck (and your backup partition), you can recover your old X11 configuration file: Check under the /etc/X11/ directory for files named XF86Config*, e.g. -rw-r--r-- 1 root root 3187 Mar 28 12:34 /etc/X11/XF86Config -rw-r--r-- 1 root root 3199 Mar 27 11:57 /etc/X11/XF86Config.old The XF86Config text file contains the X11 config information for your video card and monitor. The previous version of the file is stored with the ".old" suffix, and if your current XF86Config file isn't working, perhaps the XF86Config.old file will work. Recover by using the old file: # cd /etc/X11 # mv XF86Config XF86Config.other # cp XF86Config.old XF86Config Try "startx" and see if it works. If not (if perhaps both the old file and the new file are broken), fetch the XF86Config file from your backup partition (that partition is possibly /dev/hda6 or /dev/hdb6) and try it (or try the XF86Config.old file from the same backup partition). When you find a working XF86Config file, save it as XF86Config.T111 so that you can use it if you ever run into video problems in future. If you have a working XF86Config file for home, save it as XF86Config.home.