Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swapfile - increase standard size from 512MB to ... #1722

Open
arcolinuxz opened this issue Jun 9, 2021 · 12 comments
Open

Swapfile - increase standard size from 512MB to ... #1722

arcolinuxz opened this issue Jun 9, 2021 · 12 comments

Comments

@arcolinuxz
Copy link
Contributor

We are happy we can have a swapfile instead of a swap partition in Calamares.

The request is to increase the swapfile by default from 512MB to ... GB.

I leave the number up to you.

In the midlong term a slider would be nice to choose the GBs yourself.

@ghost
Copy link

ghost commented Jun 9, 2021

Not sure if I understood. Is this an announcement?

@monetaryabyss
Copy link
Contributor

Not sure if I understood. Is this an announcement?

No, it is a new issue that has been filed.

@adriaandegroot
Copy link
Contributor

The swap file is created in fstab/main.py (don't ask me why it ended up there exactly), and the relevant line is

desired_size = 512 * 1024 * 1024  # 512MiB

Possibilities, in order of amount-of-effort for a PR:

  • just pick another size, like 4GB
  • add config value to fstab.conf to size it
  • in the partition module, re-jig it so you can choose swapfile-small and swapfile-large, and put relevant settings into global storage and read them out here (e.g. let someone else figure out the right size)

@monetaryabyss
Copy link
Contributor

I think leaning on the side of small is good so I wouldn't want to see it set to 4GB. It is a swapfile so you can grow it later if desired and you don't have to worry about it using too much disk out of the gate. That being said, having some ability in the way of a configuration file opens it up for everyone. I would consider either the second or third option as viable if there is a move from the current status.

@killajoe
Copy link
Contributor

options options.. to make swap file implementation complete it would need to add possible hibernate setup also ;)

@arcolinuxz
Copy link
Contributor Author

arcolinuxz commented Jun 23, 2021

I just did a test with a 4GB swap filesize.
I thought the installation was broken/frozen or had just stopped.
Fstab module was on there forever.
fstab

It was creating the 8 x 512 Mb swap
desired_size = 512 * 1024 * 1024 * 8 # 4096MiB
It felt like it took forever.

### is there another way to create it faster?

It installed fine and the swapfile is 4GB
swapbig

upon the second installation I timed how long it takes to create the swapfile of 4GB on a not so slow computer.
it took 86 seconds

Result
swapresult

@arcolinuxz
Copy link
Contributor Author

desired_size = 512 * 1024 * 1024 * 4 # 2048MiB

this takes 56 seconds

@ghost
Copy link

ghost commented Sep 19, 2021

@adriaandegroot is it possible to keep the swapfile size as the double of ram size automatically

@arcolinuxz
Copy link
Contributor Author

timing is important
we do not want users to think the installer crashed
the bigger the swap file the longer it will take
some tool needs to be in place to see the progress on the backend so the users see progression

@killajoe
Copy link
Contributor

# dd if=/dev/zero of=/swapfile bs=1M count=2048 status=progress
should give a progress output -- but is this in any way usable for progress bar?

8133804032 Bytes (8,1 GB, 7,6 GiB) kopiert, 8 s, 1,0 GB/s

dd-progress-2021-09-23_01.35.46.MP4

@adriaandegroot
Copy link
Contributor

There's a couple of largely-independent parts to this issue:

  • creating a big empty file quickly; we use dd here, although elsewhere in Calamares we would instead call write() directly and avoid shelling out to an external program. If there is a faster way to do this that does not create a sparse file, I'm all ears.
  • progress reporting during the write. If we do it by hand (e.g. calling write() in a loop) then we can do reporting by hand, too. Otherwise, we need Support for external callbacks, e.g. for package installing #1740 to get a callback into Python to handle the output of the external process. The good news is that that issue has a work-branch with a pretty clear way forward. The bad news is that that's a pretty hard dependency (unless you do the output processing yourself, in Python -- this has been a request for the packages module as well, for years, which nobody has picked up either, which is why Support for external callbacks, e.g. for package installing #1740 is a hard dependency)
  • making the size configurable or extending the choices in the partitioning module to Swap File (no hibernate) and Swap File (hibernate). Doing that means writing one string and adding it to the drop-down, and then putting the requested size into GS so the later module can pick it up. At that point I'd suggest adding a Swap File (tiny) as well, which keeps the 512MiB implementation, for those that want a file but will resize later.

Those are all PR-able independently -- some are in Python modules, some are in C++ modules, but each is a small change.

@adriaandegroot
Copy link
Contributor

The relevant location is still def create_swapfile(root_mount_point, root_btrfs): in the fstab module (around line 328). You could edit that value. You could make it a configurable value. You could put a value in Global Storage in the partition module, when it decides what the right swap size should be -- and then use it here.

It should not look like it's stalled, not any more, since it reports progress after writing every 16kiB of zeroes to the swapfile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants