Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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.
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.
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.)
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.
Distribution: Mainly Devuan, antiX, & Void, with Tiny Core, Fatdog, & BSD thrown in.
Posts: 5,493
Rep:
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.
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."
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.
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!
Location: Montreal, Quebec and Dartmouth, Nova Scotia CANADA
Distribution: Arch, AntiX, ArtiX
Posts: 1,364
Rep:
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.