You are not logged in.

#1 2012-09-29 17:42:26

Thom
Member
Registered: 2012-05-22
Posts: 72
Website

to swap or not to swap ?

Hi!

I've got a small question about the swap partition.
I've got a pretty descent computeur with 4Go DDR3 ram ( not noname and 12800 ).

I've not create a swap partition... Could it be a problem ?

I'm not sure to post on the right forum, but it's pretty related to installation...

Last edited by Thom (2012-09-29 17:43:15)

Offline

#2 2012-09-29 17:50:57

headkase
Member
Registered: 2011-12-06
Posts: 1,975

Re: to swap or not to swap ?

Without a swap partition if your computer runs out of RAM then the kernel will begin to randomly kill process' to free RAM.  As long as every application, especially when all loaded at the same time, will stay within the 4GB RAM of your computer then you do not need a swap partition.  However, if you have a larger hard drive then having one wouldn't hurt at all.  The possible issue is that if you do not set up one when you initially install Arch then it may be complicated to do so later on it you find out that your 4GB RAM is inadequate.

I have 4GB of RAM and a 1TB hard drive.  My partition layout is:

200GB               Ext4  /
8GB                 Swap  Swap
Rest of Drive       Ext4  /home

I'd make a swap partition, simpler to do it at the start.

Last edited by headkase (2012-09-29 17:52:04)

Offline

#3 2012-09-29 18:00:36

2ManyDogs
Forum Moderator
Registered: 2012-01-15
Posts: 4,645

Re: to swap or not to swap ?

You're not the first person to ask this question.

https://bbs.archlinux.org/viewtopic.php?id=146691


How to post. A sincere effort to use modest and proper language and grammar is a sign of respect toward the community.

Offline

#4 2012-09-29 19:10:31

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: to swap or not to swap ?

headkase wrote:

The possible issue is that if you do not set up one when you initially install Arch then it may be complicated to do so later on it you find out that your 4GB RAM is inadequate.

I have actually seen numerous reports of people successfully using a swap file.  With the instructions in our glorious wiki, it is supposedly pretty easy.

Offline

#5 2012-09-29 19:28:39

blackout23
Member
Registered: 2011-11-16
Posts: 781

Re: to swap or not to swap ?

I don't even need swap for my 2 GB Laptop with Gnome Desktop and serveral chromium tabs on x86_64. Highest it will ever go is 50-60%. A swap partition is pretty dumb it only wastes space and is not a flexible as a swap file which can be removed and created with just a handful of commands at anytime.

Offline

#6 2012-09-29 19:29:52

headkase
Member
Registered: 2011-12-06
Posts: 1,975

Re: to swap or not to swap ?

WonderWoofy wrote:
headkase wrote:

The possible issue is that if you do not set up one when you initially install Arch then it may be complicated to do so later on it you find out that your 4GB RAM is inadequate.

I have actually seen numerous reports of people successfully using a swap file.  With the instructions in our glorious wiki, it is supposedly pretty easy.

Sorry for the confusion, I meant wink that if you didn't create a swap partition when you initially installed Arch and wanted one later then you would have to muck around with the partition table at that time.  Doing that, while fairly simple, would have a few possible points of failure.  But, yeah, that's what I meant. smile

Last edited by headkase (2012-09-29 19:31:54)

Offline

#7 2012-09-29 19:43:00

Thom
Member
Registered: 2012-05-22
Posts: 72
Website

Re: to swap or not to swap ?

Thanks for all the advices.

I don't create one because I was on a 60go hdd. I've receive my new hdd so the storage won't be a problem anymore.
I will try to follow the wiki and let you know if I've got a problem.

Offline

#8 2012-10-01 13:47:00

drcouzelis
Member
From: Connecticut, USA
Registered: 2009-11-09
Posts: 4,092
Website

Re: to swap or not to swap ?

This interests me. As far as I know I've never used the swap space that I've setup. Maybe the next time a setup a Linux installation I'll just skip th swap partition.

Does anyone know what would happen if I had no swap partition and accidentally put Linux into hibernation, saving the current state of RAM to a "swap partition" that doesn't exist? I ask because I used to use an operating system that, when hibernating, would save to a special RAM-sized partition, and if that partition didn't exist, then the partition with the operating system didn't exist the next time I started the computer. sad

Offline

#9 2012-10-01 14:12:57

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: to swap or not to swap ?

I think it would just fail to hibernate, and would no nothing.

Offline

#10 2012-10-04 06:00:23

hunterthomson
Member
Registered: 2008-06-22
Posts: 794
Website

Re: to swap or not to swap ?

4G of RAM should be fine. Ya, swap files seem cool and more flexable. I have not used a swap parition for a vary long time. One thing you will need though is some kind of memory monitor on your desktop, so you can keep an eye on things. One time, like a year ago, a program I was running had a memory leak. Then my computer started giving loads of errors. I think I had to hard-reboot, but all was find after the reboot and tracking down the memory leaking program.

It is worth noting that the bad memory leak would have resulted in the same thing even with a swap parition. It just would have taken, I guess twice as long.

Last edited by hunterthomson (2012-10-04 06:02:20)


OpenBSD-current Thinkpad X230, i7-3520M, 16GB CL9 Kingston, Samsung 830 256GB
Contributor: linux-grsec

Offline

#11 2012-10-04 06:32:55

eDio
Member
From: Ukraine, Kyiv
Registered: 2008-12-02
Posts: 422

Re: to swap or not to swap ?

Is it a big deal to dedicate 4 gb for swap? It will not slow down your pc if you have enough free memory, anyway.
I use system with 6 GB of memory. My usecases are browsing with firefox (with no disk cache and enlarged memory cache), development in eclipse, running jenkins, tomcat, etc.. Moreover, I always download files up to 1.5 GB directly into ram (/dev/shm) to reduce disk thrash. And only few times system began to swap. However it was nice that I experienced only notable slowdown but didn't lost any of my running applications. So I would go with a swap partition enabled.

Offline

#12 2012-10-04 07:46:34

hunterthomson
Member
Registered: 2008-06-22
Posts: 794
Website

Re: to swap or not to swap ?

eDio: instead of downloading to /dev/shm you can just mount your Downloads directory to a tmpfs like I do.

/etc/fstab

# Mount the downloads folder in to a tempfs
tmpfs           /home/user/Downloads    tmpfs    rw,nodev,noatime,nodiratime,noexec,nosuid,uid=1000,gid=100,mode=700,size=10G 0 0

Last edited by hunterthomson (2012-10-04 07:48:28)


OpenBSD-current Thinkpad X230, i7-3520M, 16GB CL9 Kingston, Samsung 830 256GB
Contributor: linux-grsec

Offline

#13 2012-10-04 08:09:25

Wilco
Member
Registered: 2008-11-09
Posts: 440

Re: to swap or not to swap ?

I've read some post 6-8 years ago about not using a swap partition. It was definitely not recommended to leave out a swap partition.

However, I've been running without swap for a few years now and I've never encountered problems. On the other hand, most systems come with 500GB or larger disks so you can easily miss 4-10GB for swap space.

Offline

#14 2012-10-04 13:17:50

Janusz11
Member
Registered: 2007-05-16
Posts: 87

Re: to swap or not to swap ?

I'd say this really depends on preferences and how one uses his/her box and what they do with it. Personally though I've never really needed any swap and nowadays, with the huge amounts of physical RAM (in my case 8 gig), I wouldn't bother setting up a swap partition anymore. A swap file should do the trick just fine. And the maximum I'd allocate for swap would be 1 GB.

Offline

#15 2012-10-05 14:15:53

glock24
Member
Registered: 2011-01-28
Posts: 6

Re: to swap or not to swap ?

I'll say dedicating more than 1 or 2GB for swap is a waste. If you need an application that requires lots of additional RAM than what you have, it will only run extremely slow using swap, so you're better off buying more RAM.

On the other hand, I have an SSD and disk space is very precious for me,  plus the laptop has 8GB of RAM, so I use no swap.

Using something like  "vm.swappiness = 10" in /etc/sysctl.conf I've not seen the need for swap in the last 5 or 6 years, even on computers with 1GB RAM.

Last edited by glock24 (2012-10-05 14:25:41)

Offline

#16 2012-10-05 16:46:41

bwat47
Member
Registered: 2009-10-07
Posts: 638

Re: to swap or not to swap ?

I use a swap partition slightly bigger than my 4gb of ram, so hibernate will work. I have a large harddrive with lots of free space so space isn't an issue.

Offline

#17 2012-10-05 20:41:07

FlyingHappy
Member
From: Cincinnati, OH
Registered: 2011-04-18
Posts: 192

Re: to swap or not to swap ?

I have 8Gb of RAM in my PC.  The only time I have run over 4 was when compiling android on it, then it ate all 8Gb and into probably 3 of my swap.  Unless you are doing a lot of compiling or really heavy usage, I would say you are fine without it.

Offline

#18 2012-11-27 00:10:36

ismaelvc
Member
From: México, D.F.
Registered: 2012-02-26
Posts: 136

Re: to swap or not to swap ?

You can also try:

https://aur.archlinux.org/packages.php?ID=52958

From AUR.

sudo sytemctl enable zramswap.service

I use it with my laptop:

Every 1,0s: toybox                                                                                   Mon Nov 26 17:39:59 2012


             total       used       free     shared    buffers     cached
Mem:           372        362         10          0         10        103
-/+ buffers/cache:        248        124
Swap:         1396         71       1325

Filename                                Type            Size    Used    Priority
/swapfile                               file    1048572 0       -1
/dev/zram0                              partition       381916  72840   100

cpu MHz         : 500.040 

S.ficheros     Tamao Usados  Disp Uso% Montado en
rootfs            37G    15G   21G  41% /
dev              185M      0  185M   0% /dev
run              187M   268K  187M   1% /run
/dev/sda1         37G    15G   21G  41% /
tmpfs            187M    76K  187M   1% /dev/shm
tmpfs            187M      0  187M   0% /sys/fs/cgroup
tmpfs            187M    92K  187M   1% /tmp
/dev/fd0         1,4M   399K  1,1M  29% /run/media/ismaelvc/disk

acpitz-virtual-0
Adapter: Virtual device
temp1:        +49.0C  (crit = +84.0C)

via686a-isa-6800
Adapter: ISA adapter
Vcore:        +0.06 V  (min =  +3.00 V, max =  +3.10 V)  ALARM
in1:          +0.06 V  (min =  +3.07 V, max =  +1.38 V)  ALARM
+3.3V:        +3.31 V  (min =  +0.96 V, max =  +3.63 V)
+5V:          +3.25 V  (min =  +6.44 V, max =  +6.34 V)  ALARM
+12V:         +7.87 V  (min = +15.54 V, max = +13.62 V)  ALARM
fan1:           0 RPM  (min = 3026 RPM, div = 2)
fan2:           0 RPM  (min =    0 RPM, div = 2)
temp1:        +24.1C  (high = +146.2C, hyst = +23.2C)
temp2:        +24.4C  (high = +146.2C, hyst = +54.4C)
temp3:        +25.3C  (high = +146.2C, hyst = +49.7C)

Its a amd duron 1100, I don't know how fast the HDD is, but zramswap is supposed to be faster than swaping to HDD, I have had no problems its a 10 year old laptop runing MATE (vaio / ati mach64).


Laptop: LG LM70 Express                                                  Kernel: 3.14.2-1-ARCH   
CPU: Intel Pentium M processor @1.86GHz                  Hard Drive: 80G
Video: Mobility Radeon X600                                            X Driver: xf86-video-ati
Memory Size: 1.5G + zramswap: 384M + swap: 3G

Offline

#19 2013-06-27 01:35:35

Ryan
Member
From: UK
Registered: 2012-07-17
Posts: 27

Re: to swap or not to swap ?

I think this is entirely dependent on what you use the computer and not just the amount of RAM you have. I still create a swap partition even although I have 16 gigs of RAM. I'm not sure what would happen if I had no swap but on occasions I end up using swap because I do graphics and sometimes I push things too far. When it goes to swap I stop whatever process is causing it.

Offline

#20 2013-06-27 02:25:29

thesystematic
Member
Registered: 2013-02-08
Posts: 44

Re: to swap or not to swap ?

^ what Ryan said,

It's mostly dependent on what you use the computer for...I have 4GB of RAM and don't use a swap partition, and rarely hit above 2GB with programs running on 7 virtual desktops...if you are using heavy graphics, it might be useful. Aside from that, put a counter in your toolbar so you can see it and create one if you hit > 3GB consistently.

The obvious reason is if you need to hibernate. And for the record, I think depending on your 'swappiness' a swap partition/file CAN slow down your computer because you are using swap and not RAM in some cases....although the measure of that slowdown is probably insignificant.

I think unless you're doing graphics or heavy compiling or some other memory hungry app (CAD, PhotoShop, video editing whatever) don't bother.

Offline

Board footer

Powered by FluxBB