Yellow Dog Solutions

TOPIC: Attaching Firewire Disks to a Linux Box.



Introduction:

This HOWTO describes the procedure of attaching firewire (IEEE-1394) disk drives to Linux. The IEEE-1394 firewire bus has a raw throughput of 400 bits/sec. On G4 (sawtooth) hardware, sequential disk writes will yield roughly 13 megabytes/sec; an internal 7200 IDE/ATA drive compares at 26 megabytes/sec.


Content:
The stock YDL-2.1 2.4.10-12a kernel was built with modular firewire support. Thus one can simply, attach the drive, load the drivers, partition and the create filesystems it if needed, and mount.


1) Attach the drive.
One can use either a native firewire drive or an IDE/ATA drive in a firewire enclosure. The firewire bus can provide power for the 2.5" drives while the 3.5" drives will need the external supply that comes with the enclosure. Simply plug in the cable to both the drive and your computer's firewire port. Like USB, firewire is hot-swappable so you can attach with devices powered.


2) Load The Drivers.
The following drivers will be used: ieee1394, ohci1294, & sbp2. You can load these from the command line:
modprobe ohci1394 && modprobe sbp2
Loading the ohci1394 driver will automatically load the ieee1394 driver. In our experience, unloading the ohci1394 driver in the 2.4.10-12a kernel results in a DEADLOCK condition that requires a reboot. So never unload the ohci1394 driver and don't use /etc/modules.conf to associate sbp2 with ohci1394 because if you do, then unloading sbp2 will cause ohci1394 to unload.

You can confirm that the driver is loaded with the command
lsmod
which might produce:
Module                  Size  Used by
sbp2                   17408   0  (unused)
ohci1394               20464   0  (unused)
ieee1394               34384   0  [sbp2 ohci1394]

3) Optionally Partition And Create Filesystem(s)
Firewire drives are mapped to the SCSI device files, so /dev/sda is the first driver, /dev/sdb the second, etc. Firewire drives usually have two firewire connectors so you can chain multiple drives together by plugging one drive into the other. With a single drive, either connector can be used.

You can partition the disk and create filesystems in the same manner that you use with an internal disk. We've successfully used fdisk and mke2fs (both ext2 and ext3) and a HFS disk that was initialized under MacOS 9.

If your disk is already initialized, use fdisk or pdisk to view the existing partitions so you know what to mount. For example,
pdisk -l /dev/sda
Partition map (with 512 byte blocks) on '/dev/sda'
 #:                type name              length   base     ( size )
 1: Apple_partition_map Apple                 63 @ 1       
 2:    Apple_Driver_ATA*Macintosh             64 @ 64      
 3:    Apple_Driver_ATA*Macintosh             64 @ 128     
 4:       Apple_Patches Patch Partition      512 @ 192     
 5:           Apple_HFS "Macintosh HD"  20971520 @ 704      ( 10.0G)
 6:           Apple_HFS OS9              2097152 @ 20972224 (  1.0G)
 7:           Apple_HFS MacOSUser       23068672 @ 23069376 ( 11.0G)
 8:           Apple_HFS LinuxMacShare    2097152 @ 46138048 (  1.0G)
 9:     Apple_Bootstrap untitled         1433601 @ 48235200 (700.0M)
10:     Apple_UNIX_SVR2 untitled        18874369 @ 49668801 (  9.0G)
11:     Apple_UNIX_SVR2 untitled         2097153 @ 68543170 (  1.0G)
12:     Apple_UNIX_SVR2 swap             2097153 @ 70640323 (  1.0G)
13:     Apple_UNIX_SVR2 untitled         2097153 @ 72737476 (  1.0G)
14:     Apple_UNIX_SVR2 untitled        10485761 @ 74834629 (  5.0G)
15:     Apple_UNIX_SVR2 untitled         8438730 @ 85320390 (  4.0G)
Device block size=512, Number of Blocks=93759120 (44.7G)
DeviceType=0x0, DeviceId=0x0
Drivers-

1: 21 @ 64, type=0x701
2: 34 @ 128, type=0xf8ff


4) Mount The Filesystem(s)
Now mount your filesystem with the usual mount command. For example,
mount -t ext3 /dev/sda10 /fw
mounts the tenth partition of the first disk as an ext3 filesystem onto the /fw mount point.


5) Disconnecting The Disk
When you are done using the drive, first un-mount (umount) all filesystems on the drive you want to remove and all other firewire drives on that chain. For a single partition on a single drive, simply type
umount /fw
If the umount fails because the filesystem is busy, use the command
lsof /fw
to see what processes are using the disk. For example, you might see something like:

COMMAND PID USER   FD   TYPE DEVICE SIZE NODE NAME
bash    730 root  cwd    DIR   8,14 4096    2 /fw
Next unload the sbp2 driver (don't unload the ohci1394 driver),
modprobe -r sbp2
Finally, disconnect the drive from the cable.


6) Reconnecting a Disk
The sbp2 driver must be unloaded before connecting or disconnecting drives. So ensure that sbp2 is unloaded using lsmod. If its still loaded, be sure to un-mount the appropriate filesystems and then unload sbp2 with modprobe -r sbp2. Thus, if you want to add a drive to the chain, you'll need to un-mount all filesystems on the existing drives first.

This HOWTO was written by Randall Smith




 
          Copyright ® 1999-2010. Fixstars Corporation. All rights reserved.
YDL.net Fixstars Corporation