#375 Multipartition IDE

open
nobody
5
2005-05-20
2005-05-20
dunsalen
No

The script /etc/pcmcia/ide.opts currently supplied
(pcmcia-cs-3.2.8) is
just a minimal demonstration script.

The attached script is a replacement which mounts and
unmounts IDE
cards having arbitrary numbers of partitions. Since it
is small it is
presented here as well as being attached for pickup by
a text editor:

# ATA/IDE drive adapter configuration

# This is sourced first by /etc/pcmcia/ide to get a
partition list
# in the variable PARTS as a space separated list of
partition numbers
#
# Subsequent calls provide a partition number and
expect to obtain
#
# The format of ADDRESS was once
scheme,socket,serial_no[,parts]
# but the current function file /etc/pcmcia/shared sets
the third
# parameter to something called NEW_SCHEME, which is
probably empty

# This was entirely rewritten by J.M. Hinkle to
properly accomodate
# multipartition PCMCIA cards

#
# HISTORY:
#
# 20-May-2005 Initial version of ide.opts by Joseph
M. Hinkle
#

case $ACTION in
start)
case $ADDRESS in
*,*,*,*)
# Sourced for each partition to set options
INFO="ATA/IDE card"
# DO_FSTAB="y" # Adds an entry for this device in
/etc/fstab
# DO_FSCK="y" # Requests a filesystem check on mounting
# FSTYPE="msdos" # -t option to the mount command;
auto is better
# OPTS="" # -o options to the mount command
DO_MOUNT="y"
MOUNTPT=/mnt/ide/$SOCKET/${ADDRESS##*,}
if [ ! -d $MOUNTPT ]; then mkdir -p $MOUNTPT; fi
;;
*,*,*)
# Sourced first to obtain a space separated partition
list
# ADDRESS can be scheme,socket or scheme,socket,unknown
SED="sed 's/\/dev\/$DEVICE\([^ ]*\).*/\1/'"
PARTS=`fdisk -l /dev/$DEVICE | grep ^/dev | grep -iv Ext`
PARTS=`echo "$PARTS" | eval $SED`
PARTS=`echo $PARTS | { while read n; do p="$p $n";
done; echo $p; }`
;;
esac
;;
stop)
# umounting is taken care of in /etc/pcmcia/shared
# rm_blockdev() and rm_parts()
# umounting logical partitions can take as much as a
minute
# but primary partitions are umounted immediately on
some cards
;;
check)
NO_CHECK=no
NO_FUSER=no
;;
esac

Discussion

  • dunsalen
    dunsalen
    2005-05-20

    ATA/IDE driver adapter configuration ide.opts

     
    Attachments
  • dunsalen
    dunsalen
    2005-05-21

    Logged In: YES
    user_id=1282524

    Two items come to mind since I posted this:

    1) This does not accomodate the case of a PCMCIA IDE device
    having no
    partitions, but a single filesystem occupying the entire
    drive, so would be
    mounted something like /dev/hde
    I will correct this shortly

    2) The manipulations to get the partition list into PARTS
    came about
    because it needs to be a space separated list. Since I
    posted that, I
    figured the way to get sed to replace the newlines returned
    by fdisk with
    spaces. This snippet shows the method if PARTS is a newline
    separated
    list:
    echo $PARTS | sed -n ':a;s|\n | |;$ b z;N;b a;:z; p'

    However, in testing I now find that PARTS=`fdisk -l
    /dev/hde` produces a
    space separated list just as needed. The sed expression
    required to turn
    that into a list of partition numbers would be different.
    It is not now clear
    why one case would produce a newline separated list and
    another a space
    delimited list.

    Comments will be helpful.