aws / amazon-ec2-hibinit-agent Goto Github PK
View Code? Open in Web Editor NEWLicense: Apache License 2.0
License: Apache License 2.0
The ec2-hibernate-linux-agent repository seems to contain an old version of this project. Also, the Ubuntu 20.04 AMI seems to have the old hibagent
and this hibinit-agent
both preinstalled. It's really confusing.
It looks like the hibinit-agent is currently not doing any checks to determine the underlying filesystem and it uses fallocate when creating swapfiles.
amazon-ec2-hibinit-agent/agent/hibinit-agent
Line 192 in 0224536
It's best to use dd or something other than fallocate for creating swapfiles. There should also be checks to determine the backing filesystem and possibly kernel version as not all file systems (also depends on kernel version/backports) support swapfiles.
https://man.archlinux.org/man/swapon.8#Files_with_holes
https://unix.stackexchange.com/questions/518559/what-are-the-holes-in-files-created-with-fallocate
https://btrfs.readthedocs.io/en/latest/Swapfile.html?highlight=swap%20files
https://bugzilla.redhat.com/show_bug.cgi?id=1129205
https://manpages.ubuntu.com/manpages/xenial/en/man8/mkswap.8.html
Note that a swap file must not contain any holes. Using cp to create the file is not acceptable.
Neither is use of fallocate on file systems that support preallocated files, such as XFS or
ext4, or on copy-on-write filesystems like btrfs. It is recommended to use dd and /dev/zero in
these cases. Please read notes from swapon before adding a swap file to copy-on-write
filesystems.
https://manpages.ubuntu.com/manpages/jammy/en/man8/swapon.8.html
Files with holes
The swap file implementation in the kernel expects to be able to write to the file directly,
without the assistance of the filesystem. This is a problem on files with holes or on copy-on-
write files on filesystems like Btrfs.
Commands like cp or truncate create files with holes. These files will be rejected by swapon.
Preallocated files created by fallocate may be interpreted as files with holes too depending of
the filesystem. Preallocated swap files are supported on XFS since Linux 4.18.
The most portable solution to create a swap file is to use dd and /dev/zero.
Btrfs
Swap files on Btrfs are supported since Linux 5.0 on files with nocow attribute. See the
btrfs manual page for more details.
With setuptools 62.1 and newer, it's not possible to build this package. The error says:
error: Multiple top-level packages discovered in a flat-layout: ['etc', 'agent', 'packaging'].
To avoid accidental inclusion of unwanted files or directories,
setuptools will not proceed with this build.
If you are trying to create a single distribution with multiple packages
on purpose, you should not rely on automatic discovery.
Instead, consider the following options:
1. set up custom discovery (`find` directive with `include` or `exclude`)
2. use a `src-layout`
3. explicitly set `py_modules` or `packages` with a list of names
To find more information, look for "package discovery" on setuptools docs.
When you install ec2-hibinit-agent
to amzn2-ami-minimal, EC2 Hibernation doesn't work as expected.
ec2-hibinit-agent
$ sudo yum update -y
$ sudo yum install ec2-hibinit-agent -y
$ sudo reboot
The instance successfully hibernate.
We expect the following messages in /var/log/messages.
Jan 8 21:56:54 ip-172-31-1-206 kernel: PM: hibernation entry
...
Jan 8 21:56:54 ip-172-31-1-206 kernel: PM: hibernation exit
The instance keeps running.
You might see the following log in /var/log/messages.
Jan 8 21:44:22 ip-172-31-1-206 root: Hibernation failed, Sleeping 2 mins before retry
Looking at /etc/acpi/actions/sleep.sh, it apparently depends on /usr/sbin/pm-hibernate
included in pm-utils
package.
( https://github.com/aws/amazon-ec2-hibinit-agent/blob/master/acpid.sleep.sh#L13 )
swapon --priority=$swap_priority /swap && /usr/sbin/pm-hibernate
If you install pm-utils
, hibernation works as expected.
$ sudo yum install pm-utils
Have just created a new EC2 instance with AMI image: ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-20230516 with a 48gb EBS volume and I have noticed that the root directory contains the following folder structure:
"
> var
> lib
> hibinit-agent"
The top level folder (at same level as boot, dev, etc, home...) is a double quote with a var folder within and so on.
Firstly, am I safe to delete this?
Secondly, how do I reinstall hibinit-agent as it isn't in the directory where I presume from above it should, namely, /var/lib/
Hi,
some cis-hardened operating systems (such as bottlerocket) require an encrypted swap partition due to kernel_lockdown LSM module.
This is a not-uncommon setup/requirement which should be supported
When trying to hibernate an Ubuntu EC2 instance (either through the console or with this procedure), I'm getting the error
Failed to hibernate system via logind: Not enough swap space for hibernation
Looking into the logs with sudo journalctl -u systemd-logind
, I see
/swapfile: is a candidate device.
/swap-hibinit: ignoring device with lower priority
No swap partitions or files matching resume config were found in /proc/swaps.
Running sudo cat /proc/swaps
I see
Filename Type Size Used Priority
/swapfile file 4194300 0 -2
/swap-hibinit file 4095996 0 -3
so that the /swapfile
which I created has higher priority than the /swap-hibinit
file (managed by the Ubuntu-patched hibinit-agent) which is referenced in the grub settings.
Perhaps the priority needs to be set in the swapon
command?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.