LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 06-29-2006, 04:21 PM   #1
Old_Fogie
Senior Member
 
Registered: Mar 2006
Distribution: SLACKWARE 4TW! =D
Posts: 1,519

Rep: Reputation: 63
Old PC forgets about it's own swap partition & mount it. Need help to write a script


Hi all,

For some reason, over the last two weeks my swap partition on dev/hda2 does not get mounted. On bootup before I even get to /etc/rc.d/rc.pcmcia in the boot process, I sometimes get the warning 'unable to find swap space signature' and therefore the pc does activate the 'swapon /dev/hda2'

I verify this is happening by typing 'top' in console.

Once I type 'mkswap /dev/hda2' then 'swapon /dev/hda2' I'm fine.

Is there a way that I can write a script to verify the existence of the swap partition, and if it does not do this then it will type those commands out for me?

I totally dumped the hard drive, I ran a 'debug script' too. Then reloaded, and it still happens, let's say 1 out of every 2 boots.

I do have the swap file correctly keyed into my etc/fstab.

Any thoughts on how I make a script to check this out for me?

thank you in advance.
 
Old 06-29-2006, 04:49 PM   #2
Samoth
Member
 
Registered: Apr 2005
Distribution: Exherbo
Posts: 474
Blog Entries: 1

Rep: Reputation: 32
you could make a script to check "free" and find out if you have any swap. If you dont see any swap then you can turn the swap on.

Another thing, you mention both swap file and swap partition in your post....which one is it(they are most different)? I am led to believe it is a partition, but still....

<<Samoth>>
 
Old 06-29-2006, 06:28 PM   #3
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,215
Blog Entries: 1

Rep: Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067
You can use /proc/swaps to see if swap is activated. Try a script like this:
Code:
#!/bin/sh

if grep -q "/dev/hda2" /proc/swaps; then
echo "swap already ok"
else
/sbin/swapon -a
echo "swap is now ok"
fi
If you need to re-format /dev/hda2, add "/sbin/mkswap /dev/hda2" before swapon.

Regards
 
Old 06-29-2006, 07:14 PM   #4
Old_Fogie
Senior Member
 
Registered: Mar 2006
Distribution: SLACKWARE 4TW! =D
Posts: 1,519

Original Poster
Rep: Reputation: 63
samoth: you are correct, i said swap file near the end of my post there initially. I did mean "swap partition on /dev/hda"

bathory: i'll give it a shot in a little while and report back.

thanks guys.,
 
Old 06-30-2006, 01:39 PM   #5
Old_Fogie
Senior Member
 
Registered: Mar 2006
Distribution: SLACKWARE 4TW! =D
Posts: 1,519

Original Poster
Rep: Reputation: 63
Wouldn't you know I've rebooted this pc about 10 times, and it hasn't forgotten to add the swap partition so I cant verify if the fix works yet or not. LOL

I tell ya, sometimes computers have minds all their own.
 
Old 06-30-2006, 11:52 PM   #6
Old_Fogie
Senior Member
 
Registered: Mar 2006
Distribution: SLACKWARE 4TW! =D
Posts: 1,519

Original Poster
Rep: Reputation: 63
bathory I made a *.sh file and told my /etc/rc.d/rc.local file to execute it on loading up.

I typed out exactly what you had there and also chmod it too.

Finally today, it booted up and did NOT see the swap partition, but it still said "swap already ok" like the script calls for.

I think it is not accurately checking the status of the existence of an active swap partition.

Any other ideas how the script could properly detect the status/existence accurately of the swap partition?

Or did I put my script in the wrong place?

Thank you again.
 
Old 07-01-2006, 08:35 AM   #7
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,215
Blog Entries: 1

Rep: Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067
When you say you didn't saw the swap partition, what is the output of:
Code:
cat /proc/swaps
And what happens if you run the script manually when you see no swap partition?
 
Old 07-01-2006, 10:12 AM   #8
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,961
Blog Entries: 46

Rep: Reputation: 3188Reputation: 3188Reputation: 3188Reputation: 3188Reputation: 3188Reputation: 3188Reputation: 3188Reputation: 3188Reputation: 3188Reputation: 3188Reputation: 3188
Quote:
Originally Posted by Old_Fogie
bathory I made a *.sh file and told my /etc/rc.d/rc.local file to execute it on loading up.

I typed out exactly what you had there and also chmod it too.

Finally today, it booted up and did NOT see the swap partition, but it still said "swap already ok" like the script calls for.

I think it is not accurately checking the status of the existence of an active swap partition.

Any other ideas how the script could properly detect the status/existence accurately of the swap partition?

Or did I put my script in the wrong place?

Thank you again.
Hi,

How about running some HD diagnosis!

What is the output of;
Code:
#hdparm -I /dev/hd?         #replace ? with your device
 
Old 07-03-2006, 12:48 AM   #9
Old_Fogie
Senior Member
 
Registered: Mar 2006
Distribution: SLACKWARE 4TW! =D
Posts: 1,519

Original Poster
Rep: Reputation: 63
cat /proc/swaps gives me the following IF the swap partition is activated upon boot:

Filename Type Size Used Priority
/dev/hda2 partition 514072 668 -1

and the hdparm -i /dev/hda gives me:

Model=TOSHIBA MK6409MAV, FwRev=F5.01 A, SerialNo=
Config={ Fixed }
RawCHS=13424/15/63, TrkSize=0, SectSize=0, ECCbytes=36
BuffType=unknown, BuffSize=0kB, MaxMultSect=16, MultSect=16
CurCHS=13424/15/63, CurSects=12685680, LBA=yes, LBAsects=12685680
IORDY=on/off, tPIO={min:120,w/IORDY:120}, tDMA={min:120,rec:120}
PIO modes: pio0 pio1 pio2 pio3 pio4
DMA modes: sdma0 sdma1 sdma2 mdma0 mdma1 mdma2
UDMA modes: udma0 udma1 *udma2
AdvancedPM=no WriteCache=enabled
Drive conforms to: device does not report version: 1 2 3 4

* signifies the current active mode
 
Old 07-03-2006, 03:47 AM   #10
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,215
Blog Entries: 1

Rep: Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067
The script should work (I've tested it by deactivating my swap partitionan then runing the script to re-activate it). If swap is not activated then /proc/swaps is empty, else it contains what you've posted. I suggest you to remove it from rc.local and run it manually when you see no swap space to see what happens.
 
Old 07-08-2006, 06:19 AM   #11
Old_Fogie
Senior Member
 
Registered: Mar 2006
Distribution: SLACKWARE 4TW! =D
Posts: 1,519

Original Poster
Rep: Reputation: 63
Hi bathory,

I found in the /etc/rc.d/rc.0 script some "sleep" times related to turning off the local hard drives, turning off swap, and performing something called "sync".

Anyway, I just increased the sleep times, actually I just double all of them, and so far so good.

So far it looks like that may?? have been my issue on this old slow laptop. I'll post back if the issue rears it's ugly head, but so far so good. Thank you again for your replies, it is really appreciated.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
how to mount swap partition Xiangbuilder Linux - Newbie 6 11-26-2024 05:48 PM
How to mount a read write NTFS partition CircuitSix Linux - Hardware 3 12-07-2005 03:21 AM
How to write a script for automatic mount Kalyani1 Linux - Software 34 11-03-2005 04:16 PM
How to mount can I write into the partition? homesp Mandriva 3 05-05-2005 11:56 AM
How to mount can I write into the partition? homesp Debian 4 05-05-2005 10:15 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 03:34 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