155 lines
5.1 KiB
HTML
155 lines
5.1 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
|
<HTML>
|
|
<HEAD>
|
|
<META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.9">
|
|
<TITLE>The Linux SCSI programming HOWTO: What Are The Requirements To Use It?</TITLE>
|
|
<LINK HREF="SCSI-Programming-HOWTO-5.html" REL=next>
|
|
<LINK HREF="SCSI-Programming-HOWTO-3.html" REL=previous>
|
|
<LINK HREF="SCSI-Programming-HOWTO.html#toc4" REL=contents>
|
|
</HEAD>
|
|
<BODY>
|
|
<A HREF="SCSI-Programming-HOWTO-5.html">Next</A>
|
|
<A HREF="SCSI-Programming-HOWTO-3.html">Previous</A>
|
|
<A HREF="SCSI-Programming-HOWTO.html#toc4">Contents</A>
|
|
<HR>
|
|
<H2><A NAME="s4">4. What Are The Requirements To Use It?</A></H2>
|
|
|
|
<P>
|
|
<H2><A NAME="ss4.1">4.1 Kernel Configuration</A>
|
|
</H2>
|
|
|
|
<P>You must have a supported SCSI controller, obviously. Furthermore,
|
|
your kernel must have controller support as well as generic support
|
|
compiled in. Configuring the Linux kernel (via <CODE>make config</CODE> under
|
|
/usr/src/linux) typically looks like the following:
|
|
<P>
|
|
<BLOCKQUOTE><CODE>
|
|
<PRE>
|
|
...
|
|
*
|
|
* SCSI support
|
|
*
|
|
SCSI support? (CONFIG_SCSI) [n] y
|
|
*
|
|
* SCSI support type (disk, tape, CDrom)
|
|
*
|
|
...
|
|
Scsi generic support (CONFIG_CHR_DEV_SG) [n] y
|
|
*
|
|
* SCSI low-level drivers
|
|
*
|
|
...
|
|
</PRE>
|
|
</CODE></BLOCKQUOTE>
|
|
<P>If available, modules can of course be build instead.
|
|
<P>
|
|
<H2><A NAME="ss4.2">4.2 Device Files</A>
|
|
</H2>
|
|
|
|
<P>The generic SCSI driver uses its own device files, separate from those
|
|
used by the other SCSI device drivers. They can be generated using
|
|
the <CODE>MAKEDEV</CODE> script, typically found in the <CODE>/dev</CODE>
|
|
directory. Running <CODE>MAKEDEV sg</CODE> produces these files:
|
|
<P>
|
|
<BLOCKQUOTE><CODE>
|
|
<PRE>
|
|
crw------- 1 root system 21, 0 Aug 20 20:09 /dev/sga
|
|
crw------- 1 root system 21, 1 Aug 20 20:09 /dev/sgb
|
|
crw------- 1 root system 21, 2 Aug 20 20:09 /dev/sgc
|
|
crw------- 1 root system 21, 3 Aug 20 20:09 /dev/sgd
|
|
crw------- 1 root system 21, 4 Aug 20 20:09 /dev/sge
|
|
crw------- 1 root system 21, 5 Aug 20 20:09 /dev/sgf
|
|
crw------- 1 root system 21, 6 Aug 20 20:09 /dev/sgg
|
|
crw------- 1 root system 21, 7 Aug 20 20:09 /dev/sgh
|
|
| |
|
|
major, minor device numbers
|
|
</PRE>
|
|
</CODE></BLOCKQUOTE>
|
|
<P>Note that these are character devices for raw access. On some systems
|
|
these devices may be called <CODE>/dev/{sg0,sg1,...}</CODE>, depending on your
|
|
installation, so adjust the following examples accordingly.
|
|
<P>
|
|
<H2><A NAME="ss4.3">4.3 Device Mapping</A>
|
|
</H2>
|
|
|
|
<P>These device files are dynamically mapped to SCSI id/LUNs on your SCSI
|
|
bus (LUN = logical unit). The mapping allocates devices consecutively
|
|
for each LUN of each device on each SCSI bus found at time of the SCSI
|
|
scan, beginning at the lower LUNs/ids/buses. It starts with the first SCSI
|
|
controller and continues without interruption with all following
|
|
controllers. This is currently done in the initialisation of the SCSI
|
|
driver.
|
|
<P>For example, assuming you had three SCSI devices hooked up with ids 1,
|
|
3, and 5 on the first SCSI bus (each having one LUN), then the
|
|
following mapping would be in effect:
|
|
<P>
|
|
<BLOCKQUOTE><CODE>
|
|
<PRE>
|
|
/dev/sga -> SCSI id 1
|
|
/dev/sgb -> SCSI id 3
|
|
/dev/sgc -> SCSI id 5
|
|
</PRE>
|
|
</CODE></BLOCKQUOTE>
|
|
<P>If you now add a new device with id 4, then the mapping (after the
|
|
next rescan) will be:
|
|
<P>
|
|
<BLOCKQUOTE><CODE>
|
|
<PRE>
|
|
/dev/sga -> SCSI id 1
|
|
/dev/sgb -> SCSI id 3
|
|
/dev/sgc -> SCSI id 4
|
|
/dev/sgd -> SCSI id 5
|
|
</PRE>
|
|
</CODE></BLOCKQUOTE>
|
|
<P>Notice the change for id 5 -- the corresponding device is no longer
|
|
mapped to <CODE>/dev/sgc</CODE> but is now under <CODE>/dev/sgd</CODE>.
|
|
<P>Luckily newer kernels allow for changing this order.
|
|
<P>
|
|
<H3>Dynamically insert and remove SCSI devices</H3>
|
|
|
|
<P>If a newer kernel and the <CODE>/proc</CODE> file system is running,
|
|
a non-busy device can be removed and installed 'on the fly'.
|
|
<P>To remove a SCSI device:
|
|
<BLOCKQUOTE><CODE>
|
|
<PRE>
|
|
echo "scsi remove-single-device a b c d" > /proc/scsi/scsi
|
|
</PRE>
|
|
</CODE></BLOCKQUOTE>
|
|
<P>and similar, to add a SCSI device, do
|
|
<BLOCKQUOTE><CODE>
|
|
<PRE>
|
|
echo "scsi add-single-device a b c d" > /proc/scsi/scsi
|
|
</PRE>
|
|
</CODE></BLOCKQUOTE>
|
|
<P>where
|
|
<BLOCKQUOTE><CODE>
|
|
<PRE>
|
|
a == hostadapter id (first one being 0)
|
|
b == SCSI channel on hostadapter (first one being 0)
|
|
c == ID
|
|
d == LUN (first one being 0)
|
|
</PRE>
|
|
</CODE></BLOCKQUOTE>
|
|
<P>So in order to swap the <CODE>/dev/sgc</CODE> and <CODE>/dev/sgd</CODE> mappings from
|
|
the previous example, we could do
|
|
<P>
|
|
<BLOCKQUOTE><CODE>
|
|
<PRE>
|
|
echo "scsi remove-single-device 0 0 4 0" > /proc/scsi/scsi
|
|
echo "scsi remove-single-device 0 0 5 0" > /proc/scsi/scsi
|
|
echo "scsi add-single-device 0 0 5 0" > /proc/scsi/scsi
|
|
echo "scsi add-single-device 0 0 4 0" > /proc/scsi/scsi
|
|
</PRE>
|
|
</CODE></BLOCKQUOTE>
|
|
<P>since generic devices are mapped in the order of their insertion.
|
|
<P>When adding more devices to the scsi bus keep in mind there are
|
|
limited spare entries for new devices. The memory has been allocated
|
|
at boot time and has room for 2 more devices.
|
|
<P>
|
|
<HR>
|
|
<A HREF="SCSI-Programming-HOWTO-5.html">Next</A>
|
|
<A HREF="SCSI-Programming-HOWTO-3.html">Previous</A>
|
|
<A HREF="SCSI-Programming-HOWTO.html#toc4">Contents</A>
|
|
</BODY>
|
|
</HTML>
|