-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merge openRC and systemd daemon #218
Conversation
I noticed on my systemd laptop that the directory |
Signed-off-by: Jaeger <Pascal.Jaeger@bode-kassel.com>
Signed-off-by: Pascal Jäger <pascal.jaeger@leimstift.de>
Signed-off-by: Pascal Jäger <pascal.jaeger@leimstift.de>
I think this is almost ready by now. I am just playing around with logging options and such. |
Against spamming the syslog
I have tried @Schievel1 's repo but it doesn't work for me using timeshift under Debian Testing. I installed the systemd service, started and enabled it, created a new snapshot then rebooted but GRUB doesn't get updated. Your installation instructions are incomplete and I suspect you are making some presumptions about peoples default or existing timeshift / BTRFS config. I've had a quick look at grub-btrfsd and one command that I can see its using that isn't installed by default under Debian is inotifywait which Debian and Ubuntu users can install by installing inotify-tools. Do your scripts depend upon any other non standard commands except inotify? grub-btrfsd.service still didn't work after installing inotify-tools and rebooting.
What does it expect of /.snapshots? That dir does not exist by default after installing timeshift under Debian. |
Thanks for testing that out. Yes that's correct, you need inotify for grub-btrfsd. https://packages.debian.org/bullseye/inotify-tools The service is configured to use snapper by default, have you edited it with |
No. What do I need to change within grub-btrfsd to make it work with timeshift? EDIT Oh this is covered in the README... |
Well its partly covered but it doesn't tell the user what path timeshift systemd users should be using or how to find out the correct path. I happen to know that it should be /run/timeshift/ but grub-btrfsd still doesn't successfully start for me:
|
My grub-btrfsd config:
|
Correct! /run/timeshift only appears when I have timeshift running. You say you've tested this as working with systemd and timeshift? Under which OS? |
Thanks for posting that service-file here, that you configured. With more information it is always easier to do troubleshooting. No, the order of arguments is [optional flags] (mendatory arguments) as usual. So you wanna put "ExecStart=/usr/bin/grub-btrfsd --timeshift-auto --syslog (path to snapshots dir) into that line. But since you activated --timeshift-auto you can omit the snapshots dir argument. It just gets ignored. |
Looks like you made a typo there - /usr/bin/brfsd. You meant /usr/bin/grub-btrfsd ofc. |
waves hands frantically |
You're right, I forgot to put the "--syslog" there, will fix that later |
It's still not working. I'm using:
|
The good news is that at least the service is running now but GRUB isn't getting updated when I create or delete snapshots.
|
You're not expecting the user to edit or uncomment all the required variables within the config file before they install and use grub-btrfs are you? I ask because I see lines like this in
I can see GRUB_BTRFS_MKCONFIG is defined in |
Hm now this is becoming interesting. Maybe a versioning thing. Could you stop the service with systemctl, then go I to that directory you made when doing the git clone and run "sudo ./grub-btrfsd -t -v" This is like running the service but you get the direct output. -v sets verbose mode for more information. |
It seemed to update GRUB when I removed an existing snapshot but it didn't update GRUB when I created a new snapshot
|
Strange! It didn't work first time I tried it but then I deleted the snapshot and made a new one and it worked.
|
Its still not working. Because I was seeing lines like:
In the log I presumed GRUB was getting updated but its not, after rebooting to check. It looks like $prefix isn't getting set. |
The daemon is running fine, the line that says What's the output when you run grub-btrfs? Command is "sudo /etc/grub.d/41_snapshots-btrfs" But thanks for posting that and testing it. It didn't occur to me that saying "grub menu recreated" in the log regardless if it really worked isn't a good idea :D |
|
Where is ${prefix} set? |
I think right now we are starting to troubleshoot an issue with grub-btrfs, not with the daemon, which this PR is about. Could you rollback to 4.11 and run /etc/grub.d/41_snapshots-btrfs manually? If the problem is still there, file an issue. // hm, wait a sec. Maybe this IS a problem with the daemon. maybe we are triggering the grub-btrfs script too fast sometimes? Thanks again for testing this out, I really appreciate it. That's always the problem with those timings. "It works on my machine" is just a recipe for desaster |
Increasing the sleep to 15 hasn't fixed it. |
But when you make a snapshot and run /etc/grub.d/41_snapshots-btrfs it works every time? That just plain strange, the daemon does run the script, and it does not run it any different than you would run it manually / btw instead of rebooting every time to check if the snaps appear in the grub menu what I do is "cat /boot/grub/ | grep 2022" and the check with the time if the snapshot appears in there |
I didn't say that no. All I said was that the debug output printed when running |
Oh. Alright I got that wrong. |
I already have have a proven working (but systemd only) solution based on the existing main grub-btrfs repo so the problem is definitely in your repo. |
Ok I just found something, can you do a "cat /boot/grub/grub.cfg" and post the last ~30 lines here? /and sorry I gotta ask that again even though I saw that your prompt was a # : you are sure you ran all that as root/ with sudo? |
|
Ok great. Can you do "sudo grub-mkconfig -o /boot/grub/grub.cfg" Last few lines is enough |
|
It's working now, isn't it? |
What makes you say that? Yes,I can see a snapshot in GRUB but we've just manually updated GRUB so the scripts are still broken. Why don't you install Debian in a VM so you can cut out the middle man? |
Note that you'll want to use the Calamares GUI installer on the desktop of the Debian Live install iso's to get BTRFS installed with separate subvols for / and /home configured by default. The text old and old style Debian GUI installers don't do this. https://cdimage.debian.org/debian-cd/current-live/amd64/iso-hybrid/ |
I think what happened here is when you removed the grub-btrfs you had before, the menu from grub.cfg got removed. Generate your grub menu after installation for the changes to take effect. Sorry I forgot to mention that in the PR. I thank you for your testing again, while this is not really a problem with the PR itself, we learned a lot along the way:
Thanks for that. I will definitely look into that, once we support Debian we support like half of the Linux distros out there. For now I don't think the grub from Debian is acting much different than the grub from arch. (Gentoo is a different story with its USE flags though) |
Not quite. I removed my custom systemd services for updating GRUB and I removed the extra /etc/fstab mount point I had created to get that working, then I did a
Forgot to mention what in the PR? If you can get it working in a Debian VM, installed as per my previous post then I'll test it again but your current code doesn't seem to work under Debian / systemd with timeshift. |
I am not sure about that. How did all this alter the grub.cfg?
That you have to run grub-mkconfig once after installation. |
My systemd solution doesn't require this and I don't see why yours would either. |
No it does. All of them do. Doesn't matter which daemon you have, it says Generate your grub menu after installation for the changes to take effect." In the readme for ages now. You need to run grub-mkconf to generate those lines in grub.cfg:
This is the grub menu entry, which calls the submenu in /boot/grub/grub-btrfs.cfg. / nuff said, is it working now? |
Signed-off-by: Pascal Jäger <pascal.jaeger@leimstift.de>
Signed-off-by: Pascal Jäger <pascal.jaeger@leimstift.de>
When a snapshot is created with `timeshift --create` an the commandline, sometimes the daemon is not fast enough between the first (/run/timeshift) inotifywait and the second (an the actual snapshot directory) inotifywait. Even without any `sleep` between them. So now the grub (sub)menu is always created once in its own process when the daemon sees a timeshift startup. Signed-off-by: Pascal Jäger <pascal.jaeger@leimstift.de>
Improvement with this PR
While systemd's mount services are a charming solution, they are somewhat limited and inflexible. (See #213, #211, #215)
With the daemon we wrote for openRC, we had all the flexibility a shell has, so it was easier to solve the newly arising problems with timeshift version 22.06.
So this removes the .path mount service of systemd, installs the daemon grub-btrfsd (formerly known as the openrc daemon) by default on all systems and changes the systemd service so that it runs the grub-btrfsd daemon instead.
I also changed the daemon itself. It now does not poll anymore and instead watches completely with inotifywait. It works with timeshift (version 22.06 and newer) and with snapper.
Thanks @Megver83 for contributing to this and also his ideas in #210
Before we merge this, I need to do this:
If someone is interested in testing this out:
Install the new dependency inotify-tools. (
sudo apt-get install inotify-tools
,sudo emerge inotify-tools
, however you install software on your distro. Inotify is a linux kernel utility, so the package inotify-tools should be available on nearly all linux distros)Clone my repository:
Go into the directory
cd grub-btrfs
Checkout the branch update-daemon
Run sudo make install, with the appropriate options:
sudo make install # for systemd, as this is the default option
sudo make SYSTEMD=false OPENRC=true install # for openrc
After installation run
For configuration of the service/ daemon check out the Readme at https://github.com/Schievel1/grub-btrfs/tree/update-daemon
Warning: By default the service is configured to use snapper with the snapshots directory
/.snapshots
, look up the readme @ https://github.com/Schievel1/grub-btrfs/tree/update-daemon on how to configure it for timeshift.Also check out the nice manpages with
man grub-btrfs
andman grub-btrfsd
and maybe read a bit and point out mistakes I made. (as english is not my native language)