LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Swap Partition & Root (https://www.linuxquestions.org/questions/linux-newbie-8/swap-partition-and-root-4175598038/)

Skylais 01-22-2017 07:26 PM

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?

masonm 01-22-2017 07:39 PM

Create a swap partition. If you're concerned about security use an encrypted drive.

syg00 01-22-2017 08:02 PM

See the rules re posting homework.

Skylais 01-22-2017 10:27 PM

Quote:

Originally Posted by syg00 (Post 5658812)
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.

Skylais 01-22-2017 10:30 PM

Quote:

Originally Posted by masonm (Post 5658810)
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.

pan64 01-23-2017 02:04 AM

swap is not a mounted filesystem and is not mounted as regular filesystems, therefore it not just a directory...

Jjanel 01-23-2017 02:44 AM

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:scratch:)
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.)

syg00 01-23-2017 05:22 AM

Quote:

Originally Posted by Skylais (Post 5658844)
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.

fatmac 01-23-2017 06:04 AM

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. :)

Skylais 01-23-2017 08:24 AM

Quote:

Originally Posted by Jjanel (Post 5658897)
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."

Skylais 01-23-2017 08:28 AM

Quote:

Originally Posted by fatmac (Post 5658953)
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.

pan64 01-23-2017 08:30 AM

yes, you are right. Additionally swap is used to put onto another drive (if available) which may improve the speed of it.

Skylais 01-23-2017 08:37 AM

Quote:

Originally Posted by syg00 (Post 5658937)
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!

Rickkkk 01-23-2017 08:37 AM

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 :-)

Skylais 01-23-2017 08:42 AM

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.


All times are GMT -5. The time now is 08:24 PM.