ZIP-drive mini-HOWTO
  Grant Guenther, grant@torque.net
  v1.0, 15 April 1996

  The Iomega ZIP drive is a popular, removable media disk drive.  It is
  available in two main versions, one has a SCSI interface and the other
  connects to a parallel port.  This document describes how to use the
  ZIP drive with Linux. It should be read in conjunction with the SCSI
  HOWTO.

  1.  Introduction

  The Iomega ZIP drive is a popular, low-cost, low-performance,
  portable, removable media disk drive.  Its disks have a capacity of 96
  megabytes, and the drive is available in two main versions, a SCSI
  version and a parallel port version. The parallel port version is
  actually a SCSI device as well, configured to use Iomega's proprietary
  PPA-3 SCSI-over-parallel protocol.

  This document describes how to use the ZIP drive with Linux.  Since
  this is a SCSI device, it is important for you to read the SCSI HOWTO
  as well.  That document gives a thorough introduction to the Linux
  SCSI system.  It does not contain any specific information about the
  ZIP drive, the ZIP Zoom SCSI host adapter or the PPA-3 parallel-to-
  SCSI adapter.  This mini-HOWTO aims to fill those gaps.

  This document incorporates information collected and published by
  others, in particular:

  �  Scot Wilcoxon, sewilco@fielday.mn.org

  �  Joe Mack, mack@ncifcrf.gov

  �  Byron Jeff, byron@cc.gatech.edu

  I thank them for their important contributions, and accept
  responsibility for any errors that I have introduced.

  2.  The ZIP drive

  There are three versions of the Iomega ZIP 100 drive. They all accept
  special cartridges resembling a 3.5" floppy disk that hold 100
  megabytes of data.  The disks actually hold 96 cylinders of 2048
  sectors each holding 512 bytes.  This would normally be called 96
  Megabytes.

  One version is a half-height 5.25" internal drive, with a SCSI
  interface, the other two are external drives in a small blue
  lightweight plastic enclosure, powered by an external wall brick.  The
  external drives come in a SCSI version and a parallel port version.

  All the drives have a large pushbutton on the front of the drive.
  This is used to eject the disk.  Linux locks the door while using the
  drive, but if the button is pressed while the door is locked, the ZIP
  drive will remember and eject the disk as soon as the software unlocks
  it.

  2.1.  SCSI version

  The external SCSI version of the ZIP drive has two DB25F connectors,
  and two configuration switches.  One switch selects the drive's target
  address: the choice is limited to target 5 or 6.  The other enables an
  internal terminator, in case the drive is the last one on a chain.
  The 25 pin SCSI connectors use the familiar Macintosh style wiring.
  The drive is shipped with a Macintosh type cable, but standard cables
  and converters are easily obtained if you are using a host adapter
  with a Centronics or high-density connector.

  I have not seen an internal SCSI drive, but I would expect it to have
  a standard 50 pin DIP header SCSI connector and the same two switches.

  Make sure that the target address you choose does not conflict with
  any other SCSI devices you may have on the same bus.  Also be sure
  that the physically last drive in a chain has termination enabled, or
  an external terminator installed.

  If you have an internal SCSI disk or CD-rom, and you connect your ZIP
  drive to the existing adapter, you should check to see if there are
  any terminators on the card that must be removed.  Only the two
  extreme ends of the SCSI bus should be terminated.  If your bus is
  partly internal and partly external, there should be one terminator on
  the last external device and one on the last internal device, but no
  terminators on the adapter card itself.

  Be sure that all cables are firmly attached.

  2.2.  The ZIP Zoom host adapter

  Iomega markets a SCSI host adapter under the name ZIP Zoom.  This is
  actually based on the design of the Adaptec AHA1520 family of
  adapters.  It has an external Macintosh type DB25F connector,
  compatible with the cable that comes with the ZIP drive.

  Linux supports this adapter with the aha152x driver.

  2.3.  Parallel port version

  The parallel port ZIP drive also has two DB25 connectors, the male
  (DB25M) should be connected with the supplied parallel cable to your
  computer's parallel port.  The other (female, DB25F) is intended to
  support a chained printer.  Linux does not currently support
  simultaneous use of both a ZIP drive and a chained printer.  A work-
  around is possible using loadable modules.  There are no configuration
  switches.

  The parallel port ZIP drive is compatible with several types of
  parallel ports, but currently the Linux driver supports only the
  Standard and bi-directional ports.  If your parallel port has
  configuration switches (in hardware or on a CMOS setup screen) be sure
  to set the port into one of those two modes.

  Be sure that all cables are firmly attached.

  3.  Configuring a kernel for the ZIP drive

  To use the ZIP drive with Linux, you must have a kernel configured
  with support for the SCSI system, support for SCSI disks and support
  for the host adapter you are using.  If you are not familiar with
  building a kernel, you should go to /usr/src/linux and study the
  README file found there.  There is also useful information in the
  Documentation subdirectory in recent versions.

  You must begin the process of building a kernel with the configuration
  step.  Here, you identify the specific kernel components that you
  need.  make config is the traditional, sequential, question and answer
  method of configuring the kernel.

  In recent kernels there are some new alternatives: make menuconfig
  does the same thing with a menu oriented interface, and make xconfig
  uses the tk toolkit to provide a version that is nice to use under X.

  Once you have configured your kernel, use make dep and make zLilo (or
  make zImage if you don't use LILO) to compile the new kernel and
  install it.  And, of course, don't forget to shutdown and reboot !

  You can also build all or part of the SCSI system as modules.  If you
  do this, be sure to load scsi.o, then sd.o and finally the driver for
  your host adapter, before you try to access the ZIP drive.

  3.1.  SCSI version

  If you already have a SCSI disk in your system, and you are connecting
  the ZIP drive to the same controller, there is no additional kernel
  configuration required.  Otherwise, you will most likely have to build
  a new kernel.

  If you are building a kernel to support the SCSI version of the ZIP
  drive, you should select SCSI support and SCSI disk support.  You must
  also select a driver for the interface card you will use. If you have
  a ZIP Zoom, select the aha152x driver.

  Be sure to read the documentation for your adapter in the SCSI HOWTO
  and any README files in the drivers/scsi subdirectory of the Linux
  source tree.  Pay attention to command line parameters that you might
  have to use to help the kernel initialise your adapter.

  For instance, if you are using the ZIP Zoom card, you will have to add
  something like

          aha152x=0x340,11,7,1

  to the boot command (or include it in your /etc/lilo.conf file in an
  append clause).  This tells the driver the port address and IRQ of
  your ZIP Zoom card - be sure to use the numbers that correspond to the
  way your jumpers are set.

  You should also read Paul Gortmaker's BOOTPROMPT HOWTO for information
  about configuring your kernel with LILO or LOADLIN.

  3.2.  PPA driver for 1.2.13

  If you want to use the parallel port ZIP drive with the stable kernel,
  version 1.2.13, you must fetch version 0.18 of the driver which is
  available for anonymous ftp at <ftp://gear.torque.net/pub/ppa.c>
  Installation instructions about how to compile the driver as a
  loadable module are contained in the source for ppa.c.

  Please note that you will almost certainly have to build a new kernel.
  In particular, none of the Slackware pre-built kernels will work with
  ppa.  Be careful to build your kernel with SCSI support and SCSI disk
  support, but do not include support for the lp printer driver.  In
  1.2.13 the two drivers cannot co-exist in the same kernel.

  You can adjust the port number and some timing parameters on the
  insmod command line when you load the ppa driver.   These adjustments
  are documented in the ppa.c file.  By default the driver assumes that
  the ZIP drive is connected to the parallel port at 0x378.

  There will not be any enhancements to this driver for the 1.2.13
  kernel.  You should expect it to disappear a few months after the 2.0
  kernel is released and the major distributions start using it.

  3.3.  PPA driver in current kernels

  Since version 1.3.74 the ppa driver has been a standard part of the
  kernel.  There were some changes to other parts of the kernel around
  1.3.78 that required an interim workaround, but since 1.3.85 the
  driver has been quite stable at version 0.26.  Since the code-freeze
  for Linux 2.0 is now in effect,  I expect that 0.26 will be in the
  next stable kernel.

  To build a kernel with ppa support, include SCSI support, SCSI disk
  support and select the Iomega ZIP / PPA-3 support from the list of
  low-level SCSI adapters.  You can also build the driver as a loadable
  module.

  You can use command line parameters in /etc/lilo.conf or with insmod
  to adjust the driver.   This is all documented in
  drivers/scsi/README.ppa in the kernel source tree.  I've included a
  summary in the next section.

  If you want to use both the lp and ppa drivers on the same parallel
  port, you must build both as loadable modules and load one or the
  other at any point in time, but not both.

  Linux's loadable module features are becoming more powerful, and
  correspondingly more complex, every day.  You should read the file
  Documentation/modules.txt in the kernel source tree, as a starting
  point.

  3.4.  PPA command line parameters

  If you have ppa built into your kernel, you can adjust its parameters
  from the command line of LILO or LOADLIN with the following syntax:

       ppa=base[,speed_high[,speed_low[,nybble]]]

  Where base is the i/o address of your parallel port, speed_high is a
  timing constant for certain fast loops in the driver, speed_low is a
  similar timing parameter for some slower loops and nybble is a flag to
  force the driver to use 4-bit, or nybble mode, even if it wants to do
  otherwise.

  For an example, the defaults could be specified as:

       ppa=0x378,1,6,0

  4.  Using the ZIP drive

  If you have built in all the required components, the kernel should
  recognise your adapter and drive at boot time.  If you are using a
  loadable module for your driver, the following discussion applies once
  that module is loaded.

  For the most part, the SCSI and parallel versions of the drive behave
  identically, except that the parallel version is somewhat slower.

  4.1.  Identifying the drive at boot time

  When your system boots it should display several pieces of information
  about your adapter, your drive and the disk in the drive.  If you do
  not have a disk in the drive, some of this information will be missing
  and will only appear when you insert a disk and then touch the drive
  (make some attempt to access it).  Beginning users are advised to boot
  their system with a disk in the drive - things are less confusing that
  way !

  Exactly where these messages will appear depends on how your system is
  configured.  Often they will be displayed to your system console, but
  they may be diverted into a log file such as /var/adm/messages.
  Usually, you can retrieve the last couple of screens of kernel
  messages with the dmesg command, if you can't find them anywhere else.

  If you need to get someone to help you with anything, a copy of this
  log information is critical.  Try to send as many of the relevant log
  messages as you can along with any bug report.

  Here is a sample of what the kernel's log messages should look like:

       scsi0 : PPA driver version 0.26 using 8-bit mode on port 0x378.
       scsi : 1 host.
         Vendor: IOMEGA    Model: ZIP 100           Rev: N*32
         Type:   Direct-Access                      ANSI SCSI revision: 02
       Detected scsi disk sda at scsi0, channel 0, id 6, lun 0
       scsi : detected 1 SCSI disk total.
       SCSI device sda: hdwr sector= 512 bytes. Sectors= 196608 [96 MB] [0.1 GB]
         sda: Write Protect is off
       Partition check:
         sda: sda1

  This output came from a 1.3.87 system with a parallel ZIP drive.  The
  exact output will vary depending on your host adapter and whether you
  have any other SCSI devices in your system.

  The first line displays the initialisation message from the low-level
  driver for the host adapter, in this case PPA. Following that comes
  the drive identification information returned by each device found on
  the SCSI bus. Line 5 reports the device name assigned to the drive, in
  this case /dev/sda.  And the last line hows the result of the
  partition check of the disk in the drive.  This one has one
  partition,/dev/sda1.  These reports come from different modules in the
  kernel, if you have more than one SCSI adapter, or several disks, each
  section will contain more information.

  If you are using a fresh disk, direct from Iomega, the partition check
  should show one partition, /dev/sda4.  If you have other SCSI devices
  you will understand that the ZIP drive could appear on some other
  device name like /dev/sdb - so check these messages.

  If these lines do not appear, then something is misconfigured in your
  hardware or in the kernel.  Check everything carefully before sending
  mail.

  If the scsi0: line does not appear, then you have not configured your
  host adapter and its driver correctly.  Some drivers will give you a
  hint about what is wrong.   If your drive is not detected, you
  probably have a cable problem.  If a drive name is not assigned, you
  probably forgot to include SCSI disk support when you built the
  kernel.

  Check the README files in drivers/scsi and the SCSI HOWTO for other
  debugging hints.

  4.2.  Fdisk, mke2fs, mount, etc.

  Once you know the drive name for your ZIP drive, you are set.  You can
  manipulate the drive with the normal Linux disk management commands.
  fdisk (or perhaps cfdisk) is used to manipulate the partition tables
  on the disk.  mke2fs can be used to format a partition with the ext2
  filesystem - the one most commonly used in Linux.  mount is used to
  connect a formatted partition into your directory hierarchy.

  You should study the manual pages for these tools if you are not
  familiar with them.  Be warned that there are now several quite
  different versions of the fdisk program - be careful.

  I'll describe two common scenarios.

  4.2.1.  An existing DOS formatted disk

  If you have a ZIP disk with a DOS file structure that was originally
  created by Iomega's tools, the partition scan should say that the disk
  has one partition, /dev/sda4.

  You should make a place to mount the disk, lets say /zip, and then
  mount it as an MS-DOS filesystem:

       mkdir /zip
       mount -t msdos /dev/sda4 /zip

  Now, the files on the disk should appear in /zip.  While the disk is
  mounted, you will not be able to remove it.  When you are finished
  with the disk you can umount it to release it and detach it from your
  directory hierarchy.

       umount /zip

  Once you've made the /zip mount point - you don't need to do it again,
  so you could come back later and mount something else there.

  4.2.2.  Re-format as a native Linux disk

  If you want to erase a ZIP disk and make a Linux native file system on
  it.  you should use fdisk on the entire disk:

       fdisk /dev/sda

  and delete any existing partitions (with the d command).  Then create
  a new partition with the n command, make it primary partition number
  1, use w to write the partition table to disk, and quit with q.

  Format the partition

       mke2fs /dev/sda1

  (The 1 is the number that you gave this partition in fdisk).  Now you
  can mount the disk:

       mount -t ext2 /dev/sda1 /zip

  (re-using that mount point we created before).

  4.2.3.  The ZIP Tools disk

  There is some extra work to be done if you want to use the disk that
  comes with the ZIP drive.  As shipped, the software controlled write
  protection is enabled.  Most people have unlocked the disk under DOS
  before ever trying to use it with Linux.  Linux cannot access a locked
  disk, and it must be unlocked with Iomega's tools.

  A native Linux program to manage the write protection feature, among
  other things, is expected to be available soon.

  4.3.  Ejecting a disk

  You can only eject a disk when it is dismounted.  Currently, there is
  no Linux command to eject the disk, so you must press the button on
  the front of the drive to eject the disk.

  Linux ensures that all data have been written to the disk before it is
  unlocked.

  Watch for a new ZIP tools program for Linux which will support some of
  Iomega's special features (including software controlled ejection and
  write protection) on both the SCSI and parallel versions of the drive.

  5.  Frequently asked questions

  These are some of the questions that we get asked a lot.  Please read
  the answers here before asking them again !

  5.1.  Can I boot from the ZIP drive ?

  This depends on what you are using for a host adapter.  If your host
  adapter has a BIOS ROM with code that can boot from target 5 or 6,
  then yes, you can boot from the SCSI ZIP drive.  You cannot boot from
  a parallel port drive.

  If you have DOS on your main disk and want to boot Linux from a ZIP
  disk, you can do this using the LOADLIN boot loader.  Your kernel
  image must be somewhere on the DOS disk, but the rest of your Linux
  system could be on the ZIP.  Make sure that the kernel you use has the
  correct drivers built in.

  As far as I am aware, there are no installation boot floppies for any
  of the popular distributions that contain the parallel ZIP driver, but
  this may change when Linux 2.0 comes out.

  5.2.  Why does Iomega use partition number 4 ?

  This is one of the most popular questions, but I don't think anyone
  has a definite answer to this one.  Maybe there is no good reason.

  5.3.  How can I have the disk mounted at boot time ?

  All you need to do is to add a line to your /etc/fstab file.  For
  instance, if you will always have a DOS disk in the drive when you
  boot, you could put

       /dev/sda4   /zip  msdos  defaults  0 0

  in the fstab.  Depending on your distribution, the initialisation
  scripts might try to run fsck on partitions listed in your fstab.  Be
  aware that this could cause problems if you forget to put the disk in
  the drive when you boot, or have the wrong disk there.

  5.4.  What happens if there is no disk inserted when I boot ?

  The kernel will try to read the partition table, but the operation
  will time out.  There is nothing to worry about.  Once you have
  inserted a disk, and try to do something with it the kernel will
  notice that there is a disk there now and rescan the partition table.

  HINT: when you change disks, it is a good idea always to use fdisk to
  check the partition structure on the new disk.

  The BIOS on some SCSI host adapters will attempt to read the partition
  table on your disk during the system boot.  If you cannot disable this
  check, you may be forced always to boot with a disk in the drive.

  5.5.  What SCSI adapters are compatible with the ZIP drive ?

  Iomega has a list of compatible host adapters at:

       <http://www.iomega.com/techs/zip/what063.html>

  5.6.  Can I use the parallel drive as a real SCSI disk ?

  The PPA-3 parallel-to-SCSI adapter is implemented as a single ASIC
  chip that Iomega calls a VPI0.  It is embedded on the ZIP drive's
  controller card.  There is an actual SCSI bus present, but not in a
  useful form.

  Although I haven't tried to compare the two cards, it seems logical
  that the VPI0 replaces the conventional electrical buffering circuits
  that would be required if the SCSI bus were extended outside the
  package.
  5.7.  Can I plug a printer into the parallel drive ?

  Yes, but.  Currently, you cannot have both the lp and ppa drivers
  active on the same parallel port.  A resource sharing protocol has
  been designed and is in the early stages of implementation, but will
  not be available before Linux 2.0 is released.

  In the meantime, if you do chain a printer and a ZIP drive, you can
  use them both without rebooting your system, providing you have built
  the lp and ppa drivers as loadable modules.  If you have done so, then
  when you want to print you would insmod the lp driver, and when you
  want to access the ZIP drive you would load the ppa driver.

  Of course, if you have two parallel ports, you can use one for
  printing and one for your ZIP drive.  Just build a kernel with both
  the lp and ppa drivers included, then put some appropriate
  configuration commands on your kernel command line.  For instance, if
  you use LILO and you have a printer on 0x378 and a ZIP drive at 0x3bc
  you could add the following line to your /etc/lilo.conf file.

       append = "lp=0x378 ppa=0x3bc"

  5.8.  Do you plan to support EPP/ECP ports in PPA ?

  ppa was initially developed without the benefit of any technical
  specifications for the command protocol on the parallel bus.  Instead,
  the DOS emulator was used to gather information to reverse engineer
  the protocol.  It was not possible to get the drive to work in an
  enhanced mode under the emulator.

  An Iomega technical reference manual is now available, and I have
  located a data sheet for an enhanced parallel port chip, so it may be
  possible to upgrade the driver.

  5.9.  Can PPA be used with Iomega's parallel port tape drives ?

  No.  Those drives are floppy-tape drives, there is no SCSI involved.

  Several people have indicated an interest in applying my methods to
  try to determine the protocol and develop a driver for these tapes.
  The first step in that process is to get the DOS driver working under
  DOSemu.  I have not yet heard that anyone has been successful in doing
  it.

  5.10.  Will PPA work with the parallel port SyQuest EZ135 ?

  No. The EZ135 is an IDE drive with a ShuttlePort parallel to IDE
  converter embedded in it.

  Work has begun on decoding the protocol with the intention of writing
  a Linux driver for the parallel port EZ135.  I have the basic protocol
  worked out, but I have no idea when a driver might be completed.

  Keep an eye on my web page <http://www.torque.net/ez135.html>, I will
  eventually be looking for some beta testers.

  6.  Getting more current information

  I will try to keep an up-to-date version of this mini-HOWTO available
  on my web pages.  You can check it out at

       <http://www.torque.net/zip.html>.

  There is a more general ZIP FAQ web page (with a definite Macintosh
  bias) at

       <http://earth.cnct.com/home/steveg/zip.html>.

  Iomega's web pages are at

       <http://www.iomega.com/>.

  And if you are looking for general information about parallel port
  programming for the PC, you might want to visit

       <http://www.lvr.com/parport.htm>