• Bug#250232: hdparm: 2 stage call at boot time (1/2)

    From =?iso-8859-1?Q?J=F6rg?= Sommer@1:229/2 to Stephen Gran on Wed Aug 11 00:50:05 2004
    From: [email protected]

    --EeQfGwPcQSOJBaQU
    Content-Type: text/plain; charset=iso-8859-1
    Content-Disposition: inline
    Content-Transfer-Encoding: quoted-printable

    begin Stephen Gran schrieb am Sun 08. Aug, 18:20 (-0400) :
    This one time, at band camp, J�rg Sommer said:
    begin Stephen Gran schrieb am Sat 22. May, 14:18 (-0400) :

    The patch doesn't work here on a 2.6 kernel (although I am not sure that's the cause). The value of $dev as extracted from /proc/mounts is 'rootfs' - not very helpful for working with.

    Yes, but this sounds very strange, because there is a check "test -e
    $dev" which should never accept rootfs.

    Sorry to take so long getting back to you.

    No problem.

    Yes, the test -e is exactly
    the problem. test -e rootfs is not true, so $ROOT_FS remains unset.

    Well, this is a mistake. I toke the assumtion a root fs is ever existing.
    But on the other hand, this cause is caught by "case $ROOT_DEV in *)"

    These are two runs of my script (The script was modified to read from /tmp/mounts and echo the hdparm command; script attached). One with an
    existing root device node:

    $ cat /tmp/mounts
    rootfs / rootfs rw 0 0
    /dev/root / ext2 rw 0 0
    none /dev devfs rw 0 0
    proc /proc proc rw,nodiratime 0 0
    sysfs /sys sysfs rw 0 0
    devpts /dev/pts devpts rw 0 0
    tmpfs /dev/shm tmpfs rw 0 0
    usbfs /proc/bus/usb usbfs rw 0 0
    /dev/discs/disc0/part4 /var ext3 rw 0 0
    none /tmp tmpfs rw 0 0
    /dev/loop/0 /home/joerg ext3 rw 0 0
    $ /tmp/hdparm.first start
    Setting disc parameters:/sbin/hdparm -q -f /dev/discs/disc0/disc
    /sbin/hdparm -q -m16 -q -W0 -q -c1 /dev/discs/disc0/disc
    /dev/discs/disc0/disc.
    $ /tmp/hdparm start
    Setting disc parameters:/sbin/hdparm -q -f /dev/cdroms/cdrom0
    /sbin/hdparm -q -d1 -q -Xudma2 /dev/cdroms/cdrom0
    /dev/cdroms/cdrom0.

    ...and one with a nonexisting root device node:

    $ cat /tmp/mounts
    rootfs / rootfs rw 0 0
    /dev2/root2 / ext2 rw 0 0
    none /dev devfs rw 0 0
    proc /proc proc rw,nodiratime 0 0
    sysfs /sys sysfs rw 0 0
    devpts /dev/pts devpts rw 0 0
    tmpfs /dev/shm tmpfs rw 0 0
    usbfs /proc/bus/usb usbfs rw 0 0
    /dev/discs/disc0/part4 /var ext3 rw 0 0
    none /tmp tmpfs rw 0 0
    /dev/loop/0 /home/joerg ext3 rw 0 0
    $ /tmp/hdparm.first start
    Warning: Could not find disk device of root partition; running hdparm on all Setting disc parameters:/sbin/hdparm -q -f /dev/discs/disc0/disc
    /sbin/hdparm -q -m16 -q -W0 -q -c1 /dev/discs/disc0/disc
    /dev/discs/disc0/disc,/sbin/hdparm -q -f /dev/cdroms/cdrom0
    /sbin/hdparm -q -d1 -q -Xudma2 /dev/cdroms/cdrom0
    /dev/cdroms/cdrom0.
    $ /tmp/hdparm start

    Reading from /proc/mounts gives a broken answer, and so there's 2
    choices:
    hdparm does not run on the root fs before it is mounted, or
    hdparm runs on all drives twice.

    No. I would prever the old way, that all is run early at boot time.

    Please can you send me a "sh -x" run of the attached scripted with your
    config?

    Bye, J�rg.
    end.
    --
    Alle reden von sexueller Bel�stigung am Arbeitsplatz.. Wenn das nicht
    bald losgeht, k�ndige ICH!

    --EeQfGwPcQSOJBaQU
    Content-Type: text/plain; charset=us-ascii
    Content-Disposition: attachment; filename=hdparm
    Content-Transfer-Encoding: quoted-printable

    #!/bin/sh

    set -e

    case $1 in
    start|restart|reload|force-reload)
    ;;
    stop)
    exit 0
    ;;
    *)
    echo "Usage: $0 {stop|start|restart|reload|force-reload}" >&2
    exit 1
    ;;
    esac

    if grep -w -q "nohdparm" /proc/cmdline ; then
    echo "Skipping setup of disc parameters."
    exit 0
    fi

    raidstat=OK
    if [ -e /proc/mdstat ]; then
    if grep -iq resync /proc/mdstat; then
    raidstat=RESYNC
    fi
    elif [ -e /proc/rd/status ]; then
    raidstat=`cat /proc/rd/status`
    fi

    if ! [ "$raidstat" = 'OK' ]; then
    echo "RAID status not OK. Exiting."
    exit 0
    fi

    while read dev dir junk; do
    if [ -e "$dev" -a "$dir" = / ]; then
    ROOT_DEV=$(readlink --canonicalize $dev)
    break
    fi
    done < /tmp/mounts

    case "$0
  • From Stephen Gran@1:229/2 to All on Thu Aug 12 06:30:11 2004
    From: [email protected]

    This one time, at band camp, J�rg Sommer said:
    begin Stephen Gran schrieb am Sun 08. Aug, 18:20 (-0400) :
    Yes, the test -e is exactly the problem. test -e rootfs is not true,
    so $ROOT_FS remains unset.

    Well, this is a mistake. I toke the assumtion a root fs is ever existing.
    But on the other hand, this cause is caught by "case $ROOT_DEV in *)"

    Reading from /proc/mounts gives a broken answer, and so there's 2
    choices:
    hdparm does not run on the root fs before it is mounted, or
    hdparm runs on all drives twice.

    No. I would prever the old way, that all is run early at boot time.

    Agreed, however there is a third way - I realize. Read from the output
    of mount(1), instead of /proc/mounts. This gives accurate information
    about what is mounted where, in a very compatible way.

    I also am uneasy about the the end user running
    /etc/init.d/hdparm start, and not having all their drives processed -
    not that they should be doing this frequently, but it seems
    counterintuitive otherwise.

    I think the last script I sent does the following:
    If run as /etc/rcS/S06hdparm.first, it only runs on the root disk, but
    reads from mount, rather than /proc
    If run as /etc/rcS/S29hdparm, it does the rest of your disks, skipping
    the root disk
    If run as /etc/init.d/hdparm, it runs on all disks.
    Also includes new parser code to allow people to put straight hdparm
    lines in hdparm.conf in the following format:
    command_line {
    hdparm (options) /dev/hda
    }

    Which I think is a nice addition.

    I would appreciate it if you could take a look at my revision and see if
    it meets your needs and works as expected.

    Please can you send me a "sh -x" run of the attached scripted with your config?

    Below. Note that there is no config - this is just a test run to see
    the parsing for $ROOT_DIR. Below that is a sample run after my
    revision.

    steve@gashuffer:~$ cat /proc/mounts > /tmp/mounts
    steve@gashuffer:~$ sudo sh -x ./hdparm start
    + set -e
    + case $1 in
    + grep -w -q nohdparm /proc/cmdline
    + raidstat=OK
    + '[' -e /proc/mdstat ']'
    + '[' -e /proc/rd/status ']'
    + '[' OK = OK ']'
    + read dev dir junk
    + '[' -e rootfs -a / = / ']'
    + read dev dir junk
    + '[' -e /dev2/root2 -a / = / ']'
    + read dev dir junk
    + '[' -e proc -a /proc = / ']'
    + read dev dir junk
    + '[' -e sysfs -a /sys = / ']'
    + read dev dir junk
    + '[' -e devpts -a /dev/pts = / ']'
    + read dev dir junk
    + '[' -e tmpfs -a /dev/shm = / ']'
    + read dev dir junk
    + '[' -e /dev/hda3 -a /usr = / ']'
    + read dev dir junk
    + '[' -e /dev/hda5 -a /tmp = / ']'
    + read dev dir junk
    + '[' -e /dev/hda6 -a /var = / ']'
    + read dev dir junk
    + '[' -e /dev/hda7 -a /home = / ']'
    + read dev dir junk
    + '[' -e usbfs -a /proc/bus/usb = / ']'
    + read dev dir junk
    + '[' -e 192.168.0.1:/home/music -a /home/mp3 = / ']'
    + read dev dir junk
    + '[' -e 192.168.0.1:/home/movies -a /home/movies = / ']'
    + read dev dir junk
    + '[' -e 192.168.0.1:/home/backups -a /home/backups = / ']'
    + read dev dir junk
    + '[' -e 192.168.0.1:/home -a /usr/share/Server = / ']'
    + read dev dir junk
    + case "$0" in
    + case "$ROOT_DEV" in
    + '[' '' '!=' yes ']'
    + exit 0
    steve@gashuffer:~$ ln hdparm hdparm.first
    steve@gashuffer:~$ sudo sh -x ./hdparm.first start
    + set -e
    + case $1 in
    + grep -w -q nohdparm /proc/cmdline
    + raidstat=OK
    + '[' -e /proc/mdstat ']'
    + '[' -e /proc/rd/status ']'
    + '[' OK = OK ']'
    + read dev dir junk
    + '[' -e rootfs -a / = / ']'
    + read dev dir junk
    + '[' -e /dev2/root2 -a / = / ']'
    + read dev dir junk
    + '[' -e proc -a /proc = / ']'
    + read dev dir junk
    + '[' -e sysfs -a /sys = / ']'
    + read dev dir junk
    + '[' -e devpts -a /dev/pts = / ']'
    + read dev dir junk
    + '[' -e tmpfs -a /dev/shm = / ']'
    + read dev dir junk
    + '[' -e /dev/hda3 -a /usr = / ']'
    + read dev dir junk
    + '[' -e /dev/hda5 -a /tmp = / ']'
    + read dev dir junk
    + '[' -e /dev/hda6 -a /var = / ']'
    + read dev dir junk
    + '[' -e /dev/hda7 -a /home = / ']'
    + read dev dir junk
    + '[' -e usbfs -a /proc/bus/usb = / ']'
    + read dev dir junk
    + '[' -e 192.168.0.1:/home/music -a /home/mp3 = / ']'
    + read dev dir junk
    + '[' -e 192.168.0.1:/home/movies -a /home/movies = / ']'
    + read dev dir junk
    + '[' -e 192.168.0.1:/home/backups -a /home/backups = / ']'
    + read dev dir junk
    + '[' -e 192.168.0.1:/home -a /usr/share/Server = / ']'
    + read dev dir junk
    + case "$0" in
    + BEFORE_ROOT_FSCK=yes
    + case "$ROOT_DEV" in
    + '[' yes '!=' yes ']'
    + echo 'Warning: Could not find disk device of root partition; running hdparm on all'
    Warning: Could not find disk device of root partition; running hdparm on all
    + ROOT_DEV=
    + echo -n 'Setting disc parameters:'
    Setting disc parameters:+ DISC=
    + DEFAULT=
    + OPTIONS=
    + DEF_QUIET=
    + OPT_QUIET=
    + /bin/sync
    + egrep -v '^[[:space:]]*(#|$)' /tmp/hdparm.conf
    + read KEY SEP VALUE
    grep: /tmp/hdparm.conf: No such file or directory
    + printf '\b.\n'
    .
    + exit 0

    steve@gashuffer:~$ sh -x /etc/rcS.d/S07hdparm.first start
    + set -e
    + case $1 in
    + grep -w -q nohdparm /proc/cmdline
    + raidstat=OK
    + '[' -e /proc/mdstat ']'
    + '[' -e /proc/rd/status ']'
    + '[' OK = OK ']'
    ++ /bin/mount
    ++ find_root_dev
    ++ read dev on dir junk
    ++ '[' -e /dev/hda1 -a / = / ']'
    +++ readlink --canonicalize /dev/hda1
    ++ ROOT_DEV=/dev/hda1
    ++ echo /dev/hda1
    ++ break
    + ROOT_DEV=/dev/hda1
    + case $0 in
    + BEFORE_ROOT_FSCK=yes
    + case $ROOT_DEV in
    + ROOT_DEV=/dev/hda
    + echo -n 'Setting disc parameters:'
    Setting disc parameters:+ DISC=
    + DEFAULT=
    + OPTIONS=
    + DEF_QUIET=
    + OPT_QUIET=
    + /bin/sync

    [continued in next message]

    --- SoupGate-Win32 v1.05
    * Origin: you cannot sedate... all the things you hate (1:229/2)