Mourning the loss of our friend, WhitPhil.
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 audio black screen blue screen boot bsod connection crash dell desktop drivers dvd email error excel firefox hard drive hardware hijackthis internet keyboard laptop malware monitor motherboard network networking outlook problem ram recovery router safe mode screen slow sound spyware tdlwsp.dll trojan upgrade vba video virus vista vundo windows windows 7 windows vista windows xp wireless
Search
Search for:
Tech Support Guy Forums > Operating Systems > Linux and Unix >
Solved: Swap file question

Tip: Click here to scan for System Errors and Optimize PC performance
[ Sponsored Link ]

Closed Thread
 
Thread Tools
brokenhead's Avatar
Computer Specs
Senior Member with 144 posts.
 
Join Date: Oct 2006
Experience: Intermediate
23-Nov-2007, 04:17 PM #1
Solved: Swap file question
I dual boot with XP on (hd0,0) and Ubuntu 7.10 on (hd2,0).
When I set Linux up, I have only a 10 GB root (/) partition on (hd2) with a 1 gb swap partition right next to it.

I want my swap partion on a separate hard drive to increase performance (the swap operations can be done simultaneously as other read/writes by a separate head, thereby squeezing a bit more speed out of everything.)

So I used gparted to create a 1 GB swap partition on (hd0). The problem is, how do I get this to mount automatically at start-up? Right now, I have to do it manually by highlighting it in gparted and selecting "swap on." Do I have to edit fstab? And if so, what is the modification I have to make? And then can I delete the original swap partition to force read/writes to go to the new one?
RobLinux's Avatar
Computer Specs
Senior Member with 417 posts.
 
Join Date: Nov 2007
Location: UK
Experience: UNIX/Linux Pro, M$ 'doze Sufferer
23-Nov-2007, 07:28 PM #2
fir:~ # cat /etc/fstab
LABEL=OS10.3-Root / reiserfs noacl 1 1
LABEL=OS10.3-Boot /boot ext2 noacl,noauto 1 2
/dev/disk/by-label/SWAP swap swap pri=2 0 0
/dev/disk/by-label/WINSWAP swap swap pri=4 0 0
proc /proc proc defaults 0 0
sysfs /sys sysfs noauto 0 0

I use LABELS I set when formatting filesystem or swap area, to avoid issues of device names changing on me, when disks get moved on controllers, or accessed via different modules (libata/pata_* or the older IDE drivers).

In this case WINSWAP is on the "other" disk, and is used first.
SWAP is on Linux system disk, but on most systems I'm using SW-<SERIAL>, as I have ended up with multiple versions of Linux on same system for testing purposes etc and the "simple" way would lead to clashes, and using an Distro prefix didnt' seem right for swap area.

On a mirrored system, or with multiple swap areas not on system/application disk, setting pri= to be same, leads to spreading the load. If this matters on your system you should buy yourself some more RAM, rather than put up with lots of paging.

Last edited by RobLinux : 23-Nov-2007 07:34 PM.
brokenhead's Avatar
Computer Specs
Senior Member with 144 posts.
 
Join Date: Oct 2006
Experience: Intermediate
24-Nov-2007, 11:31 AM #3
I'll boot into my Linux momentarily to get at my fstab.

There's not excessive paging going on, just the normal. But when that normal amount does have to take place, it's faster to have it be on it's own partition on a separate disk. I do that with my Windows as well. As long as read/write speeds of the disk selected for paging is comparable to or better than the OS disk, it makes sense to separate them.
brokenhead's Avatar
Computer Specs
Senior Member with 144 posts.
 
Join Date: Oct 2006
Experience: Intermediate
24-Nov-2007, 12:17 PM #4
Here is my current fstab:

# /etc/fstab: static file system information.
#
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc defaults 0 0
# /dev/sdc1
UUID=24ab9661-129d-4f19-bc10-a9d99e55efff / ext3 defaults,errors=remount-ro 0 1
# /dev/sda1
UUID=DA002B2B002B0E57 /media/sda1 ntfs defaults,umask=007,gid=46 0 1
# /dev/sda5
UUID=F898237998233592 /media/sda5 ntfs defaults,umask=007,gid=46 0 1
# /dev/sdb5
UUID=56E07A36E07A1C85 /media/sdb5 ntfs defaults,umask=007,gid=46 0 1
# /dev/sdb6
UUID=C8C82811C827FBF6 /media/sdb6 ntfs defaults,umask=007,gid=46 0 1
# /dev/sdc5
UUID=47195e88-0fdb-4fdb-8005-1b3a49251604 none swap sw 0 0
/dev/scd0 /media/cdrom0 udf,iso9660 user,noauto,exec 0 0
/dev/fd0 /media/floppy0 auto rw,user,noauto,exec 0 0

I guess my question is - what should I substitute for the "none" under the mount point heading for the swap file if I want it to mount automatically when I boot?
RobLinux's Avatar
Computer Specs
Senior Member with 417 posts.
 
Join Date: Nov 2007
Location: UK
Experience: UNIX/Linux Pro, M$ 'doze Sufferer
24-Nov-2007, 01:50 PM #5
Carry on with "none", Debian & Ubuntu have that. Other distro's traditionally write "swap" for the mount point and then "swap" repeated for the filesystem type.

Rather than use a UUID, you can choose a lable like "mkswap -L WINSWAP" and then AFTER NEXT REBOOT there'll be a device with path /dev/disk/by-label/WINSWAP (but swapon -a doesn't grok LABEL=WINSWAP yet, so you must write the pathname).

So what you should do, is alter the "sw" bit before the "0 0", that should set the swap priority with pri=N.

For example if you choose WINSWAP as a lable, then :
dev=/dev/sd??
mkswap -L WINSWAP $dev
echo "/dev/disk/by-label/WINSWAP none swap pri=4 0 0" >> /etc/fstab

Then test by "swapon $dev", which should add the new swap area, and you can check with "swapon -s", on next reboot the label is there and system does "swapon -a" for you.

NB

>> is append, '>' would be disasterous!!

And yes, I used priority to select paging on non-system disk, wheras traditionally I'd use 'striped paging' with 2 swap areas equal priority, because I had a mainly windows disk rather than a mirrored config. The comment about sign of too little RAM, was in regard to need to stripe swap area for performance, RAMs so cheap now it really is possible to run without a swap space at all.

Last edited by RobLinux : 24-Nov-2007 08:46 PM.
brokenhead's Avatar
Computer Specs
Senior Member with 144 posts.
 
Join Date: Oct 2006
Experience: Intermediate
25-Nov-2007, 02:25 PM #6
Interesting comment about RAM being so cheap that it is possible to run w/o a swap file. I was just thinking about that - my RAM is good at 1.5 GB. However, with Windows (any flavor), you are always using some swap file. I've read many a debate in forums about this. No matter how much RAM you have, Windows always keeps some free for anything else that may come its way, and so pages out some memory jobs to the page (swap) file.

With Linux, it appears not to be so. It seems the swap file isn't used unless you exceed physical memory. Therefore, your comment about a swap file is actually true with linux, but not with Windows.

Which makes Linux noticeably faster, if you ask me.

Consider: Say you have 1 GB of RAM but are using several apps at once requiring up to 1.5 GB of memory. It seems Linux will use 100% of the RAM, and page out the extra .5 GB. Windows would keep some RAM open and page out maybe .75 GB. Unless I am wrong about this, it would seem Windows is slower by design because it never makes full use of your physical memory resources. Notice, too, that Linux will run without a swap file, but Windows requires at least 5MB, I believe.

BTW - I solved my mounting problem of the swap file. The UUID was incorrect in fstab and the resume file. Now when I open System Monitor I can see that the system recognizes the swap partition. But as I mentioned above, since RAM usage is low, swap file usage is zero. Windows would be sending some pages back and forth to the hard disk.
RobLinux's Avatar
Computer Specs
Senior Member with 417 posts.
 
Join Date: Nov 2007
Location: UK
Experience: UNIX/Linux Pro, M$ 'doze Sufferer
25-Nov-2007, 11:26 PM #7
This box has 4GB.

I explicitly disabled Vista's swapfile, during "C:" shrinkage, it runs fine without disk based virtual memory, the drawback is loss of hibernate/resume (which actually is not very usable on dual boot system like mine, where I most likely will run Linux). I have done this with past Windows versions to, the only difficulty tends to be the M$ knows best attitude, which frequently causes them to nag you or they even silently reconfigure it, during some adminitrative action (perhaps windows update).

The Linux VM has to maintain a number of free pages, a lot of the past VM issues were caused by various attempts to avoid blocking under memory pressure for too long. As many reads are actually implemented by mapping the file into the VM, there tends to be lots of "clean" pages, which can be reused without saving the page to the swap area.

The reason why is that it is better to evict pages, little and often; otherwise when you come under severe memory pressure (for example during error event handling) you wont' be able to free RAM pages, because the VM itself requires some RAM to save dirty pages to backing store.

What I do notice, is that M$'s hibernate feature runs very quickly, I think that they constantly save RAM to swapfile (except perhaps on laptops when the disk's idle to avoid wasting power spinning it up) so that there's little saving to do for a resume on next boot.
Closed Thread Bookmark and Share

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.

Smart Search

Find your solution!



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


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -5. The time now is 01:54 AM.
Copyright © 1996 - 2009 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.
Powered by Cermak Technologies, Inc.