LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 07-02-2009, 10:21 PM   #1
zll5267
LQ Newbie
 
Registered: Jun 2009
Location: shanghai,china
Posts: 19

Rep: Reputation: 0
Question How to auto mount the swap space


After I startup my OS ,I find that there is no swap space,But I have made a swap partition.I use the command like 'mkswap /dev/hda5' 'swapon /dev hda5' to mount my swap space,then I use the 'free' to see it ,it's OK!Because I want the OS auto to mount the swap space,I write a new line in '/etc/fstab',like '/dev/hda5 swap swap defaults 0 0'.After that when I use the command 'mount -a',there is wrong.It says'No such file or directory',But I use 'swapon /dev/hda5',there is no problem.How can I do?(my linux version is ttylinux )
 
Old 07-02-2009, 10:57 PM   #2
GrapefruiTgirl
Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
I am not familiar with tty Linux, so I can provide only general advice, based on what I do know a bit of, which is Slackware. I'm providing this advice because I think your question is somewhat of an easy to solve issue but has gone unanswered as yet (maybe because there is more to it than I think!)

In Slackware, and many other distros of Linux, there are 'init scripts' which are shell scripts that get executed when the system is booted and the Linux kernel is setting up the machine for use.
In my script calles 'rc.S' which is the main init script that gets called first, there is the following:

Code:
/sbin/swapon -a
which enables the swapspace.

Assuming ttylinux does use init scripts during boot, you could put a similar line into yours.

I apologize if this will not work for ttylinux, but I hope it helps.

Sasha
 
Old 07-02-2009, 11:01 PM   #3
GrapefruiTgirl
Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
http://minimalinux.org/ttylinux/Docu...ngle/temp.html

Check section 5.2 of the ttylinux documentation at the link above, for the correct file in which to enable your swap space. It appears to be 'rc.sysinit'

Sasha
 
Old 07-03-2009, 01:16 AM   #4
zll5267
LQ Newbie
 
Registered: Jun 2009
Location: shanghai,china
Posts: 19

Original Poster
Rep: Reputation: 0
Hey GrapefruiTgirl!
Thank you for your help!The command 'swapon -a' doesn't work for me.Because after I startup my OS,I use this command,there is no change.I have to do like this:
1: mkswap /dev/hda5 ( /dev/hda5 is a swap partition)
2: swapon /dev/hda5
I use the commands above,then i can see the swap use the 'free'.If i use the 'swapon -a' in the second step,there is nothing too.I edit the /etc/fstab file,it also does't work.May be there is someting wrong about the line I append in the '/etc/fstab',who can tell me how to do?
 
Old 07-03-2009, 08:44 AM   #5
GrapefruiTgirl
Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
OK, if the 'swapon -a' command does not work for you for whatever reason, then simply do what you showed me in post #4, but put that into the init script:

swapon /dev/hda5

Unless there's something about your installation that I don't know about, there's no reason I know of to delete or otherwise 'un-swap' the swap space when you shut down; it will still be swap space when you reboot next time; you should not need to do the `mkswap` command every time you reboot (but if you do, then I guess you do-- but I don't know why that would be).

Sasha

PS - I checked your fstab line against my own swap line in fstab, and they appear to be the same.
 
Old 07-03-2009, 02:33 PM   #6
Kenhelm
Member
 
Registered: Mar 2008
Location: N. W. England
Distribution: Mandriva
Posts: 329

Rep: Reputation: 140Reputation: 140
Check that the last line in fstab has a newline at the end of it.
I once left out the newline and when I later tried to unmount something I received an error message complaining that the final newline was missing in fstab.
 
Old 07-03-2009, 03:31 PM   #7
vap16oct1984
Member
 
Registered: Jun 2009
Location: INDIA
Distribution: RHEL-5
Posts: 174
Blog Entries: 3

Rep: Reputation: 38
Well Zll5276,
Its so simple if you just follow what i am going to tell you. It resolves all your issue.
I have seen many problems relate to partisions, swaps and memory etc. in Linux.

Well i wants to thanks to all who is giving there good advice. Now just go through it, i hope you never got a problem related to swaps.

Pls go through these easy steps for making swap and make it permanent. Let me tell you
you can increase the swap space by two methods. First by making swap partisions and second
by making swap file. After the rest of the process is same for both.

Here your case is seems to be first one i.e you have made a swap partition called /dev/hda5.
And you have mount the partisions by running the command swapon /dev/hda5. And its works fine when you have check the memory by free command.

Now for making it permanent you have put the entry in fstab. This is where you have done the mistake. Thats why when you run mount -a again its shows an error.

So i order to give exact solution i need some help from your side. Pls give the following answer??
1)How you have made the partition /dev/hda? Is it through fdisk?
2)Can you give me the output of the command fsisk -l and df -h?
3)Give me the out put of cat /etc/fstab?

Thanks a lot...
 
Old 07-05-2009, 08:14 PM   #8
zll5267
LQ Newbie
 
Registered: Jun 2009
Location: shanghai,china
Posts: 19

Original Poster
Rep: Reputation: 0
Thank you all above,sure,I made the /dev/hda5 by fdisk,the following is the result of 'fdisk -l ':
 
Old 07-05-2009, 08:25 PM   #9
zll5267
LQ Newbie
 
Registered: Jun 2009
Location: shanghai,china
Posts: 19

Original Poster
Rep: Reputation: 0
Device Boot Start End Blocks Id System
/dev/hda1 1 2000 1007698+ 83 linux
/dev/hda2 2001 4161 1089144 5 Extended
/dev/hda5 2001 3000 503968+ 82 Linux swap
/dev/hda6 3001 4161 585112+ 83 Linux
and the result of 'cat /etc/fstab ' is:
/dev/hda1 / ext2 defaults 0 0
tmpfs /dev tmpfs noauto 0 0
devpts /dev/pts devpts gid=5,mode=0620 0 0
tmpfs /dev/shm tmpfs rw,noexec,nosuid,size=24K 0 0
proc /proc proc noauto 0 0
sysfs /sys sysfs noauto 0 0
/dev/hda5 swap swap defaults 0 0
that's all.
the last line ' /dev/hda5 ...' is added after startup the system.
when I use 'mount -a',the wrong is ' mount: mounting /dev/hda5 on swap failed:No such file or directory'.
 
Old 07-05-2009, 08:26 PM   #10
zll5267
LQ Newbie
 
Registered: Jun 2009
Location: shanghai,china
Posts: 19

Original Poster
Rep: Reputation: 0
I want to know could I put a picture in a post,I can,tell me how to do that.
 
Old 07-05-2009, 08:58 PM   #11
GrapefruiTgirl
Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
Attachments

Quote:
Originally Posted by zll5267 View Post
I want to know could I put a picture in a post,I can,tell me how to do that.
Here's the LQ FAQ page having to do with attachments:
http://www.linuxquestions.org/questi...b3_attachments

Sasha

Last edited by GrapefruiTgirl; 07-05-2009 at 09:02 PM. Reason: Added FAQ link
 
Old 07-06-2009, 02:17 AM   #12
vap16oct1984
Member
 
Registered: Jun 2009
Location: INDIA
Distribution: RHEL-5
Posts: 174
Blog Entries: 3

Rep: Reputation: 38
Talking

Quote:
Originally Posted by zll5267 View Post
Device Boot Start End Blocks Id System
/dev/hda1 1 2000 1007698+ 83 linux
/dev/hda2 2001 4161 1089144 5 Extended
/dev/hda5 2001 3000 503968+ 82 Linux swap
/dev/hda6 3001 4161 585112+ 83 Linux


and the result of 'cat /etc/fstab ' is:
/dev/hda1 / ext2 defaults 0 0
tmpfs /dev tmpfs noauto 0 0
devpts /dev/pts devpts gid=5,mode=0620 0 0
tmpfs /dev/shm tmpfs rw,noexec,nosuid,size=24K 0 0
proc /proc proc noauto 0 0
sysfs /sys sysfs noauto 0 0
/dev/hda5 swap swap defaults 0 0
that's all.
the last line ' /dev/hda5 ...' is added after startup the system.
when I use 'mount -a',the wrong is ' mount: mounting /dev/hda5 on swap failed:No such file or directory'.

Hi dear your problem got resolved just see about the red quotes. Now you think how an why i am saying this. Before giving the solution let me clear few dauts about linux swap partition and swap file system. Let me correct what you have written in your first post. See your post

[QUOTE]After I startup my OS ,I find that there is no swap space,But I have made a swap partition.I use the command like 'mkswap /dev/hda5' 'swapon /dev hda5' to mount my swap space, [\QUOTE]

After i started my OS means what??? You are taking about which OS. I mean if it is linux then which version of linux. either its Redhat, Fedora,Ubanto,Centos,Mandriva etc, Its important to know in which OS your are working as different distro has its own methods and command.

Now come to next question " I find that there is no swap space," that what you have written.
Let me clear you for installing linux atleast two partition is require first is / and second is swap. If you dont have swap partition you can't boot linux. Its not possible to install linux without swap partition. So its not possible that there is no swap. Yes what we can do is that we can increase the swap partition if you needed in future by the about two methods that i mentioned perviously .

so i wish to know which OS you are using and what are the partition you have made at the time installation. And how you install linux without swap partition???

Last edited by vap16oct1984; 07-06-2009 at 02:20 AM.
 
Old 07-06-2009, 05:22 AM   #13
GrapefruiTgirl
Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
*Ahem* Mr vap16oct1984, please notice (from post #1):

Quote:
Originally Posted by Original Poster
(my linux version is ttylinux )
Also:

Quote:
Originally Posted by vap16oct1984
If you dont have swap partition you can't boot linux. Its not possible to install linux without swap partition. So its not possible that there is no swap.
I admit I'm not an overly experienced Linux system admin, but as best as I can tell, this is not accurate at all.

Sasha
 
Old 07-06-2009, 11:38 AM   #14
vap16oct1984
Member
 
Registered: Jun 2009
Location: INDIA
Distribution: RHEL-5
Posts: 174
Blog Entries: 3

Rep: Reputation: 38
Thanks GrapefruiTGirl. I just missed the OS.

Well Zll5265,
As the OS is tty linux i suggest to use the swap file system and it will resolve your issue
permanently. Now Pls follow the these simple steps increase the swap memory.

To add a swap file:
1.Determine the size of the new swap file for example here i am increasing swap space by 100mb .

2.At a shell prompt as root, type the following command with count being equal to the desired block size:
dd if=/dev/zero of=/swapfile bs=1M count=100

3.Setup the swap file with the command:
mkswap /swapfile

4.To enable the swap file immediately but not automatically at boot time:
swapon /swapfile

5.To enable it at boot time, edit /etc/fstab to include:
/swapfile swap swap defaults 0 0

The next time the system boots, it will enable the new swap file.
6.After adding the new swap file and enabling it, make sure it is enabled by viewing the output of the command cat /proc/swaps or free.

I hope this will help you.

Thanks a lot.
 
Old 07-07-2009, 12:40 AM   #15
zll5267
LQ Newbie
 
Registered: Jun 2009
Location: shanghai,china
Posts: 19

Original Poster
Rep: Reputation: 0
Thanks a lot.yesterday I write '/dev/hda5 swap swap defaults 0 0' in the '/etc/fstab',and then restart my OS.although the OS says there is something wrong in /etc/fstab',after startup,I use the 'free' to see,I fount that the swap partition was there.
I can't explain that.
In fact,I use the ttylinux because it's small,I want to know how the linux works.when i'am studing that ,there is much trouble,but i'am happy,because there are many warmhearted person to help me.thank you very much.
Quote:
vap16oct1984,GrapefruiTgirl
 
  


Reply

Tags
swap


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to reduce swap space and reclaim the space grantm Linux - Newbie 7 08-16-2012 07:05 AM
SWAP - having trouble with swap auto mounting at boot lostdj Linux - General 2 08-05-2008 12:47 PM
how much swap space is needed; how to increase swap space? johnpaulodonnell Linux - Newbie 5 03-23-2007 03:20 AM
Failure to mount swap space on boot bleedingturnips Linux - Hardware 5 11-03-2004 01:19 AM
How to unmount actual swap and mount a new(bigger) swap space? isaac Linux - Newbie 1 06-06-2004 01:23 AM


All times are GMT -5. The time now is 03:16 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration