Linux - HardwareThis forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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
# 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
# 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}"
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
;;
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?
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
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
;;
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)
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:
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.
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 !
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)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.