how to replay a snapshot (btrfs) ?

Lentes, Bernd bernd.lentes at helmholtz-muenchen.de
Tue Jul 26 18:40:18 UTC 2016



----- Am 26. Jul 2016 um 20:19 schrieb Bernd Lentes bernd.lentes at helmholtz-muenchen.de:

> ----- Am 26. Jul 2016 um 17:59 schrieb Rashkae ubuntu at tigershaunt.com:
> 
>> On 16-07-26 08:55 AM, Lentes, Bernd wrote:
>>> Hi,
>>>
>>> sorry for asking this simple question. But i'm new to btrfs. And all the guides
>>> i found in the internet are different and none of them succeeded.
>>> I made a snapshot form my / , did some changes in the configurtaion (which
>>> weren't successfull), now i want to get back to the snapshot.
>>>
>>> This is my system:
>>>
>>> root at PC65472:~# btrfs sub list -ap /
>>> ID 257 gen 38915 parent 5 top level 5 path <FS_TREE>/@
>>> ID 258 gen 38903 parent 5 top level 5 path <FS_TREE>/@home
>>> ID 285 gen 38828 parent 257 top level 257 path @/snapshots/root_190720162124
>>>
>>> ID 285 is my snapshot.
>>>
>>> root at PC65472:~# btrfs sub get-default /
>>> ID 285 gen 38828 top level 257 path snapshots/root_190720162124
>>>
>>> I changed the snapshot to the default but i still have the configuration changes
>>> i'd like to loose.
>>> Also after a restart still no replay of the snapshot.
>>>
>> 
>> I suggest not changing the default subvolume... That way lies madness
>> 
>> In the typical Ubuntu install, the default top level subvolume (5) is
>> the default, and subvolume "@" is mounted as root.  (This is configured
>> in the Grub kernel parameters as well at /etc/fstab
>> 
>> Your situation is a bit complicacated because you have your snapshots
>> folder/subvolume as a subfolder of @.  This is how snapper program
>> handles it by default, but unless your scripts need to be setup that
>> way, I would change it, for your own convienience.  (If you were using
>> snapper, you would also use snapper to roll back changes.  I'm not
>> covering that in this message, however.
> 
> I didn't use snaper.
> 
>> 
>> You can do this by booting to a live CD, but I've successfully done this
>> on my live system as well, (ie, I changed root while booted to the
>> system, rebooted, and was successfully rolled back.  If your doing this
>> live, you'll want to make sure your not running anything that needs to
>> preserve it's running state.  To this right, you would usually boot into
>> some kind of single user mode.  But I can be recklessly wild when I know
>> what my desktop is doing/not doing.
>> 
> 
> I tried "systemctl rescue". But i couldn't login afterwards, after typing "root"
> system said "system is going down".
> Tried several times.
> I booted a live cd.
> 
>> If your default subvolume is still 285, make sure to change it back to
>> 5.  I think there might be booting problems if you change the default
>> subvolume.
>> 
> 
> IIRC correctly default was ID 257 so i set default to 257 and rebooted without
> any problem.
> 
>> 1.  Mount the device that contains your snapshots.  ex: mkdir /mnt/device
>> mount /dev/sda1 /mnt/device
> 
> mount /dev/vg1/lv_root /mnt/root
> 
>> ls /mnt/device should show sow a @ and @home directories.
> 
> yes
> 
>> 2. optional: move your snapshot folder out of the root.  mv
>> /mnt/device/@/snapshots /mnt/device/
> 
> didn't
> 
>> 3. rename your old root:  mv @ delete_me
> 
> 
> mv /mnt/root/ /mnt/root/old
> 
>> 4. create a new snapshot of your snapshot for use.
>> btrfs subvolume snapshot /mnt/device/snapshots/root_190720162124
>> /mnt/device/@
>> 
> 
> btrfs sub snapshot /mnt/root/snapshots/root_190720162124 /mnt/root/@
> 
> suceeded.
> 
>> Reboot
> 
>> You should now be rolled back.
> 
> No. Ran into busybox.
> 
> Rebooted again with a live cd.
> 
> mount /dev/vg1/lv_root /mnt/root
> 
> root at ubuntu:~# ll /mnt/root/
> insgesamt 0
> drwxr-xr-x 1 root root   8 Jul 26 17:35 ./
> drwxr-xr-x 1 root root  60 Jul 26 17:57 ../
> drwxr-xr-x 1 root root 244 Jul 19 20:19 @/
> drwxr-xr-x 1 root root 322 Jul 26 11:53 old/
> 
> root at ubuntu:~# ll /mnt/root/@
> insgesamt 16
> drwxr-xr-x 1 root root  244 Jul 19 20:19 ./
> drwxr-xr-x 1 root root    8 Jul 26 17:35 ../
> drwxr-xr-x 1 root root 2558 Jul 19 11:48 bin/
> drwxrwxr-x 1 root root    0 Jun  8 15:19 boot/
> drwxrwxr-x 1 root root    0 Jun  8 15:25 cdrom/
> drwxr-xr-x 1 root root  894 Apr 20 22:15 dev/
> drwxr-xr-x 1 root root 4636 Jul 19 19:28 etc/
> drwxrwxr-x 1 root root    0 Jun  8 15:19 home/
> lrwxrwxrwx 1 root root   32 Jul 15 11:26 initrd.img ->
> boot/initrd.img-4.4.0-31-generic
> lrwxrwxrwx 1 root root   32 Jun 28 01:18 initrd.img.old ->
> boot/initrd.img-4.4.0-28-generic
> drwxr-xr-x 1 root root  464 Jul 19 19:27 lib/
> drwxr-xr-x 1 root root   40 Apr 20 22:07 lib64/
> drwxr-xr-x 1 root root    0 Apr 20 22:07 media/
> drwxr-xr-x 1 root root   10 Jul 19 11:46 mnt/
> drwxr-xr-x 1 root root   28 Jun 24 13:59 opt/
> drwxr-xr-x 1 root root    0 Apr 12 20:14 proc/
> drwx------ 1 root root  434 Jul 19 19:24 root/
> drwxr-xr-x 1 root root  252 Apr 20 22:17 run/
> drwxr-xr-x 1 root root 4288 Jul 19 19:27 sbin/
> drwxr-xr-x 1 root root    0 Jul 19 20:19 snapshots/
> drwxr-xr-x 1 root root    0 Apr 20 22:07 srv/
> ...
> 
> That's the root i need.
> 
> root at ubuntu:~# btrfs sub list /mnt/root/
> ID 257 gen 39220 top level 5 path @
> ID 258 gen 38903 top level 5 path @home
> ID 285 gen 39218 top level 257 path old/snapshots/root_190720162124
> ID 300 gen 39218 top level 257 path @
> Two subvolumes @ ? Can i delete ID 257 ?
> 
> root at ubuntu:~# mv /mnt/root/@/* /mnt/root/
> root at ubuntu:~# ll /mnt/root/
> insgesamt 16
> drwxr-xr-x 1 root root  252 Jul 26 18:12 ./
> drwxr-xr-x 1 root root   60 Jul 26 17:57 ../
> drwxr-xr-x 1 root root    0 Jul 26 18:12 @/
> drwxr-xr-x 1 root root 2558 Jul 19 11:48 bin/
> drwxrwxr-x 1 root root    0 Jun  8 15:19 boot/
> drwxrwxr-x 1 root root    0 Jun  8 15:25 cdrom/
> drwxr-xr-x 1 root root  894 Apr 20 22:15 dev/
> drwxr-xr-x 1 root root 4636 Jul 19 19:28 etc/
> drwxrwxr-x 1 root root    0 Jun  8 15:19 home/
> lrwxrwxrwx 1 root root   32 Jul 15 11:26 initrd.img ->
> boot/initrd.img-4.4.0-31-generic
> lrwxrwxrwx 1 root root   32 Jun 28 01:18 initrd.img.old ->
> boot/initrd.img-4.4.0-28-generic
> drwxr-xr-x 1 root root  464 Jul 19 19:27 lib/
> drwxr-xr-x 1 root root   40 Apr 20 22:07 lib64/
> drwxr-xr-x 1 root root    0 Apr 20 22:07 media/
> drwxr-xr-x 1 root root   10 Jul 19 11:46 mnt/
> ...
> 
> That looks good.
> 
> root at ubuntu:~# rm -rfv /mnt/root/@
> rm: das Entfernen von '/mnt/root/@' ist nicht möglich: Vorgang nicht zulässig
> 
> Live cd is Ubuntu 16.04 desktop and i choose german. Message means "operation
> not permitted".
> Because a subvolume is mounted there ? I will leave @
> 
> I will reboot now again and keep you informed.
> 

I booted into the desired system which is fine. The system itself is not running fine, but that's someting else.

But how can i have tow "@"-subvolumes ?

root at PC65472:~# btrfs sub list /
ID 257 gen 39247 top level 5 path @
ID 258 gen 38903 top level 5 path @home
ID 285 gen 39218 top level 257 path old/snapshots/root_190720162124
ID 300 gen 39222 top level 257 path @

Btw: is there a way to create e.g. a subvolume for /var/log/ AFTER a successfull installation ?

Bernd
 

Helmholtz Zentrum Muenchen
Deutsches Forschungszentrum fuer Gesundheit und Umwelt (GmbH)
Ingolstaedter Landstr. 1
85764 Neuherberg
www.helmholtz-muenchen.de
Aufsichtsratsvorsitzende: MinDir'in Baerbel Brumme-Bothe
Geschaeftsfuehrer: Prof. Dr. Guenther Wess, Dr. Alfons Enhsen, Renate Schlusen (komm.)
Registergericht: Amtsgericht Muenchen HRB 6466
USt-IdNr: DE 129521671





More information about the ubuntu-users mailing list