-
-
Save kimono-koans/7641ee7bc7ce91f520b324bb08d699c8 to your computer and use it in GitHub Desktop.
You're going to need to snap your root according to zsys convention (just using a date won't work), like this: | |
#!/bin/bash | |
DATE_HASH="$( date | cksum | cut -f1 -d' ' | tr -d '\n' | xargs -0 printf '%x\n' )" | |
zfs snapshot -r bpool@snap_"$DATE_HASH"_prepApt | |
zfs snapshot rpool@snap_"$DATE_HASH"_prepApt | |
zfs snapshot -r rpool/ROOT@snap_"$DATE_HASH"_prepApt | |
zfs snapshot -r rpool/USERDATA@snap_"$DATE_HASH"_prepApt | |
And you'll need to execute such a script before 'apt upgrade' from /etc/apt/apt.conf.d: | |
// Takes a snapshot of the system before package changes. | |
DPkg::Pre-Invoke {"[ -x /usr/local/sbin/snapPrepApt ] && /usr/local/sbin/snapPrepApt || true";}; | |
And when you update your kernel from /etc/kernel/preinst.d like so: | |
#!/bin/sh | |
[ -x /usr/local/sbin/snapPrepApt ] && /usr/local/sbin/snapPrepApt || true | |
This seems to work with the initramfs/GRUB hooks which remain after you purge zsys. |
@kimono-koans can you verify the above? thank you!
Is there any chance you might update this as per the comments above by @almightiest?
I have a 20.04 system I upgraded to 22.04 and it still has zsys on it.
I'm not entirely sure I understand the instructions and reading @almightiest comments makes me even more confused...
@kimono-koans can you verify the above? thank you!
Hey @almightiest did you ever figure this out, I'm trying to remove zsys and I'm a little lost. I really wish Canonical would have provided clear instructions on how to remove zsys.
@46cv8 what makes you think the experiment is defunct? (See OpenZFS on Ubuntu 24.04)
I've been using ZFS on a 22.04 desktop installation for about 2 years now. I would say it is not for the faint-of-heart.
@46cv8 I did what was in my post and it worked, but I ended up installing 24.04 from scratch due to another issue unrelated. I followed the guide from https://github.com/Sithuk/ubuntu-server-zfsbootmenu
@46cv8 what makes you think the experiment is defunct? (See OpenZFS on Ubuntu 24.04)
I've been using ZFS on a 22.04 desktop installation for about 2 years now. I would say it is not for the faint-of-heart.
Hey @fpga-guy , Sorry the wording I used was unnecessary. I removed it, then refreshed just now only to see your comment referencing my wording :) Awkwardling coincidental. I've been using ZoL with zsys since 20.04 first released, and generally it's ok. However of the two times I tried to rollback, I always ended up with mismatched root and user data sets, and ended up i other strange situations that required recovering from a hard disk image backups. My use of the wording defunct, was not appropriate, but was mainly to reflect the multitude of users who have experienced issues and the lack of continued development beyond upgrades for continued compatibility (of which I am grateful).
Unrelated to this GIST, but perhaps you might have had a similar issue and can share some wisdom.
After upgrading to 22.04 from 20.04 this January I ended up with duplicate userdata datasets, The old ones appear to be not mounted, but they are the ones that generating snapshots, meanwhile the new ones, are not generating snapshots but they are mounted.
I've lost almost all the benefit of running zsys for backups as I'm afraid to even attempt to do a rollback as I have no idea which of my userdata datasets would get used, and it might result in my losing a bunch of data like ubuntu/zsys#218
I am not sure how to tell zsys which of the two datasets it should use for backups, it seems to be mounting a different one than the one it seems to want to take snapshots of.
Here's what it shows as
zsysctl show --full
Name: rpool/ROOT/ubuntu_zysz53
ZSys: true
Last Used: current
Last Booted Kernel: vmlinuz-6.8.0-45-generic
System Datasets:
- bpool/BOOT/ubuntu_zysz53
- rpool/ROOT/ubuntu_zysz53
- rpool/ROOT/ubuntu_zysz53/srv
- rpool/ROOT/ubuntu_zysz53/usr
- rpool/ROOT/ubuntu_zysz53/var
- rpool/ROOT/ubuntu_zysz53/usr/local
- rpool/ROOT/ubuntu_zysz53/var/games
- rpool/ROOT/ubuntu_zysz53/var/lib
- rpool/ROOT/ubuntu_zysz53/var/log
- rpool/ROOT/ubuntu_zysz53/var/mail
- rpool/ROOT/ubuntu_zysz53/var/snap
- rpool/ROOT/ubuntu_zysz53/var/spool
- rpool/ROOT/ubuntu_zysz53/var/www
- rpool/ROOT/ubuntu_zysz53/var/lib/AccountsService
- rpool/ROOT/ubuntu_zysz53/var/lib/NetworkManager
- rpool/ROOT/ubuntu_zysz53/var/lib/apt
- rpool/ROOT/ubuntu_zysz53/var/lib/dpkg
- rpool/ROOT/ubuntu_zysz53/var/lib/libvirt
User Datasets:
User: root
- rpool/USERDATA/root_ay5lx4
User: me
- rpool/USERDATA/me_ay5lx4
=== truncated ===
zsysctl machine show
Name: rpool/ROOT/ubuntu_zysz53
ZSys: true
Last Used: current
History:
- Name: rpool/ROOT/ubuntu_zysz53@autozsys_owqm41
Created on: 2024-09-15 06:40:15
Users:
- Name: me
History:
- rpool/USERDATA/me_ay5lx4@autozsys_9zrct9 (2024-09-16 17:20:27)
- rpool/USERDATA/me_ay5lx4@autozsys_g3slmh (2024-09-16 16:20:14)
- rpool/USERDATA/me_ay5lx4@autozsys_yss3gn (2024-09-16 15:50:54)
- rpool/USERDATA/me_ay5lx4@autozsys_ybuc4b (2024-09-16 14:50:43)
- rpool/USERDATA/me_ay5lx4@autozsys_s3ctfq (2024-09-16 13:50:32)
- rpool/USERDATA/me_ay5lx4@autozsys_owqm41 (2024-09-15 06:40:15)
- rpool/USERDATA/me_ay5lx4@autozsys_4t8vy5 (2024-02-08 13:23:19)
- rpool/USERDATA/me_svq82i (0001-01-01 00:00:00)
- Name: root
History:
- rpool/USERDATA/root_ay5lx4@autozsys_owqm41 (2024-09-15 06:40:15)
- rpool/USERDATA/root_ay5lx4@autozsys_lc09rk (2024-05-23 06:06:31)
- rpool/USERDATA/root_ay5lx4@autozsys_zj9059 (2024-05-22 06:45:25)
- rpool/USERDATA/root_ay5lx4@autozsys_usa8oh (2024-05-15 06:04:33)
- rpool/USERDATA/root_ay5lx4@autozsys_hpfi7t (2024-05-11 11:40:04)
- rpool/USERDATA/root_ay5lx4@autozsys_4t8vy5 (2024-02-08 13:23:19)
- rpool/USERDATA/root_svq82i (0001-01-01 00:00:00)
zfs list -r -o creation,space,mountpoint,mounted rpool/USERDATA
CREATION NAME AVAIL USED USEDSNAP USEDDS USEDREFRESERV USEDCHILD MOUNTPOINT MOUNTED
Mon Aug 24 14:26 2020 rpool/USERDATA 192G 231G 0B 96K 0B 231G / no
Mon Aug 24 14:29 2020 rpool/USERDATA/me_ay5lx4 192G 184G 245M 183G 0B 0B /home/me no
Thu Feb 8 17:24 2024 rpool/USERDATA/me_svq82i 192G 47.1G 0B 47.1G 0B 0B /home/me yes
Mon Aug 24 14:29 2020 rpool/USERDATA/root_ay5lx4 192G 44.9M 208K 44.7M 0B 0B /root no
Thu Feb 8 17:24 2024 rpool/USERDATA/root_svq82i 192G 1.73M 0B 1.73M 0B 0B /root yes
@46cv8 I did what was in my post and it worked, but I ended up installing 24.04 from scratch due to another issue unrelated. I followed the guide from https://github.com/Sithuk/ubuntu-server-zfsbootmenu
Thanks for the reply I think I understand after re-reading your comment afew times. I may attempt this after I do a full image backup. I should probably also try updating my kernel just to confirm that part of the snapshot process also works properly if I attempt it. Thanks again.
@46cv8 I did what was in my post and it worked, but I ended up installing 24.04 from scratch due to another issue unrelated. I followed the guide from https://github.com/Sithuk/ubuntu-server-zfsbootmenu
Thanks for the reply I think I understand after re-reading your comment afew times. I may attempt this after I do a full image backup. I should probably also try updating my kernel just to confirm that part of the snapshot process also works properly if I attempt it. Thanks again.
Great idea. Test failure scenarios, while having a full image backup. Hopefully that's good ha.
I managed to fix my issues with zsys so I'm keeping it for the time being. I posted an answer on a stackexchange thread that helped me resolve the issue. https://askubuntu.com/questions/1388997/zsys-commit-service-fails-with-couldnt-promote-dataset-not-a-cloned-filesy/1528760#1528760
before any of this, did you do:
apt purge zsys
and then you created a new file
/usr/local/sbin/snapPrepApt
from lines 3-10 in this gist?and then you created a new file like
/etc/apt/apt.conf.d/90-snapPrepApt
from lines 14-15 in this gist?and then you created a new file like
/etc/kernel/preinst.d/snapPrepApt
from lines 19-20 in this gist?Am I missing anything else? What about upgrading to a newer version of zfs since zsys is no longer a dependency holding us back from upgrading?