public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* Using send/receive to keep two rootfs-partitions in sync fails with "ERROR: snapshot: cannot find parent subvolume"
@ 2024-01-07  7:06 Clemens Eisserer
  2024-01-07  7:19 ` Andrei Borzenkov
  2024-01-07 12:37 ` Hugo Mills
  0 siblings, 2 replies; 13+ messages in thread
From: Clemens Eisserer @ 2024-01-07  7:06 UTC (permalink / raw)
  To: linux-btrfs

Hi,

I would like to use send/receive to keep two root-filesystems in sync,
as I've been using it for years now for backups where it really does
wonders (thanks a lot!).

Both disks contain a read-only snapshot which is kept in-sync between
the filesystems (int and ext are the mountpoints of the two disks,
original_disk is just used for initial data):
   btrfs send original_disk/root-ro | btrfs receive int/ #send
snapshot of the original disk to the first of the two filesystens
(disk "int")
   btrfs send int/root-ro | btrfs receive ext/ #now replicate the same
to disk "ext"
so both disks start with a snapshot "root-ro" with equal content.

in case I would like to work with one of the two disks, I create a rw
snapshot based no root-ro:
  btrfs sub snap ext/root-ro ext/root-rw

  touch ext/root-wr/create-a-new-file # perform some modifications

once modifications in root-rw are done, the following steps are
performed to sync the filesystems:
  btrfs sub snap -r ext/root-rw ext/root-ro-new #create a root-ro-new
read-only snapshot based on the rw-snapshot with modfications (so it
can be used with btrfs send)
  btrfs send -p ext/root-ro extern/root-ro-new | btrfs receive int/
#send root-ro-new to "int" filesystem
  btrfs sub del ext/root-ro # delete the original root-ro snapshot, as
it is no longer needed for differential btrfs send
  mv ext/root-ro-new ext/root-ro #rename root-ro-new to root-ro, as
this is the current state of the other (int) filesystem
  btrfs sub del int/root-ro # delete root-ro in "int" too, as it is no
longer needed for differential btrfs receive
  mv int/root-ro-new int/root-ro #rename root-ro-new to root-ro
  btrfs sub snap int/root-ro int/root-rw # create a working copy of
root-ro which is writeable

this works great - i can add/modify files in one root-rw folder, call
the synchronization script and everything is found on the other
filesystem.
When exchanging int and ext in the script above it actually works in
both directions, so this is exactly what I was hoping to achieve.
Even when executing the script multiple times int->ext, ext->int,
int->ext ... with modifications in between, everything works as
expected.
Awesome :)

However, when actually using the file-systems as rootfs, this seem to
break when performing the following steps:
- create rw snapshot of root-ro on disk "ext": btrfs sub snap
ext/root-ro ext/root-rw
- boot the system with rootfs=ext-uuid and rootflags=subvol=/root-rw
(etc/fstab was adapted accordingly)
- use the system, modify file system etc and shutdown again
- start separate system to synchronize disks (not based on int or ext
rootfs) and call sync script ext->int (shown above)

it now suddenly fails at btrfs receive with:
btrfs send -p ext/root-ro ext/root-ro-new | btrfs receive intern/
ERROR: snapshot: cannot find parent subvolume
4ed11491-7563-fb49-99e7-86cb47cfb510

which I, to be honest, don't understand.
Exactly the same sequence of commands worked multiple times when the
root-rw snapshot was not booted from but modified directly on the sync
system, even with umounts between modification & send/receive.
Does it make a difference for btrfs if it is used as rootfs vs normal
writeable mount?
Or does it just work in the non-boot case because of some side-effects?

Thanks & best regards, Clemens

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2024-01-13  8:42 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-07  7:06 Using send/receive to keep two rootfs-partitions in sync fails with "ERROR: snapshot: cannot find parent subvolume" Clemens Eisserer
2024-01-07  7:19 ` Andrei Borzenkov
2024-01-07  8:10   ` Clemens Eisserer
2024-01-07  8:21     ` Andrei Borzenkov
2024-01-07  8:29       ` Clemens Eisserer
2024-01-07 11:42         ` Clemens Eisserer
2024-01-08  8:21     ` Andrei Borzenkov
2024-01-08 19:36       ` Clemens Eisserer
2024-01-11 18:41         ` Andrei Borzenkov
2024-01-12  8:44           ` Clemens Eisserer
2024-01-13  8:42             ` Andrei Borzenkov
2024-01-07 12:37 ` Hugo Mills
2024-01-07 20:29   ` Clemens Eisserer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox