Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Arand Nash <ienorand@gmail.com>
To: linux-btrfs@vger.kernel.org
Subject: Re: Snapshot rollback
Date: Tue, 25 Oct 2011 04:04:43 +0200	[thread overview]
Message-ID: <4EA6193B.30104@gmail.com> (raw)
In-Reply-To: <4EA60690.7080401@cfl.rr.com>

On 25/10/11 02:45, Phillip Susi wrote:
 > (...)
>
> On 10/24/2011 01:45 AM, dima wrote:
>> Hello Phillip,
>> It is hard to judge without seeing your fstab and bootloader config. Maybe your
>> / was directly in subvolid=0 without creating a separate subvolume for it (like
>> __active in Goffredo's reply)? In my very humble opinion, if you have your @home
>> subvolume under subvolid=0 and then change the default subvolume, it just cannot
>> access your @home any more.
>
> Why can't it?
>
> It appears that Ubuntu sets up two subvols, one named @ and one named
> @home, and mounts them at / and /home respectively.  The boot loader was
> set to pass rootflags=subvol=@.  After changing the default volume, the
> system would not boot until I removed that rootflags argument, then it
> mounted the snapshot correctly as the root, but refused to mount /home,
> giving this nonsense error that /dev/sda1 is not a valid block device.
 >
 > (...)

Btrfs is unfortunately unable to look for snapshots by name above the 
currently set default root (I do not know why exectly), it can however 
find them by id anywhere.

In the case of (Debian?) Ubuntu, you should pretty much stay away from 
set-default.

What happens is Ubuntu mounts the _default_ subvolume, which in the 
normal case refers to the top of the btrfs tree (alias subvolid=5), then 
it looks below this for the subvolumes ("directories") named "@/" (given 
by the boot option) and "@home/" (given in fstab).

Now, when you use set-default here, it will instead mount that subvolume 
as the default, and then look _below_ that for "@/" and "@home/", 
obviously, this won't work, since these exist higher up in the tree.

When you disable the rootflags argument, btrfs assumes the default 
subvolume is the root, which works, as noted.

In order to find "@home/", you could rewrite the fstab to instead of 
"subvol=@home" read "subvolid=###", since by specifying id instead of 
name, it can find it anywhere in the tree, the subvolid can be found via
~# btrfs subvolume list /


HOWEVER, this is not the way btrfs is intended to be used on Ubuntu.
As mentioned earlier, you likely will not want to touch set-default, 
instead, when you want to muck around with your mounting sobvolumes, you 
just use mv:

To backup
~# mount /dev/sda1 /mnt
~# ls /mnt
@ @home
~@ btrfs sub snap /mnt/@ /mnt/@rootsnap
~# ls /mnt
@ @home @rootsnap

And to rollback:
~# mv /mnt/@ /mnt/@rootmessy
~# mv /mnt/@rootsnap /mnt/@
And just reboot, since it just mounts whatever is named "@/".


Now in your case, if you want to go back to the Ubuntu default btrfs 
setup, you would:
~# btrfs subvolume set-default 5 /
(since id 5 is always the top of the tree)
And reinstate the rootflags boot option.


Hope that explains some of it.

--
Martin Werner ("arand")

  reply	other threads:[~2011-10-25  2:04 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-23 19:42 Snapshot rollback Phillip Susi
2011-10-23 20:35 ` Goffredo Baroncelli
2011-10-24  5:45 ` dima
2011-10-24  5:58   ` Fajar A. Nugraha
2011-10-24  8:24     ` dima
2011-10-24 12:11       ` Fajar A. Nugraha
2011-10-25  2:00         ` dima
2011-10-25  8:01           ` Fajar A. Nugraha
2011-10-25  8:54             ` dima
2011-10-25  9:01               ` Fajar A. Nugraha
2011-10-25  0:45   ` Phillip Susi
2011-10-25  2:04     ` Arand Nash [this message]
2011-10-26  1:30       ` Phillip Susi
  -- strict thread matches above, loose matches on Subject: below --
2019-07-05 10:38 snapshot rollback Ulli Horlacher
2019-07-05 11:06 ` Ulli Horlacher
2019-07-05 11:47   ` Remi Gauvin
2019-07-05 13:03     ` Graham Cobb
2019-07-05 21:18 ` Chris Murphy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4EA6193B.30104@gmail.com \
    --to=ienorand@gmail.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox