From 308d301b6e48f9fa81f793ebac85a9ae0407528b Mon Sep 17 00:00:00 2001 From: HORIE <26223147+suikan4github@users.noreply.github.com> Date: Thu, 14 May 2026 13:08:04 +0000 Subject: [PATCH 01/16] Add devcontainer.json for development environment. --- .devcontainer/devcontainer.json | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index ddcb2f5..05d3c91 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -5,11 +5,21 @@ // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile "build": { "dockerfile": "Dockerfile" - } + }, // Features to add to the dev container. More info: https://containers.dev/features. // "features": {}, + // Configure tool-specific properties. + "customizations": { + "vscode": { + "extensions": [ + "StefanMayrhofer.shellspec-tester", + "timonwong.shellcheck" + ] + } + }, + // Use 'forwardPorts' to make a list of ports inside the container available locally. // "forwardPorts": [], From 849363709a961427a1c746fb3b68c92c008dd54f Mon Sep 17 00:00:00 2001 From: HORIE <26223147+suikan4github@users.noreply.github.com> Date: Fri, 15 May 2026 23:39:35 +0000 Subject: [PATCH 02/16] Add comment to suppress warning about empty commit message. --- spec/save_original_swap_size_spec.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/save_original_swap_size_spec.sh b/spec/save_original_swap_size_spec.sh index e8d2e66..73cf48e 100644 --- a/spec/save_original_swap_size_spec.sh +++ b/spec/save_original_swap_size_spec.sh @@ -5,7 +5,9 @@ Include 'lib/functions.sh' Describe 'save_original_swap_size function' # Mock of write_stream() function write_stream() { + # shellcheck disable=SC2034 STREAM="$1" + # shellcheck disable=SC2034 FILENAME="$2" return 0; } From b48f56634d5a44ddffb692120aeff7a112d8e209 Mon Sep 17 00:00:00 2001 From: HORIE <26223147+suikan4github@users.noreply.github.com> Date: Fri, 15 May 2026 23:40:52 +0000 Subject: [PATCH 03/16] Remove trailing comma in devcontainer.json. --- .devcontainer/devcontainer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 05d3c91..a0f1ae9 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -18,7 +18,7 @@ "timonwong.shellcheck" ] } - }, + } // Use 'forwardPorts' to make a list of ports inside the container available locally. // "forwardPorts": [], From b3011694d219a95a0a421a3e87e38fa6e7b6ba9f Mon Sep 17 00:00:00 2001 From: HORIE <26223147+suikan4github@users.noreply.github.com> Date: Sat, 16 May 2026 00:39:50 +0000 Subject: [PATCH 04/16] Changed backupg strategy. This is required to fix the issue #16. - If backup file exists, skipt to override it. - After reverting, the backup file is removed. --- fuyujitaku.sh | 2 +- lib/functions.sh | 42 +++++++++----- revert.sh | 27 +++++++-- spec/inform_swap_location_to_kernel_spec.sh | 4 +- spec/save_original_config_spec.sh | 62 +++++++++++++++++++++ spec/save_original_swap_size_spec.sh | 27 --------- 6 files changed, 114 insertions(+), 50 deletions(-) create mode 100644 spec/save_original_config_spec.sh delete mode 100644 spec/save_original_swap_size_spec.sh diff --git a/fuyujitaku.sh b/fuyujitaku.sh index 3670f49..c20b622 100755 --- a/fuyujitaku.sh +++ b/fuyujitaku.sh @@ -68,7 +68,7 @@ case "$RESPONSE" in esac echo "" -save_original_swap_size +save_original_config # If it returns non zero, abort the script. resize_swap_file diff --git a/lib/functions.sh b/lib/functions.sh index e5c8347..7a8b71e 100644 --- a/lib/functions.sh +++ b/lib/functions.sh @@ -1,5 +1,17 @@ #!/bin/sh +# Check whether the backup directory exists. +# Return true(0) if it exists, false(1) if it does not exist. +# This is helper function for the test to check whether the backup directory is created. +backup_dir_exists() { + BACKUPDIR=$(get_backup_dir_name) + if [ -d "$BACKUPDIR" ]; then + return 0 + else + return 1 + fi +} + # Write a stream to a file. # This is a helper function to make test easier. # Usage: @@ -201,15 +213,25 @@ validate_swap_file_size() { # Save original swap size -save_original_swap_size() { +save_original_config() { # This directory is shared with inform_swap_location_to_kernel() function. BACKUPDIR=$(get_backup_dir_name) SWAPSIZEFILE=$(get_original_swap_size_file_name) - mkdir -p "$BACKUPDIR" - ORIGINAL_SWAP_SIZE=$(free --mega | awk '/Swap:/{print $2}') - write_stream "$ORIGINAL_SWAP_SIZE" "$BACKUPDIR/$SWAPSIZEFILE" + # if the backup directory does not exist, create it and save the original swap size and grub file. + # if not, skip creating it because it may contain the backup files. + if ! backup_dir_exist; then + # Create backup directory. + mkdir -p "$BACKUPDIR" + # Get the original swap size in MByte and save it to a file. + ORIGINAL_SWAP_SIZE=$(free --mega | awk '/Swap:/{print $2}') + write_stream "$ORIGINAL_SWAP_SIZE" "$BACKUPDIR/$SWAPSIZEFILE" + + # Get the file name to store original grub. + GRUBFILE=$(get_original_grub_file_name) + copy_grub "$BACKUPDIR/$GRUBFILE" + fi return 0 } @@ -276,9 +298,6 @@ resize_swap_file() { inform_swap_location_to_kernel() { echo "----------- Editing GRUB configuration -----------" - # Get the file name to store original grub. - GRUBFILE=$(get_original_grub_file_name) - # Get the UUID of the root filesystem (where the swap file stays). UUID=$(findmnt / -o UUID --noheadings) @@ -291,9 +310,8 @@ inform_swap_location_to_kernel() { # Save the current GRUB configuration to a temporary file. TEMP_GRUB=$(mktemp) - SAVED_GRUB=$(mktemp) copy_grub "$TEMP_GRUB" - copy_grub "$SAVED_GRUB" + # If the grub configuration contains resume/resume_offset, remove them first. sudo sed -i /^GRUB_CMDLINE_LINUX_DEFAULT/s/resume[_=a-zA-Z0-9-]*//g $TEMP_GRUB @@ -312,14 +330,8 @@ inform_swap_location_to_kernel() { update_grub if [ $? -ne 0 ]; then echo "!!!!! Failed to update GRUB configuration." - # Restore the original GRUB configuration. - echo "!!!!! Restoring original GRUB configuration." - write_grub "$SAVED_GRUB" /etc/default/grub echo "!!!!! Aborted." return 1 - else - # Save the original file. - write_file "$SAVED_GRUB" "$BACKUPDIR/$GRUBFILE" fi echo "----------- GRUB configuration updated -----------" diff --git a/revert.sh b/revert.sh index 39c39d8..e0ec39c 100755 --- a/revert.sh +++ b/revert.sh @@ -73,7 +73,7 @@ if [ $? -ne 0 ]; then fi #----------------------------------------------------------------------- # Update the grub configuration -echo "----------- Updating GRUB configuration -----------" +echo "----------- Reverting GRUB configuration -----------" sudo update-grub if [ $? -ne 0 ]; then echo "!!!!! Failed to update GRUB configuration." @@ -81,6 +81,17 @@ if [ $? -ne 0 ]; then exit 1 fi #----------------------------------------------------------------------- +# Update initramfs +# This is necessary to apply the changes in the GRUB configuration, +# from Ubuntu 26.04. +echo "----------- Updating initramfs -----------" +sudo update-initramfs -u +if [ $? -ne 0 ]; then + echo "!!!!! Failed to update initramfs." + echo "!!!!! Aborted." + exit 1 +fi +#----------------------------------------------------------------------- # Remove the custom sleep configuration echo "----------- Removing sleep configuration -----------" sudo rm -f /etc/systemd/sleep.conf.d/sleep.conf @@ -108,14 +119,20 @@ if [ $? -ne 0 ]; then echo "!!!!! Aborted." exit 1 fi +#----------------------------------------------------------------------- +# Remove the backup files +echo "----------- Removing backup files -----------" +sudo rm -rf "$BACKUPDIR" + #----------------------------------------------------------------------- # All done echo "----------- Revert completed -----------" -echo "Swap file size reverted to original size: $ORIGINAL_SWAP_SIZE MB" -echo "GRUB configuration reverted to original." -echo "Sleep configuration reverted to original." -echo "Policykit configuration reverted to original." +echo "Reverted swap file size to original size: $ORIGINAL_SWAP_SIZE MB" +echo "Reverted GRUB configuration to original." +echo "Reverted sleep configuration to original." +echo "Reverted policykit configuration to original." echo "Systemd daemon reloaded." +echo "Original files removed." echo "All done." echo "Please reboot your system to apply the changes." diff --git a/spec/inform_swap_location_to_kernel_spec.sh b/spec/inform_swap_location_to_kernel_spec.sh index 9dafa2c..213bcd1 100644 --- a/spec/inform_swap_location_to_kernel_spec.sh +++ b/spec/inform_swap_location_to_kernel_spec.sh @@ -25,7 +25,7 @@ File size of /swapfile is 4294967296 (1048576 blocks of 4096 bytes) 3: 16384.. 28671: 2557952.. 2570239: 12288: 2535424: EOF return 0 - } + } # filefrag() Before 'write_file() { SOURCE_FILENAME="$1"; @@ -55,7 +55,7 @@ GRUB_CMDLINE_LINUX="" #GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef" EOF return 0 - } + } # copy_grub() # shellcheck disable=SC3033 update_grub() { diff --git a/spec/save_original_config_spec.sh b/spec/save_original_config_spec.sh new file mode 100644 index 0000000..3e0876a --- /dev/null +++ b/spec/save_original_config_spec.sh @@ -0,0 +1,62 @@ +#!/bin/sh + +Include 'lib/functions.sh' + +Describe 'save_original_config function' + + + # Mock of sudo command + sudo() { + # Simulate sudo by calling the command directly. + "$@" + } + + # Mock of write_stream() function + write_stream() { + # shellcheck disable=SC2034 + STREAM="$1" + # shellcheck disable=SC2034 + FILENAME="$2" + return 0; + } + + # Mock of free command + free() { + echo " total used free shared buff/cache available" + echo "Mem: 15926 2345 11234 123 2345 13245" + echo "Swap: 15892 0 15892" + } + + # Mock of copy_grub() function + copy_grub() { + # shellcheck disable=SC2034 + COPY_GRUB_DESTINATION_FILENAME="$1"; + return 0 + } + + + It 'should give the original swap size and backup file name to stdn in and parameter, respectively, if backup directory does not exist' + # Mock of backup_dir_exist() function to simulate the case when the backup directory does not exist. + backup_dir_exist() { + return 1 + } + + When call save_original_config + The variable FILENAME should equal "backup/original_swap_size" + The variable STREAM should equal "15892" + The variable COPY_GRUB_DESTINATION_FILENAME should equal "backup/original_grub_config" + End + + It 'should not give anything if backup directory already exists' + # Mock of backup_dir_exist() function to simulate the case when the backup directory already exists. + backup_dir_exist() { + return 0 + } + + When call save_original_config + The variable FILENAME should be undefined + The variable COPY_GRUB_DESTINATION_FILENAME should be undefined + End + + +End \ No newline at end of file diff --git a/spec/save_original_swap_size_spec.sh b/spec/save_original_swap_size_spec.sh deleted file mode 100644 index 73cf48e..0000000 --- a/spec/save_original_swap_size_spec.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh - -Include 'lib/functions.sh' - -Describe 'save_original_swap_size function' - # Mock of write_stream() function - write_stream() { - # shellcheck disable=SC2034 - STREAM="$1" - # shellcheck disable=SC2034 - FILENAME="$2" - return 0; - } - - # Mock of free command - free() { - echo " total used free shared buff/cache available" - echo "Mem: 15926 2345 11234 123 2345 13245" - echo "Swap: 15892 0 15892" - } - - It 'should give the original swap size and backup file name to stdn in and parameter, respectively' - When call save_original_swap_size - The variable FILENAME should equal "backup/original_swap_size" - The variable STREAM should equal "15892" - End -End \ No newline at end of file From 3372c250925d44684244ba3ffcc6dbe3f56afa17 Mon Sep 17 00:00:00 2001 From: HORIE <26223147+suikan4github@users.noreply.github.com> Date: Sat, 16 May 2026 01:09:34 +0000 Subject: [PATCH 05/16] Fix the function name and add the test for it. backup_dir_exist() -> backup_dir_exists(). --- lib/functions.sh | 2 +- spec/save_original_config_spec.sh | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/functions.sh b/lib/functions.sh index 7a8b71e..fc36756 100644 --- a/lib/functions.sh +++ b/lib/functions.sh @@ -220,7 +220,7 @@ save_original_config() { # if the backup directory does not exist, create it and save the original swap size and grub file. # if not, skip creating it because it may contain the backup files. - if ! backup_dir_exist; then + if ! backup_dir_exists; then # Create backup directory. mkdir -p "$BACKUPDIR" diff --git a/spec/save_original_config_spec.sh b/spec/save_original_config_spec.sh index 3e0876a..89eadb8 100644 --- a/spec/save_original_config_spec.sh +++ b/spec/save_original_config_spec.sh @@ -36,8 +36,8 @@ Describe 'save_original_config function' It 'should give the original swap size and backup file name to stdn in and parameter, respectively, if backup directory does not exist' - # Mock of backup_dir_exist() function to simulate the case when the backup directory does not exist. - backup_dir_exist() { + # Mock of backup_dir_exists() function to simulate the case when the backup directory does not exist. + backup_dir_exists() { return 1 } @@ -48,8 +48,8 @@ Describe 'save_original_config function' End It 'should not give anything if backup directory already exists' - # Mock of backup_dir_exist() function to simulate the case when the backup directory already exists. - backup_dir_exist() { + # Mock of backup_dir_exists() function to simulate the case when the backup directory already exists. + backup_dir_exists() { return 0 } From 4367235cfde09a1f0579831bfc6597c9752f221e Mon Sep 17 00:00:00 2001 From: HORIE <26223147+suikan4github@users.noreply.github.com> Date: Sat, 16 May 2026 01:10:51 +0000 Subject: [PATCH 06/16] Disable warning about shellecheck. --- spec/save_original_config_spec.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/save_original_config_spec.sh b/spec/save_original_config_spec.sh index 89eadb8..5189eb4 100644 --- a/spec/save_original_config_spec.sh +++ b/spec/save_original_config_spec.sh @@ -37,6 +37,7 @@ Describe 'save_original_config function' It 'should give the original swap size and backup file name to stdn in and parameter, respectively, if backup directory does not exist' # Mock of backup_dir_exists() function to simulate the case when the backup directory does not exist. + # shellcheck disable=SC2329 backup_dir_exists() { return 1 } From f6ba8cf17a38e722929d6a99e68a1fa0eff30b0d Mon Sep 17 00:00:00 2001 From: HORIE <26223147+suikan4github@users.noreply.github.com> Date: Sat, 16 May 2026 01:38:32 +0000 Subject: [PATCH 07/16] Add update_initramfs() function to lib/functions.sh. It is called in inform_swap_location_to_kernel_spec.sh. Additionally, add a check to create the backup directory only if it does not exist in save_original_config() function in lib/functions.sh. --- lib/functions.sh | 17 +++++++++++++++++ spec/inform_swap_location_to_kernel_spec.sh | 5 +++++ 2 files changed, 22 insertions(+) diff --git a/lib/functions.sh b/lib/functions.sh index fc36756..e0acfa3 100644 --- a/lib/functions.sh +++ b/lib/functions.sh @@ -52,6 +52,13 @@ update_grub() { sudo update-grub } +# Update the initramfs. +# This is easy wrapper of the update-initramfs command. +# For the ease of testing. +update_initramfs() { + sudo update-initramfs -u +} + # Copy from /etc/default/grub to a destination file. # This is a helper function to make test easier. copy_grub() { @@ -334,6 +341,16 @@ inform_swap_location_to_kernel() { return 1 fi + # Update the GRUB configuration. + update_initramfs + if [ $? -ne 0 ]; then + echo "!!!!! Failed to update initramfs." + echo "!!!!! Aborted." + return 1 + fi + + + echo "----------- GRUB configuration updated -----------" return 0 diff --git a/spec/inform_swap_location_to_kernel_spec.sh b/spec/inform_swap_location_to_kernel_spec.sh index 213bcd1..a27a1dd 100644 --- a/spec/inform_swap_location_to_kernel_spec.sh +++ b/spec/inform_swap_location_to_kernel_spec.sh @@ -62,6 +62,11 @@ EOF return 0 } + # shellcheck disable=SC3033 + update_initramfs() { + return 0 + } + Context "When successful" It "should inform swap location to kernel and return 0" When call inform_swap_location_to_kernel From 7d9d0462583af83febddaf9861504fd2f34b7d73 Mon Sep 17 00:00:00 2001 From: HORIE <26223147+suikan4github@users.noreply.github.com> Date: Sat, 16 May 2026 04:02:41 +0000 Subject: [PATCH 08/16] Revert "Add update_initramfs() function to lib/functions.sh." This reverts commit f6ba8cf17a38e722929d6a99e68a1fa0eff30b0d. --- lib/functions.sh | 17 ----------------- spec/inform_swap_location_to_kernel_spec.sh | 5 ----- 2 files changed, 22 deletions(-) diff --git a/lib/functions.sh b/lib/functions.sh index e0acfa3..fc36756 100644 --- a/lib/functions.sh +++ b/lib/functions.sh @@ -52,13 +52,6 @@ update_grub() { sudo update-grub } -# Update the initramfs. -# This is easy wrapper of the update-initramfs command. -# For the ease of testing. -update_initramfs() { - sudo update-initramfs -u -} - # Copy from /etc/default/grub to a destination file. # This is a helper function to make test easier. copy_grub() { @@ -341,16 +334,6 @@ inform_swap_location_to_kernel() { return 1 fi - # Update the GRUB configuration. - update_initramfs - if [ $? -ne 0 ]; then - echo "!!!!! Failed to update initramfs." - echo "!!!!! Aborted." - return 1 - fi - - - echo "----------- GRUB configuration updated -----------" return 0 diff --git a/spec/inform_swap_location_to_kernel_spec.sh b/spec/inform_swap_location_to_kernel_spec.sh index a27a1dd..213bcd1 100644 --- a/spec/inform_swap_location_to_kernel_spec.sh +++ b/spec/inform_swap_location_to_kernel_spec.sh @@ -62,11 +62,6 @@ EOF return 0 } - # shellcheck disable=SC3033 - update_initramfs() { - return 0 - } - Context "When successful" It "should inform swap location to kernel and return 0" When call inform_swap_location_to_kernel From c34fc811ca099e035a8dd7bf2e90cbb5b09d5cd5 Mon Sep 17 00:00:00 2001 From: HORIE <26223147+suikan4github@users.noreply.github.com> Date: Sat, 16 May 2026 13:24:36 +0000 Subject: [PATCH 09/16] Add mkdir mock to save_original_config_spec.sh To prevent to create an actual backup directory during the test. --- spec/save_original_config_spec.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/spec/save_original_config_spec.sh b/spec/save_original_config_spec.sh index 5189eb4..44a6204 100644 --- a/spec/save_original_config_spec.sh +++ b/spec/save_original_config_spec.sh @@ -34,6 +34,12 @@ Describe 'save_original_config function' return 0 } + # Mock of mkdir() function to simulate the creation of backup directory + mkdir() { + MKDIR_FLAG="$1"; + MKDIR_DIR="$2"; + return 0 + } It 'should give the original swap size and backup file name to stdn in and parameter, respectively, if backup directory does not exist' # Mock of backup_dir_exists() function to simulate the case when the backup directory does not exist. @@ -43,6 +49,8 @@ Describe 'save_original_config function' } When call save_original_config + The variable MKDIR_FLAG should equal "-p" + The variable MKDIR_DIR should equal "backup" The variable FILENAME should equal "backup/original_swap_size" The variable STREAM should equal "15892" The variable COPY_GRUB_DESTINATION_FILENAME should equal "backup/original_grub_config" From 0561855ff9ab837550770299568128a21c4dfc07 Mon Sep 17 00:00:00 2001 From: HORIE <26223147+suikan4github@users.noreply.github.com> Date: Sat, 16 May 2026 13:26:06 +0000 Subject: [PATCH 10/16] Add comment to disable shellcheck warning. --- spec/save_original_config_spec.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/save_original_config_spec.sh b/spec/save_original_config_spec.sh index 44a6204..0109cd9 100644 --- a/spec/save_original_config_spec.sh +++ b/spec/save_original_config_spec.sh @@ -36,7 +36,9 @@ Describe 'save_original_config function' # Mock of mkdir() function to simulate the creation of backup directory mkdir() { + # shellcheck disable=SC2034 MKDIR_FLAG="$1"; + # shellcheck disable=SC2034 MKDIR_DIR="$2"; return 0 } From bf38df6e5abd55921619ef049bb6f2b326800d50 Mon Sep 17 00:00:00 2001 From: HORIE <26223147+suikan4github@users.noreply.github.com> Date: Sat, 16 May 2026 20:26:46 +0000 Subject: [PATCH 11/16] Update README.md. Add workarounds for certain flavors of Ubuntu 26.04 LTS, and update the test results for version 2.0.x of this script. --- README.md | 60 +++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 52 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 462f41e..23046a7 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,8 @@ This script supports only systems with a swap file on ext4 file system. The syst ## Requirements -- Ubuntu 24.04(#1) or its flavors (e.g., Kubuntu, Ubuntu Mate, etc.) +- Ubuntu 24.04(#1) or newer + - The flavors (e.g., Kubuntu, Ubuntu Mate, etc.) - ext4 file system - swap file (not swap partition) - sudo privileges @@ -23,6 +24,25 @@ This script supports only systems with a swap file on ext4 file system. The syst - (#1) Ubuntu updated the the Polkit major version from Ubuntu 24.04. So, this script may not work on Ubuntu versions prior to 24.04. ## Test environment and results + +### Version 3.0.x +The following table shows the test environment and results for version 3.0.x of this script. +| OS | Platform | Note | +| ----------------- | -----------| ---------- | +| Ubuntu 26.04 | Hyper-V | Need workaround (#1)| +| Kubuntu 26.04 | Hyper-V | Works fine | +| Lubuntu 26.04 | Hyper-V | Need Workaround (#1)| + +--- +- (#1) After executing the fuyujitaku.sh script, reboot the system and then, run `update-initramfs -u -k all` command. See [Workarounds for certain flavors of Ubuntu 26.04 LTS](#workarounds-for-certain-flavors-of-ubuntu-2604-lts) section for details. + +### Version 2.0.x +The following table shows the test environment and results for version 2.0.x of this script. +| OS | Platform | Note | +| ----------------- | ------------------------------ | ---------- | +| Kubuntu 25.10 | Fujitsu FMV Lifebook U939 | Works fine | + + ### Version 1.x.x The following table shows the test environment and results for version 1.x.x of this script. | OS | Platform | Note | @@ -38,14 +58,11 @@ The following table shows the test environment and results for version 1.x.x of - (#3) The mouse cursor is rendered incorrectly after resuming. The workaround is to reboot the system. - (#4) Intel Core i5-8365U, 8GB RAM, 256GB SSD. -### Version 2.0.x -The following table shows the test environment and results for version 1.x.x of this script. -| OS | Platform | Note | -| ----------------- | ------------------------------ | ---------- | -| Kubuntu 25.10 | Fujitsu FMV Lifebook U939 | Works fine | - ## How to use +> [!Caution] +> For the certain flavors of Ubuntu 26.04 LTS, you need special workaround to avoid a problem. Read this section carefully before using the script. + 1. Download the latest release from [here](https://github.com/suikan4github/fuyujitaku). 2. Extract the downloaded archive. 3. Open a terminal and navigate to the extracted folder. @@ -84,6 +101,30 @@ Finally, you can specify both parameter at once. ./fuyujitaku.sh -s 12G -d 600s ``` +### Workarounds for certain flavors of Ubuntu 26.04 LTS +Certain flavors of Ubuntu 26.04 LTS (e.g., Ubuntu and Lubuntu) have a problem that prevent the execusion of `systemctl hibernate` command after running the fuyujitaku.sh script. + +Usually, the following command can configure the system hibernate possible. + +```sh +./fuyujitaku.sh +sudo reboot +``` +But you will see the following error message when you run `systemctl hibernate` command after running the above commands, in some flavors of Ubuntu 26.04 LTS. + +``` +Call to Hibernate failed: Invalid resume config: resume= is not populated yet resume_offset= is +``` +This is reported in the issue #15 . + +The workaround is to run the following command **after** rebooting the system. + +```bash +sudo update-initramfs -u -k all +sudo reboot +``` + + ## How to revert The revert.sh script is provided to revert the changes made by fuyujitaku.sh script. @@ -93,7 +134,10 @@ To revert the changes, run the following command: . ./revert.sh ``` -Note that the revert.sh script works only if the fuyujitaku.sh script was run without any errors. +> [!Note] +> The revert.sh script works only if the fuyujitaku.sh script run without any errors. + +The revert.sh script will restore the original swap size and the original kernel parameters. It will also remove the backup files created by fuyujitaku.sh script. ## How to test To run the auto tests, you need to install [shellspec](https://github.com/shellspec/shellspec). From 7ca7fa279dd29ee792d322c94a050a7af44c5f99 Mon Sep 17 00:00:00 2001 From: HORIE <26223147+suikan4github@users.noreply.github.com> Date: Sat, 16 May 2026 20:43:05 +0000 Subject: [PATCH 12/16] Update README.md Fix small issues in README.md file. --- README.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 23046a7..e6b78c7 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ The following table shows the test environment and results for version 3.0.x of | Lubuntu 26.04 | Hyper-V | Need Workaround (#1)| --- -- (#1) After executing the fuyujitaku.sh script, reboot the system and then, run `update-initramfs -u -k all` command. See [Workarounds for certain flavors of Ubuntu 26.04 LTS](#workarounds-for-certain-flavors-of-ubuntu-2604-lts) section for details. +- (#1) After executing the `fuyujitaku.sh` script, reboot the system and then, run `update-initramfs -u -k all` command. See [Workarounds for certain flavors of Ubuntu 26.04 LTS](#workarounds-for-certain-flavors-of-ubuntu-2604-lts) section for details. ### Version 2.0.x The following table shows the test environment and results for version 2.0.x of this script. @@ -102,7 +102,7 @@ Finally, you can specify both parameter at once. ``` ### Workarounds for certain flavors of Ubuntu 26.04 LTS -Certain flavors of Ubuntu 26.04 LTS (e.g., Ubuntu and Lubuntu) have a problem that prevent the execusion of `systemctl hibernate` command after running the fuyujitaku.sh script. +Certain flavors of Ubuntu 26.04 LTS (e.g., Ubuntu and Lubuntu) have a problem that prevent the execusion of `systemctl hibernate` command after running the `fuyujitaku.sh` script. Usually, the following command can configure the system hibernate possible. @@ -110,34 +110,35 @@ Usually, the following command can configure the system hibernate possible. ./fuyujitaku.sh sudo reboot ``` -But you will see the following error message when you run `systemctl hibernate` command after running the above commands, in some flavors of Ubuntu 26.04 LTS. +But you may see the following error message when you run `systemctl hibernate` command after running the above commands, in some flavors of Ubuntu 26.04 LTS. ``` Call to Hibernate failed: Invalid resume config: resume= is not populated yet resume_offset= is ``` -This is reported in the issue #15 . +This is reported in the [issue #15](#15). The workaround is to run the following command **after** rebooting the system. ```bash +# Run these commands after rebooting the system. sudo update-initramfs -u -k all sudo reboot ``` ## How to revert -The revert.sh script is provided to revert the changes made by fuyujitaku.sh script. +The `revert.sh` script is provided to revert the changes made by `fuyujitaku.sh` script. To revert the changes, run the following command: ```bash -. ./revert.sh +./revert.sh ``` > [!Note] > The revert.sh script works only if the fuyujitaku.sh script run without any errors. -The revert.sh script will restore the original swap size and the original kernel parameters. It will also remove the backup files created by fuyujitaku.sh script. +The `revert.sh` script will restore the original swap size and the original kernel parameters. It will also remove the backup files created by `fuyujitaku.sh` script. ## How to test To run the auto tests, you need to install [shellspec](https://github.com/shellspec/shellspec). From cffb6fd5b2748a94ed75d3de9d66f9069385bc94 Mon Sep 17 00:00:00 2001 From: HORIE <26223147+suikan4github@users.noreply.github.com> Date: Sat, 16 May 2026 20:47:41 +0000 Subject: [PATCH 13/16] Fix the wrong link to the issue #15. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e6b78c7..eb265e7 100644 --- a/README.md +++ b/README.md @@ -115,7 +115,7 @@ But you may see the following error message when you run `systemctl hibernate` c ``` Call to Hibernate failed: Invalid resume config: resume= is not populated yet resume_offset= is ``` -This is reported in the [issue #15](#15). +This is reported in the [issue #15](https://github.com/suikan4github/fuyujitaku/issues/15). The workaround is to run the following command **after** rebooting the system. From cdc8b5dbb600f8bbf2421a8987f09922cf31bc33 Mon Sep 17 00:00:00 2001 From: HORIE <26223147+suikan4github@users.noreply.github.com> Date: Sat, 16 May 2026 20:56:49 +0000 Subject: [PATCH 14/16] Update README.md to add test result and secureboot. Added test result of Ubuntu 24.04. Added secure boot must be disabled. --- README.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index eb265e7..9bdf311 100644 --- a/README.md +++ b/README.md @@ -14,14 +14,16 @@ This script supports only systems with a swap file on ext4 file system. The syst ## Requirements -- Ubuntu 24.04(#1) or newer - - The flavors (e.g., Kubuntu, Ubuntu Mate, etc.) -- ext4 file system -- swap file (not swap partition) -- sudo privileges +- Ubuntu 24.04(#1) or newer. + - The flavors (e.g., Kubuntu, Ubuntu Mate, etc.). +- ext4 file system. +- swap file (not swap partition). +- sudo privileges. +- Secure boot disabled in the BIOS/UEFI settings (#2). --- - (#1) Ubuntu updated the the Polkit major version from Ubuntu 24.04. So, this script may not work on Ubuntu versions prior to 24.04. +- (#2) Linux kernel lockdown feature prevents the resume from hibernation during the secure boot. To use hibernation, you need to disable secure boot in the BIOS/UEFI settings. ## Test environment and results @@ -29,6 +31,7 @@ This script supports only systems with a swap file on ext4 file system. The syst The following table shows the test environment and results for version 3.0.x of this script. | OS | Platform | Note | | ----------------- | -----------| ---------- | +| Ubuntu 24.04 | Hyper-V | Works fine| | Ubuntu 26.04 | Hyper-V | Need workaround (#1)| | Kubuntu 26.04 | Hyper-V | Works fine | | Lubuntu 26.04 | Hyper-V | Need Workaround (#1)| @@ -155,6 +158,7 @@ shellspec If you encounter any issues while using this script, please check the following: - Ensure that you have a swap file and not a swap partition. This script does not support systems with swap partitions. - Ensure that you have enough disk space to extend the swap file. The script will attempt to double the size of the swap file, by default. +- Ensure that secure boot is disabled in the BIOS/UEFI settings. - Check the system logs for any error messages related to hibernation or swap file. Generally, the script should work on Ubuntu and its flavors. However, if you encounter any issues, please feel free to open an issue on the [GitHub repository](https://github.com/suikan4github/fuyujitaku/wiki) From 53d6d707be8aa34cef749e690cc5c21b4b6765d7 Mon Sep 17 00:00:00 2001 From: HORIE <26223147+suikan4github@users.noreply.github.com> Date: Mon, 18 May 2026 20:56:23 +0000 Subject: [PATCH 15/16] Removed update-initramfs.sh --- revert.sh | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/revert.sh b/revert.sh index e0ec39c..83c1a8b 100755 --- a/revert.sh +++ b/revert.sh @@ -80,17 +80,7 @@ if [ $? -ne 0 ]; then echo "!!!!! Aborted." exit 1 fi -#----------------------------------------------------------------------- -# Update initramfs -# This is necessary to apply the changes in the GRUB configuration, -# from Ubuntu 26.04. -echo "----------- Updating initramfs -----------" -sudo update-initramfs -u -if [ $? -ne 0 ]; then - echo "!!!!! Failed to update initramfs." - echo "!!!!! Aborted." - exit 1 -fi + #----------------------------------------------------------------------- # Remove the custom sleep configuration echo "----------- Removing sleep configuration -----------" From c648d382ac6a71c81002cd1ca3467a7df4c771f1 Mon Sep 17 00:00:00 2001 From: HORIE <26223147+suikan4github@users.noreply.github.com> Date: Mon, 18 May 2026 20:59:31 +0000 Subject: [PATCH 16/16] Add lifebook as version 3.0.x tested platform. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 9bdf311..1e2bdcd 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ The following table shows the test environment and results for version 3.0.x of | Ubuntu 24.04 | Hyper-V | Works fine| | Ubuntu 26.04 | Hyper-V | Need workaround (#1)| | Kubuntu 26.04 | Hyper-V | Works fine | +| Kubuntu 26.04 | Fujitsu FMV Lifebook U9312 | Works fine | | Lubuntu 26.04 | Hyper-V | Need Workaround (#1)| ---