Live Chat & Podcast at 1:00PM Eastern on Sunday!
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
Linux and Unix
Tag Cloud
access acer asus bios bsod computer crash desktop driver drivers error ethernet excel freeze gaming hard drive hardware hdmi internet laptop malware memory monitor motherboard music netgear network printer problem ram registry router server slow software sound trojan ubuntu 11.10 uninstall usb video virus vista wifi windows windows 7 windows 7 32 bit windows 7 64 bit windows xp wireless
Search
Search for:
Tech Support Guy Forums > Operating Systems > Linux and Unix >
I want a reboot script

Reply  
Thread Tools
trev.h's Avatar
Member with 182 posts.
 
Join Date: Mar 2002
Location: Surrey, England
05-Jul-2002, 07:16 AM #1
Unhappy I want a reboot script
I have an old Dell Optiplex that I use as a home linux server running Mandrake 8.2. It has 2 hard drives installed (hda & hdd). I don't leave the server switched on all the time, only when I need it.

My problem is that "sometime" the first time the PC is switched on the hard drives are not always recognised by the bios. The bios is set to "auto" to detect the drives, there are no manual bios settings that match my drives so I have to use auto. I have also flashed the bios with the latest version from dell. I have tried all sorts of settings to no avail., I suspect the HDD controller is dodgy. I have tried a single ribbon cable as hda & hdb, no joy there.

Anyway, thats just some background. If I reboot (Ctrl+ALt+Del or hit the power button) the drives are "always" found on the second boot.

Now when Linux starts, even though hda & hdd were not found by the bios, Linux manages to find hda and starts the boot. Linux does not however find hdd which has such partitions as swap (it's the faster drive).

What I want to write is a script that, when a partition listed in fstab is not found it issues a 'shutdown -r 0' to reboot. After the reboot it should then find the partitions and continue as normal.

Only trouble is I don't know where to start.

Many thanks
Trev.
codejockey's Avatar
Senior Member with 1,410 posts.
 
Join Date: Feb 2002
05-Jul-2002, 04:48 PM #2
You may not need an entire script to do what you want. I'm not running Mandrake (there's another story there ...) so I can't verify that what I'm about to suggest will work under Mandrake, but it should (8-)). Anyway, consider adding a couple of lines to the system initialization script to check the return code from the mount command. On my (slackware) system, the script is /etc/rc.d/rc.S and the relevant lines are:
Code:
# mount file systems in fstab (and create an entry for /)
# but not NFS or SMB because TCP/IP is not yet configured
/sbin/mount -a -v -t nonfs,nosmbfs
You could add a couple of lines to produce the following:
Code:
# mount file systems in fstab (and create an entry for /)
# but not NFS or SMB because TCP/IP is not yet configured
/sbin/mount -a -v -t nonfs,nosmbfs
RC=$?

if [ $RC -ne 0 ]
then
do
    echo "one or more filesystems could not be mounted ... rebooting"
    shutdown -r now
done
Of course, this could put your machine in an endless loop if one or more mount attempts always fail. You might want to have a boot floppy handy, just in case (8-)).

Hope this helps.
__________________
The slowest component still sits at the keyboard.
trev.h's Avatar
Member with 182 posts.
 
Join Date: Mar 2002
Location: Surrey, England
08-Jul-2002, 07:30 AM #3
Thanks very much, I will try this out and wait for the IDE failure to occur.
trev.h's Avatar
Member with 182 posts.
 
Join Date: Mar 2002
Location: Surrey, England
11-Jul-2002, 06:37 PM #4
Cool A problem solved
Just a quick update on this.

On my Mandrake system the file was /etc/rc.d/rc.sysinit
I added the text as follows after
swapon -a

RC=$?
if [ $RC -ne 0 ]; then
echo "one or more filesystems could not be mounted ... rebooting"
shutdown -r now
fi


It works a treat. Thanks very much.

Trev.
codejockey's Avatar
Senior Member with 1,410 posts.
 
Join Date: Feb 2002
11-Jul-2002, 07:12 PM #5
Great work! You were smart to put the code right after the swapon command; I missed that your second disk contained the swap partition for Linux in your original post -- good thing you were alert! Glad it worked out.

Note, however, that if you ever change your swap partition to a different disk, you may need to move this code (assuming you are still using the problematic disk).

Cheers.

-codejockey
__________________
The slowest component still sits at the keyboard.
Reply

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.
Thread Tools



Facebook Facebook Twitter Twitter TechGuy.tv TechGuy.tv Mobile TSG Mobile
You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 06:37 PM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.