ALT Linux Team development discussions
 help / color / mirror / Atom feed
From: Vitaly Ostanin <vyt@vzljot.ru>
To: ALT Devel discussion list <devel@altlinux.ru>
Subject: [devel] Re: label detection at boot time
Date: Mon, 16 May 2005 20:30:20 +0400
Message-ID: <4288CA9C.9030609@vzljot.ru> (raw)
In-Reply-To: <4285ADA3.4060205@altlinux.com>


[-- Attachment #1.1: Type: text/plain, Size: 577 bytes --]

Anton Farygin пишет:

<skipped/>

> Рекомендую пересмотреть в корне схему добавления usbroot, написав скрипт
> в /etc/dev.d для блочных устройств.

Postinstall скрипт и системный скрипт из него в аттаче.

При загрузке виснет с kernel oops с упоминанием unionfs, очень
похож на тот oops, что я недавно присылал. Виснет после
добавления бранча на флешке для /etc, после этого реагирует
только на Alt+SysRq.

Livecd сделан из:
kernel-image-std26-up-2.6.11-alt8.i586.rpm
unionfs-utils-1.0.11-alt1.i586.rpm

<skipped/>

--
Regards, Vyt
mailto:  vyt@vzljot.ru
JID:     vyt@vzljot.ru

[-- Attachment #1.2: 05usbroot --]
[-- Type: text/plain, Size: 2289 bytes --]

cat <<E_O_F >> $ROOT/etc/uniontab
/etc
/home
/root
/var/mail
E_O_F

$in_chroot /bin/mkdir -p /etc/dev.d/block


cat <<E_O_F >> $ROOT/etc/dev.d/block/usbdrive.dev
#!/bin/sh -x
#
# USB drive hotplug agent for 2.6 kernels
#
#	ACTION=add
#	DEVPATH=/block/*
#

cd /etc/hotplug
. ./hotplug.functions

SourceIfNotEmpty /etc/sysconfig/hotplug

if [ "\$HOTPLUG" == "no" -o "\$USBPLUG" == "no" ];then
    exit 0
fi

STATEPATH=/var/lib/hotplug

UNIONTAB=/etc/uniontab
UNIONCTL=/usr/sbin/unionctl
MOUNT=/bin/mount
USBROOT=/media/storage_usbroot

[ -x \$UNIONCTL -a -x \$MOUNT ] || exit 1

function restart_services() {
    mesg "Restarting services with \"usbroot\" settings..."
    [ -s \$USBROOT/etc/sysconfig/clock ] && /sbin/service clock start
    [ -d \$USBROOT/etc/net ] && /sbin/service network restart
}

function add_unionfs_branches_to_usbroot() {
    mesg "Adding unionfs branches to \$USBROOT"
    grep -ve '^\(#\|\$\)' \$UNIONTAB |while read mntpt; do
        if [ -d \$mntpt ]; then
	    mkdir -p \$USBROOT/\$mntpt
	    mesg "Adding unionfs rw branch for \$mntpt to \$USBROOT/\$mntpt ..."
	    \$UNIONCTL \$mntpt --add --mode rw \$USBROOT/\$mntpt && \
	    mesg "Successfully added unionfs branch for \$mntpt" || \
	    mesg "Adding unionfs branch for \$mntpt failed."
	fi
	[ \$mntpt == /etc ] && restart_services
    done
}

function mount_usbroot() {
    /bin/mkdir \$USBROOT
    mesg "Trying to mount /dev/\$NAME to \$USBROOT ..."
    \$MOUNT /dev/\$NAME \$USBROOT -o sync && mesg "Successfully mounted." || exit 1
    mesg "Removing \$USBROOT/etc/mtab"
    rm -f \$USBROOT/etc/mtab
    if [ -s \$UNIONTAB ]; then
	add_unionfs_branches_to_usbroot
    fi
}

case \$ACTION in

add)
# FIXME: how to detect LABEL from udev (or HAL) ?
    NAME=\`udevinfo -q name -p \$DEVPATH\`
# FIXME: remove trailing space from blkid output ?
    LABEL=\`blkid /dev/\$NAME -s LABEL | cut -d '=' -f2\`
    [ \$LABEL == \"usbroot\" ] || exit 0
    mesg "Found label \$LABEL on \$DEVPATH"
    mount_usbroot
    exit 0
    ;;
remove)
# FIXME: udevinfo not works without device
    NAME=\`udevinfo -q name -p \$DEVPATH\`
    umount /dev/\$NAME
    exit 0
    ;;
*)
    debug_mesg USB drive \$ACTION event not supported
    exit 1
    ;;

esac

E_O_F

$in_chroot /bin/chmod 755 /etc/dev.d/block/usbdrive.dev

[-- Attachment #1.3: usbdrive.dev --]
[-- Type: text/plain, Size: 2014 bytes --]

#!/bin/sh -x
#
# USB drive hotplug agent for 2.6 kernels
#
#	ACTION=add
#	DEVPATH=/block/*
#

cd /etc/hotplug
. ./hotplug.functions

SourceIfNotEmpty /etc/sysconfig/hotplug

if [ "$HOTPLUG" == "no" -o "$USBPLUG" == "no" ];then
    exit 0
fi

STATEPATH=/var/lib/hotplug

UNIONTAB=/etc/uniontab
UNIONCTL=/usr/sbin/unionctl
MOUNT=/bin/mount
USBROOT=/media/storage_usbroot

[ -x $UNIONCTL -a -x $MOUNT ] || exit 1

function restart_services() {
    mesg "Restarting services with \"usbroot\" settings..."
    [ -s $USBROOT/etc/sysconfig/clock ] && /sbin/service clock start
    [ -d $USBROOT/etc/net ] && /sbin/service network restart
}

function add_unionfs_branches_to_usbroot() {
    mesg "Adding unionfs branches to $USBROOT"
    grep -ve '^\(#\|$\)' $UNIONTAB |while read mntpt; do
        if [ -d $mntpt ]; then
	    mkdir -p $USBROOT/$mntpt
	    mesg "Adding unionfs rw branch for $mntpt to $USBROOT/$mntpt ..."
	    $UNIONCTL $mntpt --add --mode rw $USBROOT/$mntpt && 	    mesg "Successfully added unionfs branch for $mntpt" || 	    mesg "Adding unionfs branch for $mntpt failed."
	fi
	[ $mntpt == /etc ] && restart_services
    done
}

function mount_usbroot() {
    /bin/mkdir $USBROOT
    mesg "Trying to mount /dev/$NAME to $USBROOT ..."
    $MOUNT /dev/$NAME $USBROOT -o sync && mesg "Successfully mounted." || exit 1
    mesg "Removing $USBROOT/etc/mtab"
    rm -f $USBROOT/etc/mtab
    if [ -s $UNIONTAB ]; then
	add_unionfs_branches_to_usbroot
    fi
}

case $ACTION in

add)
# FIXME: how to detect LABEL from udev (or HAL) ?
    NAME=`udevinfo -q name -p $DEVPATH`
# FIXME: remove trailing space from blkid output ?
    LABEL=`blkid /dev/$NAME -s LABEL | cut -d '=' -f2`
    [ $LABEL == \"usbroot\" ] || exit 0
    mesg "Found label $LABEL on $DEVPATH"
    mount_usbroot
    exit 0
    ;;
remove)
# FIXME: udevinfo not works without device
    NAME=`udevinfo -q name -p $DEVPATH`
    umount /dev/$NAME
    exit 0
    ;;
*)
    debug_mesg USB drive $ACTION event not supported
    exit 1
    ;;

esac


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 256 bytes --]

      parent reply	other threads:[~2005-05-16 16:30 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-13 12:09 [devel] FS " Vitaly Ostanin
2005-05-13 12:15 ` Sergey Vlasov
2005-05-13 12:28   ` [devel] " Vitaly Ostanin
2005-05-13 12:49     ` Anton Farygin
2005-05-13 15:07   ` Vitaly Ostanin
2005-05-14  7:49     ` Anton Farygin
2005-05-14  8:13       ` Vitaly Ostanin
2005-05-14 10:18       ` Vitaly Ostanin
2005-05-16 16:30       ` Vitaly Ostanin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4288CA9C.9030609@vzljot.ru \
    --to=vyt@vzljot.ru \
    --cc=devel@altlinux.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

ALT Linux Team development discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/devel/0 devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 devel devel/ http://lore.altlinux.org/devel \
		devel@altlinux.org devel@altlinux.ru devel@lists.altlinux.org devel@lists.altlinux.ru devel@linux.iplabs.ru mandrake-russian@linuxteam.iplabs.ru sisyphus@linuxteam.iplabs.ru
	public-inbox-index devel

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git