antynea / grub-btrfs Goto Github PK
View Code? Open in Web Editor NEWInclude btrfs snapshots at boot options. (Grub menu)
License: GNU General Public License v3.0
Include btrfs snapshots at boot options. (Grub menu)
License: GNU General Public License v3.0
Hi, thanks for your script works just super!
Could you tell me how to implement your script works like this:
If I choose a snapshot in the menu of Grub then script should be to change a name of subvolume "subvolume_root" which is on "/" in "subvolume_root_bad" and selected snapshot move on "/" and rename it giving to him a name "subvolume_root"?
PS - Usually i do this with my hands, using a couple of commands
mv /mnt/subvolume_root /mnt/subvolume_root_bad
and
mv /mnt/backup /mnt/subvolume_root
I use snap-pac which hooks into pacman to add transactions support: it creates a pre snapshot before running pacman and a post snapshot afterward. This makes possible to revert it or to diff the changes: https://wiki.archlinux.org/index.php/Snapper#Wrapping_pacman_transactions_in_snapshots
Unfortunately pre-post snapshots are not normal snapshots and should not be listed by brub-btrfs. You can show them with:
snapper -c @ list -t pre-post
or looking at the first column of
snapper -c @ list
Here is the output of:
grub-mkconfig -o /boot/grub/grub.cfg
###### - Grub-btrfs: Auto-detect - ######
###### - Grub-btrfs: Auto-detect - ######
error: syntax error.
error: Incorrect command.
error: syntax error.
Syntax error at line 173
Syntax errors are detected in generated GRUB config file.
Ensure that there are no errors in /etc/default/grub
and /etc/grub.d/* files or please file a bug report with
/boot/grub/grub.cfg.new file attached.
done
Hi,
I've been using grub-btrfs for a while now on manjaro without issues, but I recently noticed that whenever I rebuild my grub config the snapshot detection takes about 20min and uses a lot of CPU.
It also throws some errors:
###### - Grub-btrfs: Snapshot detection started - ######
# Info: Separate boot partition not detected
loading 119 failed
:1: parser error : Document is empty
^
loading 526 failed
:1: parser error : Document is empty
^
loading 527 failed
loading 618 failed
loading 675 failed
IO error (open failed path://.snapshots/629 errno:2 (No such file or directory)).
loading 119 failed
:1: parser error : Document is empty
^
loading 526 failed
:1: parser error : Document is empty
^
loading 527 failed
loading 618 failed
loading 675 failed
loading 119 failed
:1: parser error : Document is empty
^
loading 526 failed
:1: parser error : Document is empty
^
loading 527 failed
loading 618 failed
loading 675 failed
It then moves on to correctly list snapshots and completes correctly.
Any suggestions how to fix this?
I have been trying to hack this in, but grub configuration is a bit over my head. I'll describe my usercase;
I want to use grub only to boot into my other snapshots. Currently, grub-btrfs expects the kernel location to be /boot (as hard coded). It picks up the unsigned kernel at the root of my file-system, which then cannot be found because they are encrypted. I want to be able to change the kernel location to my signed copies under the ESP, in the directory EFI/Arch/vmlinuz-*. I was wondering how to add in a config option that can change the default boot partition location, and the location for the kernels.
Many applications (e.g. docker) create subvolumes (/var/lib/docker/btrfs/subvolumes/XXX
) which are children of the root subvolume (The number after top level
when running btrfs subvolume list /
). These children must be moved the the selected snapshot to keep these applications running.
An approach could be to search for all subvolumes which are children of the default root subvolume. All these children are then moved to the selected subvolume on boot.
Hi!
Could you consider to enhance the GRUB_BTRFS_TITLE_FORMAT to include snapper type "single, pre, post"?
This could simplify identification of relevant snapshot in Grub.
Regards
Thomas
Hello,
I've noticed that the script doesn't generate initrd lines when the variable
GRUB_BTRFS_CREATE_ONLY_HARMONIZED_ENTRIES is set to "true" in my /etc/default/grub.
This makes the grub.cfg unusable for snapshots unfortunately.
question: is this compatible with ubuntu version 0.5.0-2 ?
https://launchpad.net/ubuntu/+source/snapper
want to aksk ubuntu devs to add this to main repo's ...
Currently, I've deployed with Ubuntu 17.10.
After reboot to from "Ubuntu Snapshot" I've got this error
Loading Snapshot: 2017-11-22 14:00:14 ~/.snapshots/2/snapshot
Loading Kernel: vmlinuz-4.13.0-16-generic ...
Loading Initfamfs: initramfs-* ...
error: file '/@/.snapshots/2/snapshot/boot/initramfs-*' not found.
Press any key to continue ...
Any help ??
Hi all, can I use this with manual snapshot? I don't use snapper but I create my snapshot with btrfs command. Can I use this for booting my snapshots? If yes, how?
I have version 1.11-2 of grub-btrfs which I installed from an archlinux user repository PKGBUILD on my Manjaro linux installation on an EFI laptop. I left everything as-is, with the default 100 snapshot limit.
In the meantime, I installed a few kernels and used my system as I pleased. Today I had to reboot after a considerable uptime in which snapper had been dutifully storing lots of snapshots, and I ended up with a system that would not boot, or at least into GRUB. What I found after thrashing aimlessly for a couple of hours was that my grub.cfg
had grown to over 22000 lines, almost entirely as a result of these snapshot entries.
At first I thought that there was no limit being applied at all, but I now realize that I did have exactly 100 "Snapshot" submenus in the bloated file. There are big problems, though:
While the number of snapshots under consideration is certainly correlated to the resultant number of entries, the latter is what makes the boot menu unwieldly, and ultimately inoperable.
My distribution (manjaro) has a bash script at /etc/grub.d/10_linux
which dictates the logic to create menu entries from every valid pair of initramfs-*
and vmlinu[z|x]
files it finds in /boot
. grub-btrfs by contrast just makes entries for every product of the two filetypes, whether or not they make sense.
My machine currently has two vmlinuz kernel files, one each for 4.14 and 4.15. It also has initramfs files for both of those, with fallback variants, and (for reasons I have yet to determine) a couple of leftover initramfs files for a kernel that I had removed. These files result in 1 default and 4 "advanced" entries in the 10_linux section, but 12 per snapshot (=1200 total) in the 41_snapshots-btrfs
section, because grub-btrfs mashes, e.g., initramfs-4.14-rt-x86_64.img and vmlinuz-4.15-x86_64 together, even though that doesn't make sense. It's honestly questionable whether we need anything more than just the latest available kernel-ramdisk pair for these snapshot entries, but certainly very few people are could have any purpose for options to boot kernel version X with ramdisk version Y.
To close, I'd like to thank you for your contributions, but to also emphasize the seriousness of this kind of failure state. Inability to launch the bootloader is a really difficult problem for anyone without serious GRUB chops to diagnose; there was no interface, no output, and no logging. This way leads desperation.
Preventing the de facto corruption of grub.cfg
should be priority number 1, over and above the functionality that you're trying to deliver here (which is very appreciated!).
Thanks for reading.
I have similar Arch installs on several computers. For some reason, pacaur -Sua insists on listing
grub-btrfs-git-latest
for update on some installs, and not others. I've uninstalled the git package but after reinstallation, the problem persists even though the --devel flag is not enabled.
Any ideas how to track this down or fix the erroneous reporting?
Not a show stopper. I ignore it but it's puzzling.
I think this may be related to #64.
Debian 10 Stable
Whenever I boot into a snapshot from GRUB, a bunch of services don't boot and I end up in a TTY console instead of the GUI like normal. My /boot/efi is on a separate partition, and is not a BTRFS subvol, I wonder if this is related?
I have a problem where it incorrectly assumes initramfs is in /subvol name/boot
As of commit 8fffc13 at line 143:
initrd \"${boot_dir_real_path}/"${u}"\" \"/"${snap_dir_name}"/boot/"${i}"\""
I have my EFI system partition mounted at /boot and my current boot entry always loads the initramfs direct from the ESP root (not in any subdirectories). This is the recommended setup for Arch Linux if you boot using UEFI.
ex: initrd /intel-ucode.img /initramfs-linux.img
How could we best make sure this script recognizes this and use the appropriate path?
I'm happy to use GRUB_BTRFS_NINIT to override this but it doesn't seem like it does this mistake for the kernel.
Could you please create a new release and update the grub-btrfs Arch Linux package as well? The grub-btrfs-git AUR package is broken and ignoring @ doesn't work with 4.3.
I'm trying to use your script on ubuntu and the snapshots won't boot, the initrd does not finds the filesystem.
I replaced UUID with X, but the UUID of the partition and the UUID from the command line matches.
Here are some info:
/proc/cmdline with snapshot :
BOOT_IMAGE=/@/.snapshots/5/snapshot/boot/vmlinuz-4.15.0-15-generic root=UUID=X rw rootflags=suvbol=@/.snapshots/5/snapshot
/proc/cmdline on normal boot:
BOOT_IMAGE=/@/boot/vmlinuz-4.15.0-15-generic root=/dev/mapper/root-root ro rootflags=subvol=@
Instead of hardcoding Arch Linux.
It a subvolume with the characters in the gsub(/^["<FS_TREE>/"]+/,"",$NF) exists, the subvolume name generated for grub is incorrect. In my case, the use of the underscore in a subvolume name required changing the expression to
gsub(/^.*<FS_TREE>/,"",$NF)
👍 Graz for making it into the Arch community repo !
Today I've got the update to 4.0, and I like the new design with the systemd path-unit and service.
Unfortunately, grub-btrfs.service
tries to access the old config file, /etc/grub.d/41_snapshots-btrfs_config
, rather than /etc/default/grub-btrfs/config
, and fails.
Hi,
I have an issue after updating grub on Debian 9.2:
thomas@pc8-nb:~$ sudo update-grub
/usr/sbin/grub-mkconfig: 24: /etc/default/grub: Syntax error: "(" unexpected
The relevant line is:
GRUB_BTRFS_IGNORE_SPECIFIC_PATH=("var/lib/docker" "nosnapshot")
Is this Debian specific?
I have a specific subvolume I mount as root using rootflags=subvol=subvol_root
. When I recreate the GRUB configuration file with this package installed, it creates another rootflags=subvol=
entry, one for the one I've specified and then one for the snapshot.
I changed my root subvol name from "arch_root" to "@", I got
I booted into arch live CD, and changed all "arch_root" to "@" in /boot/grub/grub-btrfs.cfg
, and reboot.
But when I sudo grub-mkconfig -o /boot/grub/grub.cfg
, I got this
Generating grub configuration file ...
Found theme: /boot/grub/themes/Griffin/theme.txt
Found linux image: /boot/vmlinuz-linux
Found initrd image: /boot/intel-ucode.img /boot/amd-ucode.img /boot/initramfs-linux.img
Found fallback initrd image(s) in /boot: initramfs-linux-fallback.img
###### - Grub-btrfs: Snapshot detection started - ######
# Info: Separate boot partition not detected
# Info: snapper detected, using config 'root'
# No snapshots found.
# If you think an error has occurred , please file a bug report at " https://github.com/Antynea/grub-btrfs "
# Nothing to do. Abort.
###### - Grub-btrfs: Snapshot detection ended - ######
done
Grub2 supports superuser and user access using passwords.
As snapshots are clearly the domain of a sysadmin and not a regular user, any entries allowing to boot from a snapshot should be (optionally, or even by default) protected by such passwords.
TL;DR this can be done by adding --user ""
to the menuentry
line, but there would need to be some plumbing in the config file and documentation to make it configurable.
https://help.ubuntu.com/community/Grub2/Passwords
https://www.gnu.org/software/grub/manual/grub/grub.html#Authentication-and-authorisation
TODOs:
--users ""
vs --users "user1, user2"
)Hello,
After upgrading grub-btrfs on Arch it no longer seems to find my snap shots. I get the following error. I'm happy to help troubleshoot and poke around if you can point me in the right direction.
###### - Grub-btrfs: Snapshot detection started - ######
# Info: Separate boot partition detected
# Info: snapper detected, using config 'root'
# No snapshots found.
# If you think an error has occurred , please file a bug report at " https://github.com/Antynea/grub-btrfs "
# Nothing to do. Abort.
###### - Grub-btrfs: Snapshot detection ended - ######
The script calls snapper list
three times to collect information about the snapshots.
Depending on how the underlying filesystem and snapper is set up, this may take a long time.
Suggestions:
snapper list
, add the --disable-used-space
option. This will speed up the listing on configurations using btrfs quota.snapper list
once, store the output in e.g. an array or a temp file, and retrieve the information from there--columns
option to retrieve all needed information in one go and nothing elseHey, love this script, but it would be even better if it was snapper friendly.
I am just going from using my own simple script to using snapper and would ask if you would add date and time to the menu entry.
Snapper only numbers them in the snapshot path, which will be pretty uninformative when looking at the menu.
My suggestion would just be to add something like the output of this $bindir/btrfs subvolume list -s / --sort=-ogen | $bindir/cut -d" " -f11-12
to the end of the menu entry line which is just a date and time: 2015-05-11 10:09:23
hello guys, does anyone know how i can include btrfs snapshots in GRUB boot options? I usually use grub-customizer to add or edit boot entires.
Grub customizer has various options to add boot entries like Scripts,Linux,Linux-ISO,Chainloader,Memtest and other..
I guess i can add an entry with grub-customizer, i am not sure on how to do it tho
Thank you
Removing snapshot: 2020-07-28_12-18-36
Deleted directory: /run/timeshift/backup/timeshift-btrfs/snapshots/2020-07-28_12-18-36
Removed snapshot: 2020-07-28_12-18-36
------------------------------------------------------------------------------
Generating grub configuration file ...
Found theme: /usr/share/grub/themes/garuda/theme.txt
Found linux image: /boot/vmlinuz-linux-zen
Found initrd image: /boot/intel-ucode.img /boot/initramfs-linux-zen.img
Found fallback initrd image(s) in /boot: initramfs-linux-zen-fallback.img
###### - Grub-btrfs: Snapshot detection started - ######
# Info: Separate boot partition not detected
# Found snapshot: 2020-07-28 04:00:22 | timeshift-btrfs/snapshots/2020-07-28_04-00-22/@
# Found snapshot: 2020-07-27 20:13:24 | timeshift-btrfs/snapshots/2020-07-27_20-13-24/@
# Found snapshot: 2020-07-26 18:57:59 | timeshift-btrfs/snapshots/2020-07-26_18-57-58/@
# Found snapshot: 2020-07-26 07:30:09 | timeshift-btrfs/snapshots/2020-07-26_07-30-09/@
# Found snapshot: 2020-07-26 06:57:10 | timeshift-btrfs/snapshots/2020-07-26_06-57-10/@
# Found snapshot: 2020-07-26 02:35:34 | timeshift-btrfs/snapshots/2020-07-26_02-35-34/@
# Found snapshot: 2020-07-18 02:51:57 | @
# Found 7 snapshot(s)
------------------------------------------------------------------------------------------
sudo timeshift --list
/dev/sda2 is mounted at: /run/timeshift/backup, options: rw,relatime,compress=zstd:3,ssd_spread,space_cache,autodefrag,subvolid=5,subvol=/
Device : /dev/sda2
UUID : d6458fc5-cf8f-417a-8479-e8f6169c3604
Path : /run/timeshift/backup
Mode : BTRFS
Status : OK
6 snapshots, 194.1 GB free
Num Name Tags Description
------------------------------------------------------------------------------
0 > 2020-07-26_02-35-34 O {timeshift-autosnap} {created before upgrade}
1 > 2020-07-26_06-57-10 O sgs
2 > 2020-07-26_07-30-09 O {timeshift-autosnap} {created before upgrade}
3 > 2020-07-26_18-57-58 O {timeshift-autosnap} {created before upgrade}
4 > 2020-07-27_20-13-24 O {timeshift-autosnap} {created before upgrade}
5 > 2020-07-28_04-00-22 O {timeshift-autosnap} {created before upgrade}
Where does the program get the wrong old data from?
What am I doing wrong?
When I delete all snapshots via TS-GUI, crashed TS and my PC has no more data. But this is not the problem of grub-btrfs :)
I changed the output of grub-btrfs on my machine via a patch file in the past. Basically, I removed all leading # to have the same output as grub-mkconfig.
Before:
(5/5) Generate GRUB config to let grub-btrfs detect new snapshots
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-linux-lts
Found initrd image: /boot/initramfs-linux-lts.img
Found fallback initrd image(s) in /boot: initramfs-linux-lts-fallback.img
Found linux image: /boot/vmlinuz-linux
Found initrd image: /boot/initramfs-linux.img
Found fallback initrd image(s) in /boot: initramfs-linux-fallback.img
###### - Grub-btrfs: Snapshot detection started - ######
# Info: Separate boot partition not detected
# Info: snapper detected, using config 'root'
# Found 13 snapshot(s)
###### - Grub-btrfs: Snapshot detection ended - ######
done
After:
(5/5) Generating GRUB config and detecting new snapshots
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-linux-lts
Found initrd image: /boot/initramfs-linux-lts.img
Found fallback initrd image(s) in /boot: initramfs-linux-lts-fallback.img
Found linux image: /boot/vmlinuz-linux
Found initrd image: /boot/initramfs-linux.img
Found fallback initrd image(s) in /boot: initramfs-linux-fallback.img
Detecting snapshots ...
Info: Separate boot partition not detected
Info: snapper detected, using config 'root'
Found 13 snapshot(s)
However, I need to update this with every new release.
Therefore, would you accept a pull request to just replace the output or do you prefer a new config variable to switch between different output formats?
The title basically. The '-character is not escaped in the submenu entry, resulting in a syntax error.
I have a separate boot partition. It seems that due to some strange configuration of grub.cfg, grub's default working directory is not under the boot partition. Running the configfile "/grub/grub-btrfs.cfg"
will not find the file. You should first run search -f --set=root --no-floppy
to set the working working directory.
Example
submenu 'Arch Linux snapshots' {
search -f --set=root --no-floppy /grub/grub-btrfs.cfg
configfile "/grub/grub-btrfs.cfg"
}
This is my grub.cfg
# cat /boot/grub/grub.cfg
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#
### BEGIN /etc/grub.d/00_header ###
insmod part_gpt
insmod part_msdos
if [ -s $prefix/grubenv ]; then
load_env
fi
if [ "${next_entry}" ] ; then
set default="${next_entry}"
set next_entry=
save_env next_entry
set boot_once=true
else
set default="unsaved"
fi
if [ x"${feature_menuentry_id}" = xy ]; then
menuentry_id_option="--id"
else
menuentry_id_option=""
fi
export menuentry_id_option
if [ "${prev_saved_entry}" ]; then
set saved_entry="${prev_saved_entry}"
save_env saved_entry
set prev_saved_entry=
save_env prev_saved_entry
set boot_once=true
fi
function savedefault {
if [ -z "${boot_once}" ]; then
saved_entry="${chosen}"
save_env saved_entry
fi
}
function load_video {
if [ x$feature_all_video_module = xy ]; then
insmod all_video
else
insmod efi_gop
insmod efi_uga
insmod ieee1275_fb
insmod vbe
insmod vga
insmod video_bochs
insmod video_cirrus
fi
}
set menu_color_normal=light-gray/black
set menu_color_highlight=green/black
if [ x$feature_default_font_path = xy ] ; then
font=unicode
else
insmod part_gpt
insmod btrfs
set root='hd0,gpt3'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-ieee1275='ieee1275//disk@0,gpt3' --hint-bios=hd0,gpt3 --hint-efi=hd0,gpt3 --hint-baremetal=ahci0,gpt3 0e854bcc-6bdc-424c-a46e-251afc2842cc
else
search --no-floppy --fs-uuid --set=root 0e854bcc-6bdc-424c-a46e-251afc2842cc
fi
font="/@/usr/share/grub/unicode.pf2"
fi
if loadfont $font ; then
set gfxmode=auto
load_video
insmod gfxterm
set locale_dir=$prefix/locale
set lang=zh_CN
insmod gettext
fi
terminal_input console
terminal_output gfxterm
insmod part_gpt
insmod btrfs
set root='hd0,gpt3'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-ieee1275='ieee1275//disk@0,gpt3' --hint-bios=hd0,gpt3 --hint-efi=hd0,gpt3 --hint-baremetal=ahci0,gpt3 0e854bcc-6bdc-424c-a46e-251afc2842cc
else
search --no-floppy --fs-uuid --set=root 0e854bcc-6bdc-424c-a46e-251afc2842cc
fi
insmod gfxmenu
loadfont ($root)/@/usr/share/grub/themes/manjaro/dejavu_sans_12.pf2
loadfont ($root)/@/usr/share/grub/themes/manjaro/dejavu_sans_14.pf2
loadfont ($root)/@/usr/share/grub/themes/manjaro/dejavu_sans_16.pf2
loadfont ($root)/@/usr/share/grub/themes/manjaro/dejavu_sans_24.pf2
loadfont ($root)/@/usr/share/grub/themes/manjaro/dejavu_sans_48.pf2
loadfont ($root)/@/usr/share/grub/themes/manjaro/dejavu_sans_bold_16.pf2
loadfont ($root)/@/usr/share/grub/themes/manjaro/dejavu_sans_mono_12.pf2
loadfont ($root)/@/usr/share/grub/themes/manjaro/terminus-12.pf2
loadfont ($root)/@/usr/share/grub/themes/manjaro/terminus-14.pf2
loadfont ($root)/@/usr/share/grub/themes/manjaro/terminus-16.pf2
loadfont ($root)/@/usr/share/grub/themes/manjaro/terminus-18.pf2
loadfont ($root)/@/usr/share/grub/themes/manjaro/terminus-b12.pf2
loadfont ($root)/@/usr/share/grub/themes/manjaro/terminus-b14.pf2
loadfont ($root)/@/usr/share/grub/themes/manjaro/terminus-b16.pf2
loadfont ($root)/@/usr/share/grub/themes/manjaro/terminus-b18.pf2
insmod png
set theme=($root)/@/usr/share/grub/themes/manjaro/theme.txt
export theme
if [ x$feature_timeout_style = xy ] ; then
set timeout_style=menu
set timeout=5
# Fallback normal timeout code in case the timeout_style feature is
# unavailable.
else
set timeout=5
fi
### END /etc/grub.d/00_header ###
### BEGIN /etc/grub.d/10_linux ###
menuentry 'Manjaro Linux' --class manjaro --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-0e854bcc-6bdc-424c-a46e-251afc2842cc' {
load_video
set gfxpayload=keep
insmod gzio
insmod part_gpt
insmod btrfs
set root='hd0,gpt2'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-ieee1275='ieee1275//disk@0,gpt2' --hint-bios=hd0,gpt2 --hint-efi=hd0,gpt2 --hint-baremetal=ahci0,gpt2 0002937f-36b7-48ec-9c04-181fe4f1cbfb
else
search --no-floppy --fs-uuid --set=root 0002937f-36b7-48ec-9c04-181fe4f1cbfb
fi
linux /vmlinuz-5.3-x86_64 root=UUID=0e854bcc-6bdc-424c-a46e-251afc2842cc rw rootflags=subvol=@ quiet
initrd /amd-ucode.img /initramfs-5.3-x86_64.img
}
submenu 'Advanced options for Manjaro Linux' $menuentry_id_option 'gnulinux-advanced-0e854bcc-6bdc-424c-a46e-251afc2842cc' {
menuentry 'Manjaro Linux (Kernel: 5.3rc7.d0901.g089cf7f-1-MANJARO x64)' --class manjaro --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.3rc7.d0901.g089cf7f-1-MANJARO x64-advanced-0e854bcc-6bdc-424c-a46e-251afc2842cc' {
load_video
set gfxpayload=keep
insmod gzio
insmod part_gpt
insmod btrfs
set root='hd0,gpt2'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-ieee1275='ieee1275//disk@0,gpt2' --hint-bios=hd0,gpt2 --hint-efi=hd0,gpt2 --hint-baremetal=ahci0,gpt2 0002937f-36b7-48ec-9c04-181fe4f1cbfb
else
search --no-floppy --fs-uuid --set=root 0002937f-36b7-48ec-9c04-181fe4f1cbfb
fi
linux /vmlinuz-5.3-x86_64 root=UUID=0e854bcc-6bdc-424c-a46e-251afc2842cc rw rootflags=subvol=@ quiet
initrd /amd-ucode.img /initramfs-5.3-x86_64.img
}
menuentry 'Manjaro Linux (Kernel: 5.3rc7.d0901.g089cf7f-1-MANJARO x64 - fallback initramfs)' --class manjaro --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.3rc7.d0901.g089cf7f-1-MANJARO x64-fallback-0e854bcc-6bdc-424c-a46e-251afc2842cc' {
load_video
set gfxpayload=keep
insmod gzio
insmod part_gpt
insmod btrfs
set root='hd0,gpt2'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-ieee1275='ieee1275//disk@0,gpt2' --hint-bios=hd0,gpt2 --hint-efi=hd0,gpt2 --hint-baremetal=ahci0,gpt2 0002937f-36b7-48ec-9c04-181fe4f1cbfb
else
search --no-floppy --fs-uuid --set=root 0002937f-36b7-48ec-9c04-181fe4f1cbfb
fi
linux /vmlinuz-5.3-x86_64 root=UUID=0e854bcc-6bdc-424c-a46e-251afc2842cc rw rootflags=subvol=@ quiet
initrd /initramfs-5.3-x86_64-fallback.img
}
}
### END /etc/grub.d/10_linux ###
### BEGIN /etc/grub.d/20_linux_xen ###
### END /etc/grub.d/20_linux_xen ###
### BEGIN /etc/grub.d/30_os-prober ###
### END /etc/grub.d/30_os-prober ###
### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
### END /etc/grub.d/40_custom ###
### BEGIN /etc/grub.d/41_custom ###
if [ -f ${config_directory}/custom.cfg ]; then
source ${config_directory}/custom.cfg
elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then
source $prefix/custom.cfg;
fi
### END /etc/grub.d/41_custom ###
### BEGIN /etc/grub.d/41_snapshots-btrfs ###
submenu 'Arch Linux snapshots' {
configfile "/grub/grub-btrfs.cfg"
}
### END /etc/grub.d/41_snapshots-btrfs ###
### BEGIN /etc/grub.d/60_memtest86+ ###
if [ "${grub_platform}" == "pc" ]; then
menuentry "Memory Tester (memtest86+)" --class memtest86 --class gnu --class tool {
search --fs-uuid --no-floppy --set=root --hint-ieee1275='ieee1275//disk@0,gpt2' --hint-bios=hd0,gpt2 --hint-efi=hd0,gpt2 --hint-baremetal=ahci0,gpt2 0002937f-36b7-48ec-9c04-181fe4f1cbfb
linux16 /memtest86+/memtest.bin
}
fi
### END /etc/grub.d/60_memtest86+ ###
I modified grub-btrfs to work with AMD microcode only (comment out the business about the intel file {the microcode filename just has "amd" instead of "intel" prefixed }) and with timeshift. Maybe I make a pull-request one time.
It would be nice to have the config option to see AMD microcode only. So the menu gets uncluttered on a AMD machine.
for timeshift, just the path line must be changed from .snapshots to /mnt/timeshift/backup/timeshift-btrfs/snapshots/
snapper-gui work great in SUSE but breaks on most other distros unfortunately.
Hi,
When I try to run "sh 41_snapshots-btrfs" nothing happens, no output, nothing :(
[demo@btrfs01 grub.d]$ sh 41_snapshots-btrfs
[demo@Abemisser grub.d]$
My EFI is mounted at /boot/efi and my grub.cfg is located in /boot/efi/grub/ I don't if this has something to say?
Linux 4.19.1-arch1-1-ARCH #1 SMP PREEMPT Sun Nov 4 16:49:26 UTC 2018 x86_64 GNU/Linux
Is it possible to enable some kind of debug log?
Best Regards
Soren
This is one specific request for much nicer support of snapper's snapshots, originally mentioned in #23:
Make the script run snapper list
, and use the description column for the snapshot in the GRUB menu instead of the current one. The script should not require any configuration (contrary to #28), just run snapper list
and fallback to the current implementation if the command returned with a non-zero exit code or didn't produce a table of entries to parse. If only some of the discovered snapshots are not mentioned in the output of snapper list
, again fallback and name those snapshots with the current naming scheme.
PR #28 should be closed because #23 is an invalid issue, but some bits and pieces of the PR can be reused to implement this feature.
I can make a PR, @Antynea are you still around to review and merge?
On Arch Linux I am getting an issue where it will include snapshots of docker containers on my machine at
var/lib/docker/btrfs/subvolumes
despite it being included in /etc/default/grub-btrfs/
config here:
57 GRUB_BTRFS_IGNORE_SPECIFIC_PATH=("var/lib/docker" "@var/lib/docker" "var/lib/docker/btrfs/subvolumes" "@/var/lib/docker/btrfs/subvolumes/")
Post pac-snap output:
Found snapshot: 2020-10-01 20:34:38 | @/.snapshots/5/snapshot | pre | pacman -Syu Found snapshot: 2020-10-01 16:30:38 | @/.snapshots/1/snapshot | single | timeline Found snapshot: 2020-09-21 13:56:05 | @/var/lib/docker/btrfs/subvolumes/12ee3841107f6a84f2dd8d27de3add46ac93be3ed05e9c4d38dbb505085b06ea-init Found snapshot: 2020-09-19 04:48:14 | @/var/lib/docker/btrfs/subvolumes/ca4982dd926876676465206d1ecd78f98af61d1e10cad81abae6e53e161c635c-init Found snapshot: 2020-09-12 18:31:19 | @/var/lib/docker/btrfs/subvolumes/976ac50fc3e045ba3011ae8409dd156b8e3879304766a2bc422e832ef386baeb Found snapshot: 2020-09-12 18:31:19 | @/var/lib/docker/btrfs/subvolumes/98a5c0240b308ccb3610459ac48acfcad9afd24a0a77e86c68b9eab5781096af Found snapshot: 2020-09-12 18:31:19 | @/var/lib/docker/btrfs/subvolumes/9def363859fbba065560c821a0be16b4b16f749d089690f68b8c5e11e9aab4c9 Found snapshot: 2020-09-12 18:31:16 | @/var/lib/docker/btrfs/subvolumes/6000b365c4369b1aea0bc2b38e2333c50f54c44e18da5972bb109867d52e8731 Found snapshot: 2020-09-12 18:12:54 | @/var/lib/docker/btrfs/subvolumes/3ceadc8495ce125b0d9b0c6ba045dc15927d516331ddd3597c350aef2620ceaa Found snapshot: 2020-09-12 18:12:54 | @/var/lib/docker/btrfs/subvolumes/3ceadc8495ce125b0d9b0c6ba045dc15927d516331ddd3597c350aef2620ceaa-init Found snapshot: 2020-09-12 02:19:25 | @/var/lib/docker/btrfs/subvolumes/462c1909d14af8d924849922ed4185525dabee22f8b35e17b6c58f951bca4eda Found snapshot: 2020-09-12 02:19:24 | @/var/lib/docker/btrfs/subvolumes/ac8542243671fcc2a057d21373be0fa8f0df1693b56edfc032595acb97ce360c Generated 400 total GRUB entries. You might experience issues loading snapshots menu in GRUB. Found 50 snapshot(s) done
Hi,
I have setup BTRFS snapshots successfully and can boot any snapshot from Grub.
However I have identified an issue related to snapshot rollback.
Steps to reproduce the issue (with Debian 9.6):
snapper rollback X
snapper rollback
will create additional snapshots, of which one is a read-write snapshot Y of snapshot X; in addition this snapshot Y will be set as default snapshot (corresponding to btrfs subvolume set-default Y
)The system will not boot and run into Kernel panic.
A workaround to boot w/o errors is to edit the entry related to default by means of modifying the line starting with "linux"; here the string rootflags=...
must be deleted.
Do you have an idea for a permanent fix?
Generating grub configuration file
Found theme: /usr/share/grub/themes/Vimix/theme.txt
Found linux image: /boot/vmlinuz-5.4-x86_64
Found initrd image: /boot/amd-ucode.img /boot/initramfs-5.4-x86_64.img
Found initrd fallback image: /boot/initramfs-5.4-x86_64-fallback.img
Found linux image: /boot/vmlinuz-5.4-rt-x86_64
Found initrd image: /boot/amd-ucode.img /boot/initramfs-5.4-rt-x86_64.img
Found initrd fallback image: /boot/initramfs-5.4-rt-x86_64-fallback.img
###### - Grub-btrfs: Snapshot detection started - ######
# Info: Separate boot partition not detected
Config 'root' not found.
Config 'root' not found.
Config 'root' not found.
# No snapshots found.
# If you think an error has occurred , please file a bug report at " https://github.com/Antynea/grub-btrfs "
# Nothing to do. Abort.
###### - Grub-btrfs: Snapshot detection ended - ######
Found memtest86+ image: /boot/memtest86+/memtest.bin
Grub was not displayed
error sparse file not allowed
Hi,
this is certainly not an issue but rather an enhancement request, or at least a question to the developers.
So, I like the software you developed in the context of BTRFS + GRUB.
However, I don't know if GRUB menu will display multiple Linux installations in dedicated BTRFS subvolumes of the same BTRFS partition.
What is needed for this?
THX
Hi,
I have installed and configured grub-btrfs w/o issues.
And I can see in screen that existing BTRFS snapshots are found when new Grub Menu is generated.
However, when I check the submenu in Grub there are no entries.
Could you please advise how to troubleshoot this issue?
THX
Getting this error on update-grub
Generating grub configuration file ...
Found theme: /boot/grub/themes/EndeavourOS/theme.txt
Found linux image: /boot/vmlinuz-linux-lts
Found initrd image: /boot/amd-ucode.img /boot/initramfs-linux-lts.img
Found fallback initrd image(s) in /boot: initramfs-linux-lts-fallback.img
Found linux image: /boot/vmlinuz-linux
Found initrd image: /boot/amd-ucode.img /boot/initramfs-linux.img
Found fallback initrd image(s) in /boot: initramfs-linux-fallback.img
###### - Grub-btrfs: Snapshot detection started - ######
# Info: Separate boot partition not detected
ERROR: not a btrfs filesystem: /
ERROR: can't access '/'
# No snapshots found.
# If you think an error has occurred , please file a bug report at " https://github.com/Antynea/grub-btrfs "
# Nothing to do. Abort.
###### - Grub-btrfs: Snapshot detection ended - ######
Found memtest86+ image: /boot/memtest86+/memtest.bin
done'
Hi,
Snapshots are not detected on my system.
When I run grub-mkconfig -o /boot/grub/grub.cfg, I get the output below.
Generating grub configuration file ...
Found theme: /usr/share/grub/themes/starfield/theme.txt
Found linux image: /boot/vmlinuz-linux
Found initrd image: /boot/intel-ucode.img /boot/initramfs-linux.img
Found fallback initrd image(s) in /boot: initramfs-linux-fallback.img
###### - Grub-btrfs: Snapshot detection started - ######
# Info: Separate boot partition not detected
# No snapshots found.
# If you think an error has occurred , please file a bug report at " https://github.com/Antynea/grub-btrfs "
# Nothing to do. Abort.
###### - Grub-btrfs: Snapshot detection ended - ######
done
Could you please help me on that?
My system is Arch Linux. These are the related packages on my system:
grub 2:2.02-7
grub-btrfs 3.2-1
snap-pac-grub 1.0.4-1
Thanks in advance!
Sadly I could not find more information on how and why the error occurs but while creating the grub config with grub-mkconfig -o /boot/grub/grub.cfg
, /etc/grub.d/41_snapshots-btrfs
tells me that on lines 296
and 309
, 0882080592106262008919021151341962250
is too large for the current base
and blames char \"0882080592106262008919021151341962250\"
.
Mentioned lines actually contain the same code:
296: if [[ "$snapper_id" -eq "$id" ]]; then
309: if [[ "$snapper_id" -eq "$id" ]]; then
OS: Arch Linux
Kernel: x86_64 Linux 4.14.10-1-ARCH
CPU: Intel Core i7-3630QM @ 8x 3.4GHz
Grub: grub-2:2.02-4
Snapper: snapper-0.5.0-3
Snap-Pac: snap-pac-1.1-1
Hi,
I installed grub-btrfs and had it working briefly, however the option to boot into the snapshots stopped showing up in grub for some reason.
When I run grub-mkconfig -o /boot/grub/grub.cfg, I get the output below.
> Generating grub configuration file ...
> Found linux image: /boot/vmlinuz-linux
> Found initrd image: /boot/intel-ucode.img /boot/initramfs-linux.img
> Found fallback initrd image(s) in /boot: initramfs-linux-fallback.img
> Found Windows Boot Manager on /dev/nvme0n1p1@/EFI/Microsoft/Boot/bootmgfw.efi
> Detecting snapshots ...
> Info: Separate boot partition not detected
> Found snapshot: 2020-10-04 10:02:38 | timeshift-btrfs/snapshots/2020-10-04_10-02-38/@
> Found snapshot: 2020-10-04 10:00:01 | timeshift-btrfs/snapshots/2020-10-04_10-00-01/@
> Found snapshot: 2020-10-03 22:13:09 | timeshift-btrfs/snapshots/2020-10-03_22-13-09/@
> Found snapshot: 2020-10-03 12:44:02 | timeshift-btrfs/snapshots/2020-10-03_12-44-01/@
> Found snapshot: 2020-10-03 12:00:01 | timeshift-btrfs/snapshots/2020-10-03_12-00-01/@
> Found snapshot: 2020-10-02 15:38:00 | timeshift-btrfs/snapshots/2020-10-04_11-28-44/@
> Found 6 snapshot(s)
> Found Windows Boot Manager on /dev/nvme0n1p1@/EFI/Microsoft/Boot/bootmgfw.efi
> Detecting snapshots ...
> Info: Separate boot partition not detected
> Found snapshot: 2020-10-04 10:02:38 | timeshift-btrfs/snapshots/2020-10-04_10-02-38/@
> Found snapshot: 2020-10-04 10:00:01 | timeshift-btrfs/snapshots/2020-10-04_10-00-01/@
> Found snapshot: 2020-10-03 22:13:09 | timeshift-btrfs/snapshots/2020-10-03_22-13-09/@
> Found snapshot: 2020-10-03 12:44:02 | timeshift-btrfs/snapshots/2020-10-03_12-44-01/@
> Found snapshot: 2020-10-03 12:00:01 | timeshift-btrfs/snapshots/2020-10-03_12-00-01/@
> Found snapshot: 2020-10-02 15:38:00 | timeshift-btrfs/snapshots/2020-10-04_11-28-44/@
> Found 6 snapshot(s)
> done
Grub presents me with 2 boot options
Arch Linux & Windows 10, I'd like to restore the option to boot into Arch Linux snapshots if possible
These are the related packages on my system:
grub 2:2.04-8
grub-btrfs 4.6-1
timeshift 20.03-1
timeshift-autosnap 0.9-1
I'm also curious why my snapshots are showing up multiple times when I run grub-mkconfig -o /boot/grub/grub.cfg if you have any idea.
Thanks in advance!
The description of some snapshots is wrong. In this specific example, the description of all snapshots is just timeline. Sometimes just a few snapshots aren't named correctly.
$ sudo snapper ls
Type | # | Pre # | Date | User | Cleanup | Description | Userdata
-------+---+-------+-------------------------------+------+----------+-----------------------------------------------------------------------------+---------
single | 0 | | | root | | current |
single | 1 | | Fri 30 Mar 2018 23:31:44 CEST | root | | test123 |
pre | 2 | | Fri 30 Mar 2018 23:46:15 CEST | root | number | pacman -Ud /home/vagrant/.cache/pacaur/grub-btrfs/grub-btrfs-2.0.1-1-any... |
post | 3 | 2 | Fri 30 Mar 2018 23:46:17 CEST | root | number | grub-btrfs |
single | 4 | | Sat 31 Mar 2018 00:00:27 CEST | root | timeline | timeline |
single | 5 | | Sat 31 Mar 2018 13:10:45 CEST | root | timeline | timeline |
pre | 6 | | Sun 01 Apr 2018 13:14:23 CEST | root | number | pacman -Syu |
post | 7 | 6 | Sun 01 Apr 2018 13:15:22 CEST | root | number | gtk-update-icon-cache gtk3 linux linux-headers mpg123 openssl srt unrar ... |
$ sudo grub-mkconfig -o /boot/grub/grub.cfg
Generating grub configuration file ...
Found theme: /boot/grub/themes/Vimix/theme.txt
Found linux image: /boot/vmlinuz-linux
Found initrd image: /boot/initramfs-linux.img
Found fallback initrd image(s) in /boot: initramfs-linux-fallback.img
###### - Grub-btrfs: Auto-detect Start - ######
# Found snapshot: 2018-04-01 13:15:22 | @/.snapshots/7/snapshot | single | timeline
# Found snapshot: 2018-04-01 13:14:23 | @/.snapshots/6/snapshot | single | timeline
# Found snapshot: 2018-03-31 13:10:45 | @/.snapshots/5/snapshot | single | timeline
# Found snapshot: 2018-03-31 00:00:27 | @/.snapshots/4/snapshot | single | timeline
# Found snapshot: 2018-03-30 23:46:17 | @/.snapshots/3/snapshot | single | timeline
# Found snapshot: 2018-03-30 23:46:15 | @/.snapshots/2/snapshot | single | timeline
# Found snapshot: 2018-03-30 23:31:44 | @/.snapshots/1/snapshot | single | timeline
# Found 7 snapshot(s)
###### - Grub-btrfs: Auto-detect End - ######
done
However, the assignment of the snapshots is correct. If I boot into snapshot #6 for example, the old kernel is loaded.
When one is selecting a r/o snapshot, grub-btrfs
should create a new snapshot based on the selection one but in r/w mode such that the original snapshot is not changed!
Bit of a hairy one.
As the docker snapshots include linux kernels, autodetect is finding them and adding them to the boot menu.
Interestingly I actually think it might be possible to boot them (haven't checked yet) but it's very unlikely that you'd ever actually want to do this.
> Attempting to update grub-cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-linux
Found initrd image: /boot/initramfs-linux.img
Found fallback initramfs image: /boot/initramfs-linux-fallback.img
###### - Grub-btrfs: Auto-detect - ######
# Found Snapshot: 2016-03-31 10:26:52 var/lib/docker/btrfs/subvolumes/74040aee4fa98f7dc6bbdcd7df8e361352c7d9dc55440ee54f312eda1f52079c
# Found Snapshot: 2016-03-31 10:26:50 var/lib/docker/btrfs/subvolumes/74040aee4fa98f7dc6bbdcd7df8e361352c7d9dc55440ee54f312eda1f52079c-init
# Found Snapshot: 2016-03-31 10:26:46 var/lib/docker/btrfs/subvolumes/b61091160bd9583172cf1a4f81be99b244aefa0674f1e04cd5990928552e0825
# Found Snapshot: 2016-03-31 10:26:45 var/lib/docker/btrfs/subvolumes/b61091160bd9583172cf1a4f81be99b244aefa0674f1e04cd5990928552e0825-init
# Found Snapshot: 2016-03-31 10:26:42 var/lib/docker/btrfs/subvolumes/5bc5ce665173d6fbc356096f938e8ebf4b3b69e2aa6c779c88e5ba19edcacd66
# Found Snapshot: 2016-03-31 10:26:42 var/lib/docker/btrfs/subvolumes/5bc5ce665173d6fbc356096f938e8ebf4b3b69e2aa6c779c88e5ba19edcacd66-init
# Found Snapshot: 2016-03-31 10:25:00 .snapshots/913/snapshot
# Found Snapshot: 2016-03-31 10:24:41 var/lib/docker/btrfs/subvolumes/805c0ef9f093c6fc2685ec9592485c2bca478f3cd0b8716533d0e78a3f07aa20
# Found Snapshot: 2016-03-31 10:24:36 var/lib/docker/btrfs/subvolumes/805c0ef9f093c6fc2685ec9592485c2bca478f3cd0b8716533d0e78a3f07aa20-init
# Found Snapshot: 2016-03-31 10:22:22 .snapshots/912/snapshot
# Found Snapshot: 2016-03-31 10:00:27 .snapshots/911/snapshot
###### - Grub-btrfs: Auto-detect - ######
Hello,
I've configured grub-btrfs to boot my snapshot, but when I execute :
# snapper rollback
I've got this error
Creating read-only snapshot of default subvolume.IO Error (.snapshots is not a btrfs subvolume).
Also, I'm working with Kubuntu 17.10 and Plasma Desktop not loaded when booting any snapshots, only boot to text mode.
I'll appreciate if help me to fix this.
Thanks
Hello Dev Team
I am completely new on Linux, and have just installed Manjaro after deleting my Win10 and hopping like 10 distros in these days. I ended up with Manjaro.
I encountered some seemingly errors after updating may Grub on a clean install and just wanted to report here as per the request within the terminal, so I just followed the instructions there with a link to here.
My OS is working perfectly and booting so I have no clue is there is any error or not so I just report it here for your information.
LUKS full disk encryption with Btrfs is the active, working setup.
Operating System: Manjaro Linux
KDE Plasma Version: 5.19.5
KDE Frameworks Version: 5.73.0
Qt Version: 5.15.0
Kernel Version: 5.7.19-2-MANJARO
OS Type: 64-bit
Processors: 12 × Intel® Core™ i7-8700K CPU @ 3.70GHz
Memory: 15.6 GiB of RAM
Graphics Processor: GeForce RTX 2070/PCIe/SSE2
Title. I ignored the /var/lib/docker directory on /etc/default/grub-btrfs/config
and docker subvolumes still get detected as snapshots.
On grub-mkconfig (on the pacman hook, but running grub-mkconfig -o /boot/grub/grub.cfg
yields the same)
Using /var/lib/docker
or var/lib/docker
has exactly the same effect.
edit: for the record, var is on a different subvolume
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.