Ubuntu QA:
BlogBrainstormPackage status
Log in
Ubuntu QA
The Ubuntu community has contributed 17459 ideas, 107690 comments, 2263278 votes
Idea sandbox Idea sandbox
Popular ideas Popular ideas
Ideas in development Ideas in development
Implemented ideas Implemented ideas
Idea #14045: put swap partition as swapfile on Ubuntu installation

Written by pyrates the 4 Oct 08 at 03:56. Category: System. Related project: Nothing/Others. Status: New
Rationale
I think we should start thinking about moving the swap partition to just an ordinary swapfile on the partition that Ubuntu is installed onto. This way we don't have to resize partitions if we want to make it smaller or bigger. Then we could put an easy to use GUI in front of it that sets the size of it or if it's automatically managed by the OS instead. By default it should be managed by the OS. OS X and Windows do it this way, so I think Ubuntu should too.

-7
votes
up equal down
Solution #1: How to do this initially
Written by pyrates the 4 Oct 08 at 03:56.
4
votes
up equal down
Solution #2: More elegant solution
Written by pyrates the 12 Feb 09 at 08:32.
1. Move the swap partition to a swap file.
2. Enable it to be configured via the gui but store the configuration in a text file so that those who want to edit it via the command line can.
3. Once configuration is done, apply the changes to it by rebooting the computer. If there is a way to do this without restarting, I'd like to hear it.
4. Default configuration should be on the drive that Ubuntu is installed onto with system managed size.
5. Swap partition should be able to be resized if needed without having to reboot based on how much memory the system needs at any given time.

Propose your solution

Attachments
No attachments.


Duplicates


Comments
brettalton wrote on the 4 Oct 08 at 07:12
You must be a Windows user. Have a file on your partition for swap creates incredible defragmentation which will only create more overhead when searching for files. Why not have it separated with a distinct partition?

zooounds wrote on the 4 Oct 08 at 14:20
I think you cannot hibernate to a swapfile.

Auzy wrote on the 4 Oct 08 at 15:34
@Zooounds, that can be fixed though..

@brattalton check your sources. You allocate the swap file, defrag it once (or ensure its allocated already defragged), and there isn't any fragmentation. The advantage is though, at least the file can expand if you run out of swap file, with a swap partition, stuff will just crash!

pyrates wrote on the 12 Oct 08 at 04:43
Yes I am a windows user. But OS X works this way too because the complexity of having a separate partition for the swap shouldn't be necessary. It's a lot easier resizing a file then it is to resize a swap partition isn't it?

petrosyan@gmail.com wrote on the 3 Dec 08 at 05:52
brettalton, you must be a really stupid user.

Allocate a swap file does NOT create "incredible" defragmentation.

Swapping to a file does not create any extra overhead: http://en.wikipedia.org/wiki/Paging#Linux

@zooounds, you can hibernate to a swap file. You just need to add "resume_offset" command to kernel options, and this is what this idea is all about.

pyrates wrote on the 7 Dec 08 at 07:28
If we can get this implemented, then we can simplify the installation process by allowing the end user to just select which partition to install Ubuntu onto, much like how Windows and OS X does it. They don't involve any complex mount points that you're forced to choose. That unneeded complexity would all be hidden by this.

gnc wrote on the 14 Dec 08 at 00:32

IMHO users should be able to choose at install time between swap file, swap partition or swapless system.

Swap file is as fast as a swap partition.
(http://lkml.org/lkml/2005/7/7/326)

pyrates wrote on the 21 Dec 08 at 01:28
So then according to the link gnc posted, Ubuntu should have no problem switching over to using a swap file instead of a swap partition. Sure does make sense to me.

borsook wrote on the 21 Dec 08 at 14:40
Actually swap partitions work great with windows, system is much faster then simply because windows always fragments swap file whatever one does... ;)

chareos wrote on the 22 Dec 08 at 16:20

A good reason would be that if I add RAM to my PC and my swap parttion is not big enough, I lose my ability to hibernate the system.

Changing swapfile size is much easier than change partition size, am I correct ?

iva2k wrote on the 18 Jan 09 at 05:58
+1 for swapfiles

Swapfile is a very useful feature for my cause. I use MacBookPro with tripple-boot (Mac OSX, Ubuntu, WinXP). Due to various limitations of GRUB, WinXP+BootCamp, MacOSX, EFI, etc, extended partitions cannot be used (can you believe that in 21st century?), so I left with only 4 primary MBR partitions, one of which is taken by EFI/GPT. It leaves no place for a swap partition in the scheme of things on MacBookPro. I did a very easy 5-line prep of a file, and got swap on a file on /.

However, implementers beware! It breaks nice uspalsh boot screen and drops into text mode "Reading files needed to boot..." due to /etc/initramfs-tools/conf.d/resume file content. I found this article that may help to do it properly:
http://www.mjmwired.net/kernel/Documentation/power/swsusp-and-swap-files.txt, however after few hours of trial and error hibernate/resume still does not work and usplash drops out. Usplash is easy to fix by removing "quiet" from kernel boot options. Hibernate seems broken due to a bug (see Ubuntu bug #313724 https://bugs.launchpad.net/ubuntu/+source/gnome-power-manager/+bug/313724).


Post your comment