LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 07-15-2005, 09:27 AM   #16
sall
Member
 
Registered: Apr 2005
Posts: 50

Original Poster
Rep: Reputation: 15

I do have rc#.d files in the /etc/ directory, but.. they look like this

/etc/rc1.d
/etc/rc2.d
/etc/rc3.d and so on up to /etc/rc6.d

I do not know if this is meaningful or not to the situation.
 
Old 07-15-2005, 09:32 AM   #17
Ben2210
Member
 
Registered: Feb 2004
Location: Toronto
Distribution: Arch
Posts: 146

Rep: Reputation: 16
Ok, so it looks like the people behind Ubuntu decided to use "cool" filenames for the bootscripts.
I don't know Ubuntu, so I don't know where would be the "right" place to mount the USB drive.
But anyway... if you're not afraid of dirty hacks, you can try by yourself.

The goal of the game is to find a script that will be called near the end of the boot process. That has to be later than "hotplug".

A first solution would be to add the mount command at the end of /etc/init.d/hotplug.
That would be quite clean.
If that does not work, try something later in the boot process. Typically, anything involving X will happen late.
Try /etc/init.d/xorg-common.

In any case, in addition to the mount command, add a line like that :
echo "Mounting /dev/sda1 ..."
or
logger "Mounting /dev/sda1 ..."

in order to make sure that your command is actually executed.
 
Old 07-15-2005, 09:36 AM   #18
Ben2210
Member
 
Registered: Feb 2004
Location: Toronto
Distribution: Arch
Posts: 146

Rep: Reputation: 16
Quote:
I do have rc#.d files in the /etc/ directory, but.. they look like this

/etc/rc1.d
/etc/rc2.d
/etc/rc3.d and so on up to /etc/rc6.d

I do not know if this is meaningful or not to the situation.
Yes it is probably meaningful : I guess rcx.d is executed whenever you boot at runlevel x.

Usually, when booting into X, the runlevel is 4 or 5

rc4.d and rc5.d are probably the same file, one is probably a link to the other one, check with ls -l

to know your default runlevel, check /etc/inittab

Then you can edit the relevant rcx.d file. But first try /etc/init.d/hotplug, as explained in my previous post, that would be the cleanest solution.
 
Old 07-15-2005, 09:51 AM   #19
sall
Member
 
Registered: Apr 2005
Posts: 50

Original Poster
Rep: Reputation: 15
Ben 2210 I appreciate all your help, but more is needed.

As I go to add the mount commad to /etc/init.d/hotplug

this is all the info I get:

#!/bin/sh -e
#
# description: Starts and stops each hotpluggable subsystem.
# On startup, may simulate hotplug events for devices
# that were present at boot time, before filesystems
# used by /sbin/hotplug became available.

PATH=/sbin:/bin

[ -x /sbin/hotplug ] || exit 0

. /lib/lsb/init-functions
. /etc/default/rcS
if [ "x$VERBOSE" = "xno" ]; then
MODPROBE_OPTIONS="$MODPROBE_OPTIONS -Q"
export MODPROBE_OPTIONS
fi

if [ ! -f /proc/sys/kernel/hotplug ]; then
log_warning_msg "Kernel hotplug support not enabled."
exit 0
fi

[ -e /etc/default/hotplug ] && . /etc/default/hotplug

# Takes two parameters, list to sort through, and list of elements
# that should be removed from it. Returns prune_output, which is
# the list with the elements removed, and prune_discard, which is
# a list of the discarded elements.
#
# Some days I wish shell had tuples.
prune()
{
unset prune_output prune_discard

for x in ${1}; do
keep=y
for y in ${2}; do
if [ ${x} = ${y} ]; then
keep=n
fi
done
if [ ${keep} = y ]; then
prune_output="${prune_output} ${x}"
else
prune_discard="${prune_discard} ${x}"
fi
done

# echo "1: ${1}"
# echo "2: ${2}"
# echo "prune_output: ${prune_output}"
# echo "prune_discard: ${prune_discard}"

}


