[Bug 2031345] Re: Swap file remains unnecessarily large if system memory size decreases
Launchpad Bug Tracker
2031345 at bugs.launchpad.net
Tue Sep 26 22:20:33 UTC 2023
This bug was fixed in the package ec2-hibinit-agent - 1.0.0-0ubuntu13.3
---------------
ec2-hibinit-agent (1.0.0-0ubuntu13.3) lunar; urgency=medium
* d/p/lp2031345-recreate-swap-file.patch: Reduce SWAP size if current SWAP
is larger than needed (LP: #2031345)
-- Mitchell Dzurick <mitchell.dzurick at canonical.com> Mon, 28 Aug 2023
07:23:22 -0700
** Changed in: ec2-hibinit-agent (Ubuntu Lunar)
Status: Fix Committed => Fix Released
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to ec2-hibinit-agent in Ubuntu.
https://bugs.launchpad.net/bugs/2031345
Title:
Swap file remains unnecessarily large if system memory size decreases
Status in ec2-hibinit-agent package in Ubuntu:
Fix Released
Status in ec2-hibinit-agent source package in Focal:
Fix Released
Status in ec2-hibinit-agent source package in Jammy:
Fix Released
Status in ec2-hibinit-agent source package in Lunar:
Fix Released
Bug description:
Upstream Change - https://github.com/aws/amazon-ec2-hibinit-
agent/commit/d2ce783d10d3a4437ebac468ed669666d8b6671b
[FFE]
====
This change includes a small optimization to resize the swap partition. On hibernation, the contents of RAM is put onto SWAP, so if the amount of RAM reduces, the SWAP file will be too large, and waste space.
[SRU]
====
[Impact]
If an AWS EC2 user decreases the amount of RAM on an instance, unnecessary disk space will be used.
[Test Case]
1. create & start a c5.xlarge instance.
2. Upgrade to the new ec2-hibinit-agent package.
3. Stop the instance.
4. Modified to a smaller instance (c5.large)
5. `journalctl -b | grep "Swap already exists!"` verify swap is recreated
Aug 04 18:19:03 ip-172-31-22-174.ec2.internal hibinit-agent[2457]: Swap already exists! (have 8011616256, need 4194304000), deleting existing swap file /swap since current swap is sufficiently large and wasting memory
7. Stop and restart the instance again
8. `journalctl -b | grep "There's sufficient swap available"` to verified no recreation. of swap occured.
Aug 04 18:23:17 ip-172-31-22-174.ec2.internal hibinit-agent[2452]: There's sufficient swap available (have 4194304000, need 4194304000)
9. Stop the instance
10. Modify to larger (c5.xlarge) instance.
11. Start the instance.
12. `journalctl -b | grep "Swap already exists!"` to verify swap is created due to larger swap required.
Aug 04 18:25:03 ip-172-31-22-174.ec2.internal hibinit-agent[2600]: Swap already exists! (have 4194304000, need 8011620352), deleting existing swap file /swap
[Where things could go wrong]
- If Dynamic swap allocation fails, then hibernation may not properly save the state of the machine.
- Perhaps the user relies on the bigger SWAP size for something else and dynamically resizing on instance change could cause issues? I'd say unlikely but could be a concern.
- [racb] I asked what might happen if a user has increased swap size manually and expects it to stay large. But I'm told that a specific swap filename is used that is specific to hibernation, so it seems reasonable that this would be automatically managed.
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/ec2-hibinit-agent/+bug/2031345/+subscriptions
More information about the foundations-bugs
mailing list