Is the swapfile configured to increase the size dynamically if it is filled up?
Announcement
Collapse
No announcement yet.
Does the swapfile increase size dynamically?
Collapse
This topic is closed.
X
X
-
I believe the answer is "No". It is created a certain size and will not exceed that size. It does dynamically change contents, but the "boundaries" stay the same. Thsi command will show you the size and current usage of your swapfile:
swapon -s
The current practice is to have a swapfile the same size as your RAM or at least 2GB if you have less RAM than that. If you feel like you need to make it larger, you must turn off swap, enlarge the current file, and reset and start it as swap.
The above command would have also revealed where your current swapfile is located. Then, to stop swap and add 2GB to the current file;
sudo swapoff /swapfile
sudo dd if=/dev/zero of=/swapfile bs=1M count=2048 oflag=append conv=notrunc
sudo mkswap /swapfile
sudo swapon /swapfile
In order, the above commands do; stop swap, add 2GB, reset the file as a swapfile, restart swap.
You don't even have to reboot.
- Top
- Bottom
-
Originally posted by oshunluvr View PostI believe the answer is "No". It is created a certain size and will not exceed that size. It does dynamically change contents, but the "boundaries" stay the same. Thsi command will show you the size and current usage of your swapfile:
swapon -s
The current practice is to have a swapfile the same size as your RAM or at least 2GB if you have less RAM than that. If you feel like you need to make it larger, you must turn off swap, enlarge the current file, and reset and start it as swap.
The above command would have also revealed where your current swapfile is located. Then, to stop swap and add 2GB to the current file;
sudo swapoff /swapfile
sudo dd if=/dev/zero of=/swapfile bs=1M count=2048 oflag=append conv=notrunc
sudo mkswap /swapfile
sudo swapon /swapfile
In order, the above commands do; stop swap, add 2GB, reset the file as a swapfile, restart swap.
You don't even have to reboot.
- Top
- Bottom
Comment
-
Doesn't the installer create a swap partition still, or has that changed?
Anyway, it could be simply that it isn't needed, useful, or slows things down. I admit I have never given much thought about it. Linux is by nature a mullti-user, multi-disk, networking OS with finely grained user and group permissions, so I imagine it likely simply much more efficient to use a partition. Also, in a multi boot setup, multiple Linux OS installs will all use the same swap, as Linux will see any exiting swap partition during bootup and automatically use it.
Of course, being Linux, there are options
https://github.com/Tookmund/Swapspace
The original version of this is available in the Ubuntu repos, with the more up to date fork of it shown above is available in 19.04
I think for suspend and hibernate purposes, as static file or partition is required.
I believe with LVM, I bet you can probably automate a swap resize via scripting.Last edited by claydoh; Feb 26, 2019, 06:10 PM.
- Top
- Bottom
Comment
-
Originally posted by claydoh View PostDoesn't the installer create a swap partition still, or has that changed?
Anyway, it could be simply that it isn't needed, useful, or slows things down. I admit I have never given much thought about it. Linux is by nature a mullti-user, multi-disk, networking OS with finely grained user and group permissions, so I imagine it likely simply much more efficient to use a partition. Also, in a multi boot setup, multiple Linux OS installs will all use the same swap, as Linux will see any exiting swap partition during bootup and automatically use it.
Of course, being Linux, there are options
https://github.com/Tookmund/Swapspace
The original version of this is available in the Ubuntu repos, with the more up to date fork of it shown above is available in 19.04
I think for suspend and hibernate purposes, as static file or partition is required.
I believe with LVM, I bet you can probably automate a swap resize via scripting.
- Top
- Bottom
Comment
-
Originally posted by claydoh View PostDoesn't the installer create a swap partition still, or has that changed?
Anyway, it could be simply that it isn't needed, useful, or slows things down. I admit I have never given much thought about it. Linux is by nature a mullti-user, multi-disk, networking OS with finely grained user and group permissions, so I imagine it likely simply much more efficient to use a partition. Also, in a multi boot setup, multiple Linux OS installs will all use the same swap, as Linux will see any exiting swap partition during bootup and automatically use it.
Of course, being Linux, there are options
https://github.com/Tookmund/Swapspace
The original version of this is available in the Ubuntu repos, with the more up to date fork of it shown above is available in 19.04
I think for suspend and hibernate purposes, as static file or partition is required.
I believe with LVM, I bet you can probably automate a swap resize via scripting.
- Top
- Bottom
Comment
Comment