# The purpose of this is to generate an ordered list, where the list
# is taken from LIST, and DEPLIST specified the order that elements
# iff they exist must be in.
#
# 1 is the LIST, 2 is the DEPLIST
sort_with_deps()
{
# Get the list of elements that have no ordering requirement
prune "${1}" "${2}"

# Put these at the top of our list
sorted_list=${prune_output}

# Reverse psychology here. Throw away all items of the DEPLIST
# that we actually want. prune_discard will have them in the right
# order
prune "${2}" "${prune_discard}"

# append it to the new list, knowing that dependancies are satisfied.
sorted_list="${sorted_list} ${prune_discard}"

unset prune_output prune_discard

}

run_rcs() {
PRINTK=`cat /proc/sys/kernel/printk`
[ "$VERBOSE" = no ] && echo "0 0 0 0" > /proc/sys/kernel/printk

LIST=/etc/hotplug/*.rc
ORDERING="/etc/hotplug/pci.rc /etc/hotplug/usb.rc /etc/hotplug/ide.rc /etc/hotplug/scsi.rc"

sort_with_deps "${LIST}" "${ORDERING}"

for RC in ${sorted_list}; do
basename=${RC#/etc/hotplug/}
name=${basename%.rc}
[ "$VERBOSE" != no ] && log_begin_msg "Running $basename..."
if [ "$(eval echo \$HOTPLUG_RC_$name)" = no ]; then
[ "$VERBOSE" != no ] && log_end_msg 1 || true
continue
fi
set +e
if [ "$VERBOSE" != no ]; then
$RC $1
RC_STATUS=$?
else
$RC $1 >/dev/null 2>&1
RC_STATUS=$?
fi
set -e
if [ "$1" = status ]; then
continue
fi
[ "$VERBOSE" != no ] && log_end_msg $RC_STATUS || true
done
echo "$PRINTK" > /proc/sys/kernel/printk
return 0
}


case "$1" in
start)
log_begin_msg "Starting hotplug subsystem..."
#echo /sbin/hotplug > /proc/sys/kernel/hotplug
run_rcs $1
log_end_msg 0
;;

stop)
log_begin_msg "Stopping hotplug subsystem..."
run_rcs $1
#echo /bin/true > /proc/sys/kernel/hotplug
log_end_msg 0
;;

restart|force-reload)
log_begin_msg "Restarting hotplug subsystem..."
run_rcs stop
run_rcs start
log_end_msg 0
;;

status)
run_rcs $1
;;

*)
log_success_msg "Usage: $0 {start|stop|restart|status|force-reload}"
exit 1
;;
esac

exit 0
----------------------------------------

So, you are saying Ben2210 to just add:

mount /mnt/usbdrive or whatever the mountpoint after exit 0.... if not after exit 0 then where? or is the command mount /mnt/usb not the correct command?
 
Old 07-15-2005, 10:03 AM   #20
Ben2210
Member
 
Registered: Feb 2004
Location: Toronto
Distribution: Arch
Posts: 146

Rep: Reputation: 16
OK. You're right to ask, because, indeed, the script is quite complicated, and it's important to add the mount command at the right place.

I'd say that you should add the mount command here :

Quote:
case "$1" in
start)
log_begin_msg "Starting hotplug subsystem..."
#echo /sbin/hotplug > /proc/sys/kernel/hotplug
run_rcs $1
log_end_msg 0
;;
change it into that :

Quote:
case "$1" in
start)
log_begin_msg "Starting hotplug subsystem..."
#echo /sbin/hotplug > /proc/sys/kernel/hotplug
run_rcs $1

echo "Mounting /dev/sda1 in 5 seconds..."
sleep 5
mount /dev/sda1

log_end_msg 0
;;

Later you can try removing the sleep 5, or reduce the sleep.
 
Old 07-15-2005, 10:05 AM   #21
Ben2210
Member
 
Registered: Feb 2004
Location: Toronto
Distribution: Arch
Posts: 146

Rep: Reputation: 16
But, ahem, actually, it starts looking like hotplug is not the right place...
perhaps try xorg-common or rc5.d...
 
Old 07-15-2005, 10:07 AM   #22
sall
Member
 
Registered: Apr 2005
Posts: 50

Original Poster
Rep: Reputation: 15
Alright sounds good I will give it a shot just after one more question. If I dont have fstab pointing to mount the drive at /mnt/usb it usually mounts at /media/sda1 should I keep the fstab mount I have currently at /mnt/usb or remove and mount at /media/sda1 without any fstab entry for the HD
 
Old 07-15-2005, 10:11 AM   #23
sall
Member
 
Registered: Apr 2005
Posts: 50

Original Poster
Rep: Reputation: 15
xorg-common seems to be a bit different at the "case$" area:

#!/bin/sh
# /etc/init.d/xorg-common: set up the X server and ICE socket directories

set -e

PATH=/bin:/usr/bin:/sbin:/usr/sbin
SOCKET_DIR=/tmp/.X11-unix
ICE_DIR=/tmp/.ICE-unix

. /lib/lsb/init-functions
. /etc/default/rcS

do_restorecon () {
# Restore file security context (SELinux).
if which restorecon >/dev/null 2>&1; then
restorecon "$1"
fi
}

set_up_socket_dir () {
if [ "$VERBOSE" != no ]; then
log_begin_msg "Setting up X server socket directory $SOCKET_DIR..."
else
log_begin_msg "Setting up X server socket directory..."
fi
if [ -e $SOCKET_DIR ] && [ ! -d $SOCKET_DIR ]; then
mv $SOCKET_DIR $SOCKET_DIR.$$
fi
mkdir -p $SOCKET_DIR
chown 0:0 $SOCKET_DIR
chmod 1777 $SOCKET_DIR
do_restorecon $SOCKET_DIR
log_end_msg 0
}

set_up_ice_dir () {
if [ "$VERBOSE" != no ]; then
log_begin_msg "Setting up ICE socket directory $ICE_DIR..."
else
log_begin_msg "Setting up ICE socket directory..."
fi
if [ -e $ICE_DIR ] && [ ! -d $ICE_DIR ]; then
mv $ICE_DIR $ICE_DIR.$$
fi
mkdir -p $ICE_DIR
chown 0:0 $ICE_DIR
chmod 1777 $ICE_DIR
do_restorecon $ICE_DIR
log_end_msg 0
}

case "$1" in
start)
set_up_socket_dir
set_up_ice_dir
;;

restart|reload|force-reload)
/etc/init.d/xorg-common start
;;

stop)
:
;;

*)
log_success_msg "Usage: /etc/init.d/xorg-common {start|stop|restart|reload|force-reload}"
exit 1
;;
esac

exit 0

# vim:set ai et sts=2 sw=2 tw=0:


I am not tryin to rendor my computer in operable by messing this up... so, where exacly do I place the:

echo "Mounting /dev/sda1 in 5 seconds..."
sleep 5
mount /dev/sda1


Thanks
 
Old 07-15-2005, 10:19 AM   #24
Ben2210
Member
 
Registered: Feb 2004
Location: Toronto
Distribution: Arch
Posts: 146

Rep: Reputation: 16
You can perfectly mount your drive without a fstab entry, however it's not optimal ! It's a good idea to use fstab whenever possible. So setup your fstab the way you like, and then use it to mount your drive. But you're free to choose any empty directory as mountpoint.

If Ubuntu has some preferred mountpoint for the USB key, you should probably keep that unchanged. If it's /media/sda1, you can edit fstab accordingly.

I hope I answered to your question (didn't fully understand)

As for your last post :

All I see is that xorg-common isn't a very comfortable place either ! what about rc5.d (also check your runlevel in /etc/inittab)
 
Old 07-15-2005, 10:27 AM   #25
sall
Member
 
Registered: Apr 2005
Posts: 50

Original Poster
Rep: Reputation: 15
Yes, your respionse to fstab question makes sense to me, I did no think it mattered. Anyways, since you suggested not using xorg-common and trying rc5.d, I cd to the directory rc5.d and did an ls this the output:

craig@laptop:~$ cd /etc/rc5.d
craig@laptop:/etc/rc5.d$ ls
K08vmware S12alsa S20apmd S20postfix S25mdadm S99acpi-support
K11anacron S13gdm S20dbus-1 S20powernowd S89anacron S99fetchmail
S05vbesave S14ppp S20inetd S20rsync S89atd S99rmnologin
S10sysklogd S19cupsys S20makedev S20samba S89cron S99stop-bootlogd
S11klogd S20acpid S20pcmcia S21kdm S90vmware
craig@laptop:/etc/rc5.d$

which do u recomend I attempt to add the:

echo "Mounting /dev/sda1 in 5 seconds..."
sleep 5
mount /dev/sda1

And I also tried the /etc/inittab and recieved the permission denied error whether logged into root or not...
 
Old 07-15-2005, 10:31 AM   #26
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,691

Rep: Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894
(excerpt from another linux forum)
Quote:
The question is "What's the Debian equivalent of rc.local" or "Where can I put startup commands in Debian?"

Here's a quick step-by-step guide to one way to do this:

1. Execute this command to find your default runlevel:
cat /etc/inittab | grep initdefault
You should see a line like this:
id:2:initdefault:
That means 2 is your default runlevel. This may also be 3, or rarely 4 or 5.

2. Create your rc.local file like this (as root):
touch /etc/init.d/rc.local
chmod 774 /etc/init.d/rc.local

3. Set it to be run at boot time by doing this:
ln -s /etc/init.d/rc.local /etc/rcX.d/S99local
(this command should also work: update-rc.d -f rc.local start 99 2 3 4 5 )

4. Replace the X with your default runlevel from step one. For example, rc2.d.
Edit your /etc/init.d/rc.local script.
This will cause your rc.local script to be run last during the bootup process (because of the 99). This is generally what you want to do, to make sure all the basic services are started before your custom startup script runs.


/etc/inittab is a text file. You should be able to view it via any editor.

Last edited by michaelk; 07-15-2005 at 10:34 AM.
 
Old 07-15-2005, 10:33 AM   #27
Ben2210
Member
 
Registered: Feb 2004
Location: Toronto
Distribution: Arch
Posts: 146

Rep: Reputation: 16
You can thank michaelk a lot because this is the solution !

And sorry michaelk for having "stolen" your newbie


EDIT : ignore the "This may also be 3, or rarely 4 or 5."
It's obviously referring to an archaic Debian configuration. Nowadays almost everyone boots in runlevel 4 or 5, especially with newbie-friendly distros like Ubuntu.

I hope that these instructions, which refer to an old version of Debian, still apply to Ubuntu !

Last edited by Ben2210; 07-15-2005 at 10:41 AM.
 
Old 07-15-2005, 10:44 AM   #28
sall
Member
 
Registered: Apr 2005
Posts: 50

Original Poster
Rep: Reputation: 15
Alright I did what michael k has suggested. All goes well. One problem as I am "Newbie" I have two problems...

1. the rc.local I created is blank(is this correct?)

and

2. What exact command do I enter into /etc/init.d/rc.local to properly load my drive that is mounted at /mnt/usbdrive and the device is /dev/sda1
 
Old 07-15-2005, 10:49 AM   #29
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,691

Rep: Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894
I'm not a Debian expert so hopefully it will get you in the correct direction.

Just edit the rc.local and enter the command to mount the drive.
#!/bin/sh
mount /mnt/sda1

Last edited by michaelk; 07-15-2005 at 10:51 AM.
 
Old 07-15-2005, 10:50 AM   #30
Ben2210
Member
 
Registered: Feb 2004
Location: Toronto
Distribution: Arch
Posts: 146

Rep: Reputation: 16
Of course it's blank : The command "touch" creates an empty file.
You can then edit it with any text editor, as root. For example you can try pico or nano, they are nice little text-mode editors.
If your fstab is properly set up, just write this in rc.local :

Code:
#!/bin/sh
/bin/mount /dev/sda1
if your mount program is in the /bin directory. (check that. Perhaps it's /sbin or /usr/bin)

Last edited by Ben2210; 07-15-2005 at 10:51 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
MDK 9.2 cannot mount Ext USB hard drive dr_skids Linux - Hardware 0 11-06-2005 11:56 AM
usb mount hard drive rpetrenko SUSE / openSUSE 2 10-07-2005 12:49 AM
I can mount a usb hard drive fiacobelli Linux - Hardware 3 07-06-2005 01:52 PM
Mounting Ext. Hard Drive through USB 2+PCMCIA CondorPasa Linux - Hardware 1 03-11-2004 06:49 AM
mount usb module then mount usb hard drive guanyu Linux - Hardware 1 10-08-2003 11:50 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 05:33 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration