[KLUG Members] USB2 HDD on Linux
bfdamkoehler at worldnet.att.net
bfdamkoehler at worldnet.att.net
Mon Aug 16 22:29:04 EDT 2004
I don't know about the IOGear USB2 but I have used a couple of Western Digitals,
IOMegas, etc. My experience is mostly on Mandrake 9.0 or 9.2 (linux 2.4.x).
If you are only going to use one drive and never swap it this is serious
overkill. Anyway, this is how I do it. I haven't talked to anyone else so I
don't know if there is a better way.
USB drives show up as some /dev/sdX. If you have only one drive it will probably
be /dev/sda. I use a shell script to locate the /dev/sdX and mount any
partitions on it. I used another to perform the unmounts.
This requires that you have a dump of the partition table on the disk. The
script searches for a known pattern. If it finds the pattern it tries to mount
the partitions.
If you are going to remove the usb cable, power down the drive, etc, you should
sync first and umount any partitions. As long as you do that you can hot swap
them to your hearts content. I have been forced to reboot a time or two because
I forget to do that!
I don't do anything about fsck'ing the drives at mount time. I guess that I
haven't been burned too badly by powering down without umounting. Non-journaled
file systems like ext2 or fat32 are more sensitive than journalled filesystems.
The following is an example script that mounts three partitions on an external
disk. I only scan up to /dev/sdl. Thus far I haven't needed to go any farther.
! /bin/ksh
#
# mnt_wd_ext.sh
#
# This command file locates the device that my WD external firewire/USB2 disk
# lives on and mounts the partitions on it.
# It is invoked as:
#
# sh mnt_wd_ext.sh
#
# where
#
# no cmd line args are required
#
# Variable Definition
# -------- ----------
# $0 the script file name
#
# Revision History:
# Version - Author - Date - Description
# 01 BFDamkoehler 08-Jun-04 initial edit
#
#
#
# It is invoked as:
#
# chk_disk_for_partitions dev_name
#
# where
#
# dev_name is a device name such as /dev/sda
#
# Revision History:
# Version - Author - Date - Description
# 01 BFDamkoehler 08-Jun-04 initial edit
#
chk_disk_for_partitions ()
{
fdisk $1 2>/dev/null >$TMP_DIR/fs$$.tmp <<-THE_END
p
q
THE_END
echo "Testing ${1}"
grep -q "1 4079 32764536 c Win95 FAT32 (LBA)" $TMP_DIR/fs$$.tmp
if [ $? -eq 0 ] ; then
echo "mounting partitions of " $1
set -x
mount ${1}1 /fat1
mount ${1}2 /fat2
mount ${1}3 /ext
set +x
exit 0
fi
} # end of "chk_disk_for_partitions ()"
#
# make sure that our environment variables are defined
#
if [ "$TMP_DIR" = "" ] ; then
echo "${0}: the environment variable TMP_DIR does not exist"
exit 1
fi
#
# go fer it
#
chk_disk_for_partitions /dev/sda
chk_disk_for_partitions /dev/sdb
chk_disk_for_partitions /dev/sdc
chk_disk_for_partitions /dev/sdd
chk_disk_for_partitions /dev/sde
chk_disk_for_partitions /dev/sdf
chk_disk_for_partitions /dev/sdg
chk_disk_for_partitions /dev/sdh
chk_disk_for_partitions /dev/sdi
chk_disk_for_partitions /dev/sdj
chk_disk_for_partitions /dev/sdk
chk_disk_for_partitions /dev/sdl
exit 0
Michael Lueck wrote:
> Anyone have hands on experience with something like an IOGear USB2 drive
> connecting to Linux? Looking to support: Hot plug mode, manual mount. 2.6.7
> Kernel on Debian testing. (What do they call that, Sarg or something like it?)
>
> Not finding much useful in Google before just plugging it in.
>
> TIA!
>
> Michael Lueck
> Lueck Data Systems
> http://www.lueckdatasystems.com/
>
>
> _______________________________________________
> Members mailing list
> Members at kalamazoolinux.org
>
>
More information about the Members
mailing list