LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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-14-2008, 10:03 PM   #1
glore2002
Member
 
Registered: Mar 2007
Location: Buenos Aires, Argentina.
Distribution: Lubuntu 17.10 x64
Posts: 510

Rep: Reputation: 33
Is my swap partition enabled or not?


Hello!

Before installing Slackware 12.1 I've created three different partitions as follows:
Swap: Logical -> 6Gb (I have 4Gb RAM installed).
/: Primary -> 20Gb
/home:Primary -> 40Gb

There are also two win partitions (primary NTFS and logical FAT32)

If I run cfdisk, I can see what follows:

Name Flags Part Type FS Type [Label] Size (MB)
------------------------------------------------------------------------------
sda1 Boot Primary NTFS [^G] 64428.62
sda5 Logical W95 FAT32 21476.21
sda6 Logical Linux swap 5996.23
sda3 Primary Linux ext3 20003.89
sda4 Primary Linux ext3 48134.34

Everything works fine. Dual boot (win/slackware). Slackware works OK. But if I type free -m at command prompt I get:

total used free shared buffers cached
Mem: 4051 583 3467 0 37 317
-/+ buffers/cache: 228 3823
Swap: 0 0 0

And where it says Swap, it also says: total 0 (zero) used (0) and free (0). That makes me think that swaps doesn't exist for my Slackware system. Is this true?

Maybe I forgot to mount it while installing or I don't know.

If this were the case, can I tell Slacware now to use that "unused" 6Gb Swap partition?

Thanks in advance,
Glore2002.-
 
Old 06-14-2008, 10:13 PM   #2
tommcd
Senior Member
 
Registered: Jun 2006
Location: Philadelphia PA USA
Distribution: Lubuntu, Slackware
Posts: 2,230

Rep: Reputation: 293Reputation: 293Reputation: 293
It looks like your swap is not being used. Since /dev/sda6 is your swap partition, to activate the swap partition, run as root:
Code:
mkswap /dev/sda6
swapon /dev/sda6
Make sure the swap partition is listed in your /etc/fstab also. 6GB is way too much for a swap partition. With 4GB RAM you will probably never use the swap anyway.
 
Old 06-14-2008, 10:43 PM   #3
shadowsnipes
Senior Member
 
Registered: Sep 2005
Distribution: Slackware
Posts: 1,443

Rep: Reputation: 73
glore2002,

Are you planning on using hibernation? If not then you really probably won't need hardly any (if any) swap ever. 500MB swap is more than enough swap for my computer with about 1.3GB RAM. I hardly ever use swap at all (pretty much only when using virtual machines), and when I have it has never exceeded 16MB.

If you have plenty of hdd space I wouldn't sweat the large swap size. You might need it if you decide to use hibernation anyways.
 
Old 06-14-2008, 10:45 PM   #4
T3slider
Senior Member
 
Registered: Jul 2007
Distribution: Slackware64-14.1
Posts: 2,367

Rep: Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843
You should have this line in your /etc/fstab file:
Code:
/dev/sda6        swap             swap        defaults         0   0
Add that line if it doesn't already exist and reboot. If it still doesn't work, try the `mkswap /dev/sda6` line and then reboot again. If that still doesn't work, you can add it manually without rebooting (`swapon /dev/sda6`), but it won't survive a reboot.

The amount of swap you should use depends on who you talk to. A general consensus seems to be double your physical RAM, but never more than 2 GB. If you have less than 1 GB of physical RAM, your swap should be double your RAM. Otherwise, no more than 2 GB. This is a fairly good rule -- if you use hibernate, your system may use a fair amount of RAM, and therefore a large amount of data will have to be written to the swap. However, this will almost never be more than 2 GB (probably not more than 1 GB) unless you're trying to hibernate while running supercomputer tasks (). Reinstalling from scratch is a lot of work, so unless you think you'll be tight on space it's not necessary -- but you can if you want. You could also try shrinking the swap and subsequently enlarging another partition (using gParted, for example), but this is mildly risky, and I'm not entirely sure if you can resize swap (you probably can, but I'm definitely not positive).
 
Old 06-14-2008, 11:01 PM   #5
shadowsnipes
Senior Member
 
Registered: Sep 2005
Distribution: Slackware
Posts: 1,443

Rep: Reputation: 73
Quote:
Originally Posted by T3slider View Post
I'm not entirely sure if you can resize swap (you probably can, but I'm definitely not positive).
Resizing swap is easy. Delete the partition and make a new swap of the size you want. It's not like you have to save anything in it (unless you are in a hibernated state).

gparted live cd does work well for resizing partitions should it ever be necessary. I generally prefer to keep my swap on a primary partition.
 
Old 06-15-2008, 12:24 AM   #6
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
You also don't need to reboot after adding the line in your fstab -simply type swapon and it will be activated.
 
Old 06-15-2008, 08:17 AM   #7
glore2002
Member
 
Registered: Mar 2007
Location: Buenos Aires, Argentina.
Distribution: Lubuntu 17.10 x64
Posts: 510

Original Poster
Rep: Reputation: 33
Thumbs up Now my swap is being used.

Thank you friends!

Code:
             total       used       free     shared    buffers     cached
Mem:          4051        535       3515          0         23        355
-/+ buffers/cache:        156       3894
Swap:         5718          0       5718

These are the steps I finally took
:

a) First, I have added this line to /etc/fstab:
Code:
/dev/sda6        swap             swap        defaults         0   0
b) Then I ran:

Code:
swapon -a
With swapon you can activate swap partition without rebooting.

Are 6Gb too much? Well, I read a lot of opinions about this and there are as many postures as people are. I think you are right. Well, as an example, I was using Slackware until today without a swap partition and nothing happened.

How did I determined 6Gb as my swap partition? I took it from somewhere that said: Up to 2Gb, double the size for your swap. More than 2Gb RAM, same amount for swap + 2. So, since I have 4Gb RAM, 4 + 2 = 6Gb. I wanted to make sure I wouldn't need a larger swap in the future.

Maybe, resizing the partition now is a little bit risky. If I delete swap partition and create a smaller one (1Gb) as Shadowsnipes suggested How can I add the 5Gb left to -for instance- Slackware / partition? Is that possible without losing data?

Talking about Hibernate. How do I activate that option in Slackware?

Thank you!

Last edited by glore2002; 06-15-2008 at 08:39 AM.
 
Old 06-15-2008, 02:29 PM   #8
T3slider
Senior Member
 
Registered: Jul 2007
Distribution: Slackware64-14.1
Posts: 2,367

Rep: Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843
Quote:
Originally Posted by glore2002
Maybe, resizing the partition now is a little bit risky. If I delete swap partition and create a smaller one (1Gb) as Shadowsnipes suggested How can I add the 5Gb left to -for instance- Slackware / partition? Is that possible without losing data?
Yes, it's possible. Of course, I would never suggest doing this without a backup (things CAN go wrong -- however, they never have for me). You should download the GParted LiveCD and burn it to a CD (or DVD). Go search for a guide on using GParted if it isn't intuitive to to. You can resize your swap partition (and since it doesn't hold any data you don't need to worry about it corrupting anything) and subsequently grow another partition (and since you're increasing, rather than decreasing the size of the partition, it shouldn't damage anything). It would be best to increase the size of the partition immediately neighbouring the swap partition -- I'm not even sure if it's possible to do otherwise, but even if it is, it is probably a bad thing to have one partition on non-consecutive blocks (in the absence of LVM, which you don't need to know anything about). If GParted doesn't let you resize the swap partition, you can just delete it and recreate a smaller one, and then grow the other partition (it accomplishes the same thing).
Quote:
Originally Posted by glore2002
Talking about Hibernate. How do I activate that option in Slackware?
The default 12.1 kernels already have the required options built in to the kernel (and so should your compiled one), so adding hibernation is as easy as adding
Code:
append="resume=/dev/sda6"
where /dev/sda6 is your swap partition to /etc/lilo.conf in your kernel stanza. My kernel stanza looks like this, for your reference:
Code:
image = /boot/vmlinuz-generic-smp-2.6.24.5-smp
  initrd = /boot/initrd.gz
  root = /dev/sda1
  label = Generic
  append="resume=/dev/sda6"
  read-only  # Partitions should be mounted read-only for checking
Of course, then you must run `/sbin/lilo` as root to write the changes to the MBR. To actually hibernate, you use the following command (as root):
Code:
# echo disk > /sys/power/state
That will suspend your system to disk (hibernate), assuming it can find your swap partition (it should be able to find it without trouble if it's activated). To power the system back on, turn on your PC and MAKE SURE that the proper kernel is booted at the LILO boot prompt. You may wish to add the append="resume=/dev/sda6" line as a global configuration, or into each kernel stanza, to ensure that this happens if you frequently switch kernels (I don't know why you would do that, but you never know). It should boot your system into the same state it was in previously.

If done incorrectly, and your system is started up without resuming from swap, you will likely get hard drive errors because the drives are being mounted when they weren't properly unmounted. That's a bad thing. You can usually fix it with an fsck (it's usually done automatically if errors are detected), but it's never a definite thing, so you must be careful.

If you wish to suspend to RAM or standby, you can use the following commands:
Code:
# echo mem > /sys/power/state
Code:
# echo standby > /sys/power/state
They are less risky.

Last edited by T3slider; 06-15-2008 at 02:41 PM.
 
Old 06-15-2008, 10:26 PM   #9
shadowsnipes
Senior Member
 
Registered: Sep 2005
Distribution: Slackware
Posts: 1,443

Rep: Reputation: 73
Quote:
Originally Posted by T3slider View Post
It would be best to increase the size of the partition immediately neighbouring the swap partition -- I'm not even sure if it's possible to do otherwise, but even if it is, it is probably a bad thing to have one partition on non-consecutive blocks (in the absence of LVM, which you don't need to know anything about).
You can grow any supported file system type regardless of the position. It just might take a while, however, as the data has to be physically moved. For instance, if your swap partition is your first partition, you shrink it, and then choose to grow your last partition, you will have to wait for all of the other partitions to move first. For large partitions chock full of data this can take hours.
 
  


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
swap file vs. swap partition verndog Ubuntu 16 07-09-2012 08:49 PM
Hard Drive Partition Management - Mandriva Double Partition with Swap File partition moshebagelfresser Linux - Hardware 2 05-23-2008 10:46 AM
oh Mandriva 2006.0 reboots atfer swap enabled gopi219 Linux - Hardware 1 10-14-2006 10:33 AM
How do I know that my swap is enabled and working properly? mouse46 Linux - Software 9 10-26-2004 07:32 PM
Newbie Installing Debian3 on m68k w/250M Partition Needs help creating swap partition AppleMac Linux - Newbie 2 11-01-2002 08:45 AM

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

All times are GMT -5. The time now is 07:35 PM.

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