Merge ~aciba/ubuntu/+source/hibagent:lp1896638-path-to-swapfile-by-uuid-bionic into ubuntu/+source/hibagent:ubuntu/bionic-devel

Proposed by Alberto Contreras
Status: Merged
Merge reported by: Robie Basak
Merged at revision: bebafc513ad64708db5d98188883b5f71057bf91
Proposed branch: ~aciba/ubuntu/+source/hibagent:lp1896638-path-to-swapfile-by-uuid-bionic
Merge into: ubuntu/+source/hibagent:ubuntu/bionic-devel
Diff against target: 64 lines (+42/-0)
3 files modified
debian/changelog (+8/-0)
debian/patches/lp1896638-set-resume-device-by-partition-uuid.patch (+33/-0)
debian/patches/series (+1/-0)
Reviewer Review Type Date Requested Status
Simon Chopin (community) Approve
Review via email: mp+440126@code.launchpad.net

Description of the change

Cherry-picked upstream fixes 43636fcf and 0f995e80 in pkg/ubuntu/kinetic-devel:

  * d/p/lp1896638-set-resume-device-by-partition-uuid: Set resume device
    by PARTUUID instead of by name. Thanks to Tony Nie <email address hidden>.
    (LP: #1896638)

Please tag & sponsor.

PPA: ppa:aciba/hibagent-sru-lp1896638-swapfile

Steps to test:

* Launch an EC2 instance
# sudo /usr/bin/enable-ec2-spot-hibernation

* The resume partition is set by device name:
$ grep no_console /boot/grub/grub.cfg
... no_console_suspend=1 resume_offset=780288 resume=/dev/xvda1 ...

* Start a new EC2 instance. This is easier than manually reverting the state back (swap and config files).
# sudo apt-add-repository -ys ppa:aciba/hibagent-sru-lp1896638-swapfile
# sudo apt install -y hibagent
# sudo /usr/bin/enable-ec2-spot-hibernation

* Make sure the agent is active and running:
# systemctl status hibagent

* Make sure the swap is correctly configured:
$ swapon --show
NAME TYPE SIZE USED PRIO
/swap file 3.9G 512K -2

* Make sure the resume partition is defined by uuid:
$ grep no_console /boot/grub/grub.cfg
... no_console_suspend=1 resume_offset=780288 resume=PARTUUID=14aaf7d8-41e2-43b2-b149-a402305a5136 ...

To post a comment you must log in.
bebafc5... by Alberto Contreras

changelog

Revision history for this message
Simon Chopin (schopin) wrote :

Uploaded, with a small adjustment to the version number.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index 6a412fe..6c9c9a9 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,11 @@
6+hibagent (1.0.1-0ubuntu2.18.04.1) bionic; urgency=medium
7+
8+ * d/p/lp1896638-set-resume-device-by-partition-uuid: Set resume device
9+ by PARTUUID instead of by name. Thanks to Tony Nie <zirann@amazon.com>.
10+ (LP: #1896638)
11+
12+ -- Alberto Contreras <alberto.contreras@canonical.com> Fri, 31 Mar 2023 10:02:42 +0200
13+
14 hibagent (1.0.1-0ubuntu1) bionic; urgency=medium
15
16 * Build-depend on python3-all, it is needed by pybuild
17diff --git a/debian/patches/lp1896638-set-resume-device-by-partition-uuid.patch b/debian/patches/lp1896638-set-resume-device-by-partition-uuid.patch
18new file mode 100644
19index 0000000..39ef202
20--- /dev/null
21+++ b/debian/patches/lp1896638-set-resume-device-by-partition-uuid.patch
22@@ -0,0 +1,33 @@
23+From: Tony Nie <zirann@amazon.com>
24+Subject: Set resume device by PARTUUID instead of by device name
25+Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/ec2-hibinit-agent/+bug/1896638
26+Origin: upstream, https://github.com/aws/ec2-hibernate-linux-agent/commit/43636fcf
27+---
28+ agent/hibagent | 7 +++++++
29+ 1 file changed, 7 insertions(+)
30+
31+Index: b/agent/hibagent
32+===================================================================
33+--- a/agent/hibagent 2023-03-24 13:12:50.192981414 +0100
34++++ b/agent/hibagent 2023-03-24 13:17:13.151025129 +0100
35+@@ -99,6 +99,11 @@ def get_swap_space():
36+ return int(lines[0].split()[2]) * 1024
37+
38+
39++def get_partuuid(device):
40++ return check_output(
41++ ['lsblk', '-dno', 'PARTUUID', device]).decode('ascii').strip()
42++
43++
44+ def patch_grub_config(swap_device, offset, grub_file, grub2_dir):
45+ log("Updating GRUB to use the device %s with offset %d for resume" % (swap_device, offset))
46+ lines = []
47+@@ -128,6 +133,8 @@ def patch_grub_config(swap_device, offse
48+ # Do GRUB2 update as well
49+ if grub2_dir and os.path.exists(grub2_dir):
50+ offset_file = os.path.join(grub2_dir, '99-set-swap.cfg')
51++ if swap_device.startswith("/dev"):
52++ swap_device = "PARTUUID=%s" % get_partuuid(swap_device)
53+ if not os.path.exists(offset_file):
54+ with open(offset_file, 'w') as fl:
55+ fl.write('GRUB_CMDLINE_LINUX_DEFAULT="$GRUB_CMDLINE_LINUX_DEFAULT no_console_suspend=1 '
56diff --git a/debian/patches/series b/debian/patches/series
57index eddb8a8..6b13838 100644
58--- a/debian/patches/series
59+++ b/debian/patches/series
60@@ -6,3 +6,4 @@ detect-hibernate-cmd-by-default.patch
61 use-sh-for-init-scripts.patch
62 add-lsb-init-info.patch
63 fix-enable-ec2-spot-hibernation.patch
64+lp1896638-set-resume-device-by-partition-uuid.patch

Subscribers

People subscribed via source and target branches