LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-22-2017, 07:26 PM   #1
Skylais
LQ Newbie
 
Registered: Jan 2017
Distribution: centOS
Posts: 7

Rep: Reputation: Disabled
Swap Partition & Root


In terms of performance and security, what are the advantages of creating a swap partition rather than a swap file in root? Would the swap file be able to be accessed easier by unauthorized users, or can the swap file cause file issues within root? Perhaps there are better formats for swap to be used in?
 
Old 01-22-2017, 07:39 PM   #2
masonm
Senior Member
 
Registered: Mar 2003
Location: Following the white rabbit
Distribution: Slackware64, OpenSUSE Tumbleweed
Posts: 2,298

Rep: Reputation: 88
Create a swap partition. If you're concerned about security use an encrypted drive.
 
Old 01-22-2017, 08:02 PM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 18,062

Rep: Reputation: 2895Reputation: 2895Reputation: 2895Reputation: 2895Reputation: 2895Reputation: 2895Reputation: 2895Reputation: 2895Reputation: 2895Reputation: 2895Reputation: 2895
See the rules re posting homework.
 
Old 01-22-2017, 10:27 PM   #4
Skylais
LQ Newbie
 
Registered: Jan 2017
Distribution: centOS
Posts: 7

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by syg00 View Post
See the rules re posting homework.
It's not exactly homework, more of a question that stemmed off of a homework question. I have searched google, delved into 3 Linux security books and all that I can come up with is that on a separate partition the swap would not be as accessible to intruders. Although, with encryption then I suppose it wouldn't matter as much if it was on the same partition. So then what is the real benefit? Is the Linux-swap format better purposes for purely swapping? I can't seem to find a good answer, I understand the point in swapping but not why it should be on a seperate partition besides availability. Even then not sure what types of attack could be done with the Swap file. I'm not trying to cheat or anything like that, I'm honestly trying to understand the file systems and setup of Linux.
 
Old 01-22-2017, 10:30 PM   #5
Skylais
LQ Newbie
 
Registered: Jan 2017
Distribution: centOS
Posts: 7

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by masonm View Post
Create a swap partition. If you're concerned about security use an encrypted drive.
I do have a swap partition, however the question is why the swap file should be on a separate partition. Wouldn't the desperate partition just become a mount point within the file system anyways? At least that's how the reading I have done explains it. It states that all devices are technically just other directories within the file system unlike in windows where separate drive letters are used.
 
Old 01-23-2017, 02:04 AM   #6
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 12,984

Rep: Reputation: 4094Reputation: 4094Reputation: 4094Reputation: 4094Reputation: 4094Reputation: 4094Reputation: 4094Reputation: 4094Reputation: 4094Reputation: 4094Reputation: 4094
swap is not a mounted filesystem and is not mounted as regular filesystems, therefore it not just a directory...
 
1 members found this post helpful.
Old 01-23-2017, 02:44 AM   #7
Jjanel
Member
 
Registered: Jun 2016
Distribution: any&all, in VBox; Ol'UnixCLI; NO GUI resources
Posts: 999
Blog Entries: 12

Rep: Reputation: 361Reputation: 361Reputation: 361Reputation: 361
Hi&'welcome'. Do you have access to a Linux system? (if not, try LinuxZoo.net!)
Look at permissions/mode via ls -l /dev/<disk-swap-partition> and /path/swapFILE
Here's a bunch of info. Basically, both similar.

Actually 'TRY' making and using a swap file. Ok? ??

Are there any "issues[?]" [to the 'root' filesystem] which you are thinking of? I know none.
(For performance, use another/different *disk*: 'load-balancing')

>"Is the Linux-swap format better purposes for purely swapping?"
I'm a bit confused by: "better formats for swap to be used in". (unless ramzswap)
Whatever space setup for swapping to, partition or file, is simply 'blocks of space'.
(feel free to clarify more on the 'format' concept you are asking about) Command: swap -l

Security: same as any disk /dev or /file. UNLESS you boot a forensic 'live'OS or remove drive...

best wishes... let us know. (Mark ThreadTools 'Solved' when done here.)
 
1 members found this post helpful.
Old 01-23-2017, 05:22 AM   #8
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 18,062

Rep: Reputation: 2895Reputation: 2895Reputation: 2895Reputation: 2895Reputation: 2895Reputation: 2895Reputation: 2895Reputation: 2895Reputation: 2895Reputation: 2895Reputation: 2895
Quote:
Originally Posted by Skylais View Post
I'm honestly trying to understand the file systems and setup of Linux.
In that case, congratulations.
And please forgive my terseness.

In a time long ago (maybe even last millenium ?) there was a marked (performance) advantage to having a separate partition(s) for swap. This is a no longer the case.
As for security, it's all over the top IMHO, but encryption is indeed the recommended cure. Until it screws up, and you no longer have a system, .... but I probably digress.
 
1 members found this post helpful.
Old 01-23-2017, 06:04 AM   #9
fatmac
Senior Member
 
Registered: Sep 2011
Location: Upper Hale, Surrey/Hants Border, UK
Posts: 3,092

Rep: Reputation: Disabled
The different ways of having swap, partitions & swap files, were twofold, firstly speed, & second was if you didn't create it when installing or you needed more swap space. Swap files can be created & used as & when you need extra swap space, mounted, unmounted, & then deleted, which was handy when we didn't have a lot of ram.
 
Old 01-23-2017, 08:24 AM   #10
Skylais
LQ Newbie
 
Registered: Jan 2017
Distribution: centOS
Posts: 7

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Jjanel View Post
Hi&'welcome'. Do you have access to a Linux system? (if not, try LinuxZoo.net!)
Look at permissions/mode via ls -l /dev/<disk-swap-partition> and /path/swapFILE
Here's a bunch of info. Basically, both similar.
From that link you posted i actually found some disadvantages to using a swapfile rather than a swap partition:
"A swap file is considered a file within a file system; therefore, when you back up a file system, a rather large swap file (empty file) is also backed up if you don't specifically exclude it.
Because a swap file is simply a file in some file system, you are not able to unmount that file system while the swap file is in use.
This method of creating a swap file has a negative effect on system performance because the swap file is slower than a dedicated swap slice."
 
Old 01-23-2017, 08:28 AM   #11
Skylais
LQ Newbie
 
Registered: Jan 2017
Distribution: centOS
Posts: 7

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by fatmac View Post
The different ways of having swap, partitions & swap files, were twofold, firstly speed, & second was if you didn't create it when installing or you needed more swap space. Swap files can be created & used as & when you need extra swap space, mounted, unmounted, & then deleted, which was handy when we didn't have a lot of ram.
Makes complete since. I've only had 8gb ram systems so when i was first learning about swapping i was somewhat confused as to its importance except as a backup in case of memory overload. However, i do see that while still useful it was probably much more useful in the past.
 
Old 01-23-2017, 08:30 AM   #12
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 12,984

Rep: Reputation: 4094Reputation: 4094Reputation: 4094Reputation: 4094Reputation: 4094Reputation: 4094Reputation: 4094Reputation: 4094Reputation: 4094Reputation: 4094Reputation: 4094
yes, you are right. Additionally swap is used to put onto another drive (if available) which may improve the speed of it.
 
Old 01-23-2017, 08:37 AM   #13
Skylais
LQ Newbie
 
Registered: Jan 2017
Distribution: centOS
Posts: 7

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by syg00 View Post
In that case, congratulations.
And please forgive my terseness.

In a time long ago (maybe even last millenium ?) there was a marked (performance) advantage to having a separate partition(s) for swap. This is a no longer the case.
As for security, it's all over the top IMHO, but encryption is indeed the recommended cure. Until it screws up, and you no longer have a system, .... but I probably digress.
Ha! I have definitely screwed up with encryption before!
and thank you. So i have learned that there is or at least was a performance improvement with swap on a separate partition. This is good, I also learned that apparently there are exploits that can create DOS using the swap file. I am sure back when swap was more heavily used this would have been problem, now days probably not so much. Thanks!
 
Old 01-23-2017, 08:37 AM   #14
Rickkkk
Senior Member
 
Registered: Dec 2014
Location: Montreal, Quebec, CANADA
Distribution: Arch
Posts: 1,104

Rep: Reputation: 417Reputation: 417Reputation: 417Reputation: 417Reputation: 417
I personally, through habit, always use a distinct swap partition, mostly for the reasons you found in Jjanel's link. The swapfile being just that, a file located on the / filesystem of the system's main partition seemed less reliable to me and more prone to performance issues.

Quite frankly, mind you, with the amount of RAM on most systems these days, swap is much more rarely used - some folks don't set up any swap space at all. I always do, just in case I end up doing something very memory-intensive one day, but I admit that this is probably overkill.

Cheers :-)
 
1 members found this post helpful.
Old 01-23-2017, 08:42 AM   #15
Skylais
LQ Newbie
 
Registered: Jan 2017
Distribution: centOS
Posts: 7

Original Poster
Rep: Reputation: Disabled
Alright guys i think i have a better understanding of swap and why it may be better to create a separate partition for it, especially in the past. Hmm... Another advantage i just thought of, is that you could technically have multiple OSs using the same swap partition given they don't run at the same time. Anyhow, i really appreciate it and plan on sticking around here. Lots to learn.
 
1 members found this post helpful.
  


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
Resizing partition in VHD file - root partition first, swap second (*Advanced*) dpesios Linux - Virtualization and Cloud 2 05-18-2012 05:50 AM
Resizing partition in VHD file - root partition first, swap second (*Advanced*) dpesios Linux - Virtualization and Cloud 3 05-17-2012 11:53 AM
Extending Red Hat Linux Partition (/root, /swap & /d01) without restarting (Urgent) umairnazim Red Hat 4 06-16-2011 03:00 PM
Install DSL on root or swap partition?? justasmallcup DamnSmallLinux 9 09-28-2007 12:58 PM
how to expand linux partition & how much swap do i I need? AGazzaz Linux - Software 5 05-03-2006 05:20 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:20 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration