Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then 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.
I saw the following post in another thread and thought it was interesting:
Quote:
welll here is a tip to increase the size of swap file manually.
#dd if=/dev/zero of=swap bs=1000000 count=1
#chmod 0 swap
make the swap file
#mkswap swap
add to current swap file
#swapon -v swap
chk if it works..
#cat /proc/swap
In Linux you create swap partitions, not files. how can you simply create a swap file and use it? I could see this as a Windows trick, but it doesn't seem logical in Linux, based on what I know. Can someone clarify for me?
I saw the following post in another thread and thought it was interesting:
In Linux you create swap partitions, not files. how can you simply create a swap file and use it? I could see this as a Windows trick, but it doesn't seem logical in Linux, based on what I know. Can someone clarify for me?
I saw the following post in another thread and thought it was interesting:
In Linux you create swap partitions, not files. how can you simply create a swap file and use it? I could see this as a Windows trick, but it doesn't seem logical in Linux, based on what I know. Can someone clarify for me?
A partition is just an entry in the device table, isn't it? One disk device is pretty much the same as another, regardless of what hardware/software it's instantiated in.
Linux has supported swap files (as well as partitions) for as long as I've been playing with it.
Prior to 2.5, the swap file entailed more overhead because it was a file, and needed additional pathlengh (VFS ??? - I dunno, I never looked). For anybody on 2.6 kernels this is no longer a concern - I/O to swap is now handled directly by the blocklayer driver(s). Same for files and partitions regardless.
You can create a file for swap space but its not the best solution in many cases because files have a tendancy, on a well used partition, to not end up sequential which generally slows down access time.
Now that I think about it however, I'd like to see a compile time comparison on a machine with little ram and plenty of swap using various file systems, ext2, ext3, ext4, jfs, xfs, reiserfs, etc.
Swap files ain't "files" - they won't fragment with use. Last I looked at the mkswap code it wasn't very friendly, and made no allowance for non-contiguous allocation. IIRC (nowadays) the space map only has the length, and marks any bad blocks within that range. I don't think I'd allow (subsequent) fragmentation within the originally allocated extent that mkswap knew about.
But then, I don't use swap files, so I don't need to worry about that ...
Swap files ain't "files" - they won't fragment with use. Last I looked at the mkswap code it wasn't very friendly, and made no allowance for non-contiguous allocation. IIRC (nowadays) the space map only has the length, and marks any bad blocks within that range. I don't think I'd allow (subsequent) fragmentation within the originally allocated extent that mkswap knew about.
But then, I don't use swap files, so I don't need to worry about that ...
A true swap "file" won't fragment with use but it may be fragmented to begin with. I've done a good bit of work doing file recovery on ext2/3 file systems so I'm pretty familiar with how files are allocated when using a program like dd... especially in the case of a large file (say a gig) and a heavily used file system (been in production for a long time) you very well may end up with a non-contiguous swap file especially if its very large (>1g). I would have to dig around in the code of mkswap to be absolutely positive, but I can't imagine it even caring if every single block used was non-contiguous.... that becomes something the file system has to deal with. Look at the process slow coder is using to generate the swap file... that *IS* a true file on the file system.
It's a moot point for me too, if i'm dipping into the swap on the system I've got more significant issues than how the swap files are function, but shrug, might as well keep it as accurate as possible.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.