SPONSORED LINKS

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Running Linux using an external Jaz drive and floppy



Hi,

Here's some general info for those of you who may be interested. It's the method I
used to get Linux to run on my Thinkpad 701CS without using any HD space - i.e.
a partial boot from floppy to the point that my PCMCIA SCSI card is recognised
(New Media Bus Toaster). It is a somewhat unsatisfactory solution, since at the
times that the Jaz is not mounted, the system is trying to do things to the 'Wrong'
root partition (i.e. a dummy root partition during startup, and once the PCMCIA
drivers get unloaded, well, erm, there is no root partition). Still, it works.
Also note that I read in a message to a Linux mailing list that the PCMCIA drivers
in a future release will be such that they can be compiled into the kernel.

Note that this method allows you to create a very portable Linux boot disk: I've
tried it in another notebook and it worked first time (i.e. the notebook had the Jaz
drive connected with the same Linux medium in)

cheers,

Andrew.

SETTING UP LINUX TO BOOT FROM SCSI DISK ATTACHED VIA PCMCIA
(c) Andrew Richards, January 1997 (andrew@tic.ch).

Introduction
  I have a laptop that is very tight on space on the hard disk, so
  I decided to install Linux on my Jaz drive, attached via a PCMCIA
  SCSI card (New Media Bus Toaster). The problem with Linux and
  PCMCIA in this scenario is that PCMCIA support normally only
  gets loaded _after_ the root filesystem has been mounted. PCMCIA
  support cannot be compiled into the kernel.

  By using LILO (or LOADLIN with a similar method) it is possible
  to setup a boot floppy or a program you can fire from DOS,
  which contains the kernel and a skeleton root filesystem with
  enough information and drivers to load the PCMCIA drivers for
  the SCSI card. Once these drivers are loaded it is possible to
  mount the real root filesystem.

  The kernel offers a facility called initrd which makes this chain
  of events possible. Once the real root filesystem is loaded, the
  skeleton root filesystem is moved to a subdirectory where it is
  still mounted. This can then be unmounted if desired.

  Here are some notes on what I did to get this working on _my_
  setup - yours could well be different, so take care to adjust e.g.
  device names to match your system when reading this document. I
  assume technical competence and some willpower - this procedure
  isn't easy! I hope this document helps someone out there...

Distributing this document
  Feel free to distribute this document; on the same terms as the
  GNU license.

Starting point
  You need to run a basic Linux somehow to generate the boot floppy
  or hard-disk setup. Talk nicely to a friend or do as I did:

  The distribution of Linux that I'm using makes it possible to
  run Linux from the CD-ROM - which contains a 'Live filesystem',
  with the exception of about 30Mbyte of files which have to be
  on a read/writeable device, i.e. a directory on the hard disk.

  Note that this setup is unsatisfactory for normal Linux use
  because it is botched together, slow (because of the CD-ROM)
  and inflexible if I want to add bits to it. But to get our boot
  floppy it's great.

  Also note that you need a reasonably recent version of Linux -
  I guess anything from 1996 onwards. Anything with a version 2.x
  kernel is fine.

The Jaz drive
  I used this for three things when setting up the root floppy -
  a place to store my skeleton root filesystem, a place to compile
  a kernel for my floppy, and for the real root filesystem. I did
  this by having three partitions of the Jaz disk - generated by
  using cfdisk. The skeleton root filesystem must fit into a
  partition of 5 Megabytes - any bigger and there's no chance it'll
  compress onto a single floppy disk.

The Kernel
  I decided to build my own kernel to minimise space. This is
  actually not strictly necessary - you could easily use one of
  the precompiled kernels from the distribution. To do this I
  copied /usr/src/linux and subdirectories to a writeable device
  (in fact a small partition on the Jaz drive), then executed
  these commands from the ....src/linux directory,
		make menuconfig
		make dep
		make clean
		make zImage
  This creates (after a long compilation - about an hour for me)
  the file zImage in ....src/linux/arch/i386/boot. Make sure that
  you include RAM disk support and SCSI support (but no specific
  low-level SCSI drivers are required - the PCMCIA module doesn't
  need these).
  You now have a compressed kernel image that will be used later...

The skeleton root filesystem
  I setup a 5Mbyte partition on the Jaz drive, i.e /dev/sda2
  (/dev/sda1 is where the real Linux root filesystem is, /dev/sda3
  is the partition I used to generate the kernel). Before
  creating a filesystem on it, 'Zero' it so that it compresses well:
		dd if=/dev/zero of=/dev/sda2 bs=1k count=5120
  then create a filesystem on it,
		mke2fs -b 1024 -m 0 /dev/sda2 5120
  mount it,
		mount /dev/sda2 /mnt
  and put the necessary files in it (see my directory structure
  below - the options d, p, and R for the cp command are very useful
  for this step). You will need to create a special file /linuxrc
  which is run for the skeleton root filesystem. Mine looks like
  this,
					#!/bin/bash
					/etc/rd.d/pcmcia start
					fsck /dev/sda1
  - alternatively, make /linuxrc a symbolic link to a shell, so
  that you can then type in commands manually,
		cd /mnt
		ln -s bin/bash linuxrc
  Note that if you choose this second option, when you boot your
  system with the new boot floppy, you will have a shell prompt.
  Typically type the comands above (pcmcia start, fsck) before
  typing 'exit' - once the shell terminates (i.e. the program
  linuxrc), the real root filesystem is mounted.

  Now unmount the filesystem,
		umount /mnt
  Compress it to a file,
		dd if=/dev/sda2 bs=1k count=5120 | gzip -9 > /skeleton.gz
  This file will be used later...

The floppy
  Take an old unwanted floppy that's been formatted at least once
  in it's lifetime (i.e. under DOS). Create a filesystem on it,
		mke2fs /dev/fd0 -m 0
  mount it,
		mount /dev/fd0 /mnt
  and remove the lost+found directory for extra space,
		rm -r /mnt/lost+found
  Copy the 'Loader' to the floppy (see LILO documentation),
		cp /boot/boot.b /mnt
  Copy the kernel image that you wish to use to the floppy,
		cp ....zImage /mnt
  Copy the compressed skeleton root filesystem to the floppy,
		cp /skeleton.gz /mnt
  Note that if skeleton.gz doesn't fit on this floppy, that's not
  a problem - see the next section - but before you do that, tell
  LILO to put the finishing touches to the disk:
  Create a file /etc/lilo.conf with contents e.g.,
				boot = /dev/fd0
				compact
				install=/mnt/boot.b
				map=/mnt/map
				image=/mnt/zImage
				   label=linux
				   root=/dev/sda1 
				   initrd=/mnt/skeleton.gz
  - in this example the real root filesystem is on /dev/sda1. If
  you had to put skeleton.gz on a separate disk, add the indented
  line (under image...),
		append="prompt_ramdisk=1"
  Run LILO to process the lilo.conf file, updating your floppy,
		lilo
  tidy up by unmounting the floppy
		umount /mnt
  - you've now created your boot floppy, but don't reboot just yet....

Creating a separate root floppy if necessary (see previous section)
  Again using an old unwanted formatted floppy,
		dd if=/skeleton.gz of=/dev/fd0

The real root filesystem
  Set this up from the Linux install disks if you haven't already,
  and add the empty directory /initrd to it. The skeleton filesystem
  will get moved to this directory when the real root filesystem
  gets mounted.

Does it work?
  Cross your fingers. Now reboot the system with your boot floppy
  in the drive.

Using LOADLIN instead of a boot floppy
  Using LOADLIN it's possible to fire Linux from DOS using files
  found on the hard disk (formatted for DOS). It needs most of
  the steps above - in particular a kernel and a compressed
  skeleton root filesystem. Then proceed as follows:
    *THIS SECTION STILL TO BE WRITTEN*

Still to be added to this document
  Altering the startup and shutdown files to not dismount the
  root filesystem until the latest possible moment, and not to
  unload PCMCIA support while the root filesystem needs to be
  accessed (my current thoughts are to put a couple of syncs
  in the /etc/pcmcia/scsi file).

Sources
  I used lots of Linux documents to sort this out. Personal
  contributions from Dave Ahn, Chris Bednar and Huber Mantel
  and the documents, Kernel HOWTO, Module HOWTO, Installation
  HOWTO, PCMCIA HOWTO, BOOTDISK HOWTO, LILO documentation and
  man pages, and in particular the initrd.txt and ramdisk.txt
  documents (for me in /usr/src/linux/Documentation).

The skeleton root file system
  Here is a listing of the skeleton root file system:

total 11
drwxr-xr-x  bin  
drwxr-xr-x  dev  
drwxr-xr-x  etc  
drwxr-xr-x  lib  
-rwxr-xr-x  linuxrc  
drwxr-xr-x  mnt  
drwxr-xr-x  modules  
drwxr-xr-x  proc  
lrwxrwxrwx  rmmod -> bin/insmod
lrwxrwxrwx  sbin -> bin
drwxr-xr-x  tmp  
drwxr-xr-x  usr  
drwxr-xr-x  var  
    
bin:    
total 753
drwxr-xr-x  init.d  
lrwxrwxrwx  sh -> bash
and ordinary files:
agetty, bash, cardmgr, cat, echo, fgrep, fsck, fsck.ext2, init, insmod,
kill, loadkeys, ls, mingetty, mknod, mount, ps, pwd, rm, scsi_info, sleep,
umount, uname

bin/init.d:    
total 7
-rwxr-xr-x  boot  
-rwxr-xr-x  pcmcia  
-rwxr-xr-x  rc  
    
dev:    
total 1
lrwxrwxrwx  core -> /proc/kcore
lrwxrwxrwx  fd -> /proc/self/fd
drwxr-xr-x  inet  
lrwxrwxrwx  ram -> ram0
lrwxrwxrwx  ramdisk -> ram0
lrwxrwxrwx  stderr -> fd/2
lrwxrwxrwx  stdin -> fd/0
lrwxrwxrwx  stdout -> fd/1
and the following devices (from standard dev directory)
console, fd0, fd1, full, hda, hda1, hda2, hda3, hda4, hda5, hda6, 
hdb, hdb1, hdb2, hdc, hdc1, hdc2, initrd, kmem, mem, nst0, null, port, 
ram0, ram1, random, scd0, scd1, sda, sda1, sda2, sda3, sda4, sda5,
sda6, sda7, sda8, sda9, sdb, sdb1, sdb2, sdb3, sdb4, sdb5, sdb6, sdb7, sdc,
sdc1, sdc2, sr0, sr1, st0, tty, tty0, tty1, tty2, tty3, tty4, urandom, zero
    
dev/inet:    
total 0
    
etc:    
total 26
-rw-r--r--  fstab  
-rw-r--r--  ld.so.cache  
drwxr-xr-x  pcmcia  
-rw-r--r--  rc.config  
lrwxrwxrwx  rc.d -> ../sbin/init.d
    
etc/pcmcia:    
total 48
-r-xr-xr-x  cdrom  
-r--r--r--  cdrom.opts  
-rw-r--r--  config  
-r--r--r--  config.opts  
-r-xr-xr-x  fixed  
-r--r--r--  fixed.opts  
-r-xr-xr-x  ftl  
-r--r--r--  ftl.opts  
-r-xr-xr-x  memory  
-r--r--r--  memory.opts  
-r-xr-xr-x  network  
-r--r--r--  network.opts  
-r-xr-xr-x  pcmem  
-r--r--r--  pcmem.opts  
-r-xr-xr-x  rc.pcmcia  
-r-xr-xr-x  scsi  
-r--r--r--  scsi.opts  
-r-xr-xr-x  serial  
-r--r--r--  serial.opts  
    
lib:    
total 1208
-rwxr-xr-x  ld-linux.so.1  
lrwxrwxrwx  ld-linux.so.1. -> ld-linux.so.1
lrwxrwxrwx  libc.so.5 -> libc.so.5.2.18
-rwxr-xr-x  libc.so.5.2.18  
-rwxr-xr-x  libncurses.so.1.9.9g  
lrwxrwxrwx  libncurses.so.3.0 -> libncurses.so.1.9.9g
drwxr-xr-x  modules  
    
lib/modules:    
total 1
drwxr-xr-x  2.0.25  
    
lib/modules/2.0.25:    
total 14
drwxr-xr-x  block  
drwxr-xr-x  cdrom  
drwxr-xr-x  fs  
drwxr-xr-x  ipv4  
drwxr-xr-x  misc  
-rw-r--r--  modules.dep  
drwxr-xr-x  net  
drwxr-xr-x  pcmcia  
drwxr-xr-x  scsi  
    
lib/modules/2.0.25/block:    
total 0
    
lib/modules/2.0.25/cdrom:    
total 0
    
lib/modules/2.0.25/fs:    
total 12
-rw-r--r--  binfmt_elf.o  
    
lib/modules/2.0.25/ipv4:    
total 0
    
lib/modules/2.0.25/misc:    
total 11
-rw-r--r--  vtx.o  
    
lib/modules/2.0.25/net:    
total 0
    
lib/modules/2.0.25/pcmcia:    
total 120
-rw-r--r--  aha152x_cs.o  
-rw-r--r--  ds.o  
-rw-r--r--  fixed_cs.o  
-rw-r--r--  ftl_cs.o  
-rw-r--r--  i82365.o  
-rw-r--r--  pcmcia_core.o  
-rw-r--r--  tcic.o  
    
lib/modules/2.0.25/scsi:    
total 104
-rw-r--r--  scsi_mod.o  
-rw-r--r--  scsi_syms.o  
-rw-r--r--  sd_mod.o  
-rw-r--r--  sg.o  
-rw-r--r--  sr_mod.o  
    
mnt:    
total 0
    
modules:    
total 123
-rw-r--r--  aha152x.o  
-rw-r--r--  aha152x_cs.o  
-rw-r--r--  cdrom.o  
-rw-r--r--  i82365.o  
-rw-r--r--  pcmcia_core.o  
    
proc:    
total 1
-r--r--r--  devices  
    
tmp:    
total 0
    
usr:    
total 2
drwxr-xr-x  adm  
drwxr-xr-x  lib  
    
usr/adm:    
total 0
    
usr/lib:    
total 0
    
var:    
total 1
drwxr-xr-x  run  
    
var/run:    
total 0