* Adds security if a false positive is detected:
* if the command "grep -qs "$gbgmp" /proc/mounts;" returns a false positive.
"rm -d" will return an error if the directory is not empty.
* Rework the creation of the "grub-btrfs.cfg" file:
* Before, the "grub-btrfs.cfg" file was deleted and then the new configuration was written.
No backup was made.
* Now, the new configuration will be written in a temporary file "grub-btrfs.new" and then analysed with the "grub_script_check" command before being finally written in the "grub-btrfs.cfg" file.
If an error is detected, the "grub-btrfs.new" file will coexist with the old "grub-btrfs.cfg" file, if it exists.
* Adds trap command on EXIT signal:
* Now umount command will launch on EXIT signal.
* Adds a function called by the trap on EXIT signal to unmount and delete the temporary folder.
(That should be the end of multiple tmp.xxxxxxxxxx in /tmp)
- If the command fails, retry every 2 seconds. After 10 attempts, it will stop and display a warning.
- If the command is successful, "Succes" will be displayed.
* Adds "grub-btrfs" as a prefix to the temporarie mount folder.
(before = tmp.xxxxxxxxx , now = grub-btrfs.xxxxxxxxxx)
* Corrects printf format string:
* printf interprets escape sequences and format specifiers in the format string. If variables are included, any escape sequences or format specifiers in the data will be interpreted too, when you most likely wanted to treat it as data.
* With these changes, the script will be disabled as soon as possible, if :
* "GRUB_BTRFS_DISABLE" If this variable is set to "true"
* "btrfs-progs isn't installed" This package is required to retrieve information from the btrfs filesystem.
* "grub-mkconfig_lib couldn't be found" This library is required because the script depends on it.
* "Root filesystem isn't btrfs" grub-btrfs currently checks only the btrfs snapshots present on the root partition.
Running a command and then checking its exit status $? against 0 is redundant.
Instead of just checking the exit code of a command, it checks the exit code of a command that checks the exit code of a command.
* Add possibility to boot without init(rd,ramfs):
- For a snapshot to be valid, it must contain a boot folder and a kernel from the official list (or have been added to the custom kernel list)
- if a snapshot doesn't contain an init(rd,ramfs), it will be detected as valid.
- Suppress script stop when an init is not found
- If init isn't found, add the letter "x" to the init list. (hoping this doesn't break the support for custom init names)
- The microcode support is still present, despite the absence of init(rd,ramfs), is it really relevant ?
- Add filter to ignore snapper's snapshot "type or description" during run "grub-mkconfig"
- Two new variables available in the config file:
# Ignore specific type of snapper's snapshot during run "grub-mkconfig".
# Type = single, pre or post.
# Default: ("")
GRUB_BTRFS_IGNORE_SNAPPER_TYPE=("")
# Ignore specific description of snapper's snapshot during run "grub-mkconfig".
# Default: ("")
GRUB_BTRFS_IGNORE_SNAPPER_DESCRIPTION=("")
Script:
Improves the rootflags option in the kernel command line:
- Remove "rw" flag.
- Parse fstab mountoptions and add them to rootflags:
Adds functionality to read in snapshot specific mount flags
from the respective fstab and uses them in combination with the new
config option, while the latter is prioritized.
Both places can, but don't need to define mount flags. If either of them
doesn't, it will simply not be taken into account.
Config file:
Adds a new config variable "GRUB_BTRFS_ROOTFLAGS":
- The new variable is used to include user-defined rootflags in the
kernel command line of generated snapshot bootmenu entries.
See config file for more infos.
* Fix#116 (#118)
* Renames variable GRUB_BTRFS_DIRNAME to GRUB_BTRFS_GRUB_DIRNAME and improves its description
* Adds variable GRUB_BTRFS_BOOT_DIRNAME, used to detect the boot partition and the location of kernels/initrafms/microcodes
* Modify "GRUB_BTRFS_DIRNAME"
* Full path to Grub folder is now configurable (/boot is no longer hard coded).
* Detection of the boot partition is now based on the location of the Grub folder.
* Warning [see](https://github.com/Antynea/grub-btrfs/pull/113#issuecomment-705916729)
Modify the function which is used to ignore a path.
@ shouldn't be hardcoded.
Create 2 separate functions to ignore a specific path or prefix path.
In specific path, only exact paths are ignored.
In prefix path, any path starting with the specified string will be ignored.
e.g :
if specific path = @, only @ snapshot will be ignored.
if prefix path = @, all snapshots beginning with "@/..." will be ignored.
* Add password protection support for the submenu
Grub2 supports superuser and user access using passwords. #95
-Ability to add authorized users.
-Possibility to disable password protection for the submenu.
* Update config
* Update README.md
Btrfs filesystems may be slow when listing snapshots and calculating
space usage for each.
And that space information is not needed and never used in the scipt.
So, add --disable-ununsed-space to all calls to btrfs.
See: https://github.com/Antynea/grub-btrfs/issues/91
Co-authored-by: Peter G <nephros@pearl.crownest.nephros.org>
Previously, the kernel parameters came after the `rootflags=subvol=<snapshot>`
argument. This means that when the user's standard kernel parameters also
contain a `rootflags=subvol=<root>`, it will override the subvol flag of the
snapshot. So put the snapshot's subvol flag last.
Fix#72
The submenu generated by "grub-btrfs" doesn't load in the "GRUB menu."
Sometimes the Grub prefix and root variable don't match.
This ensures that the prefix variable is used to load the grub-btrfs.cfg file.
See
How to specify files
and
Special environment variables : root
and
Special environment variables : prefix