Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: " " <Cedric.dewijs@eclipso.eu>
To: <Cedric.dewijs@eclipso.eu>
Cc: <arvidjaar@gmail.com>, <linux-btrfs@vger.kernel.org>
Subject: Re: Re: Re: cloning a btrfs drive with send and receive: clone is bigger than  the original?
Date: Sun, 10 Jan 2021 08:41:00 +0100	[thread overview]
Message-ID: <067af02fb023de04276f14aa6f26ae8e@mail.eclipso.de> (raw)
In-Reply-To: <b709a56556c3adfc9ff352f2a51db3a3@mail.eclipso.de>

I've tested some more.

Repeatedly sending the difference between two consecutive snapshots creates a structure on the target drive where all the snapshots share data. So 10 snapshots of 10 files of 100MB takes up 1GB, as expected.

Repeatedly sending the difference between the first snapshot and each next snapshot creates a structure on the target drive where the snapshots are independent, so they don't share any data. How can that be avoided?

Script (version that sends the difference between the first snapshot and each current snapshot):
# cat ~/btrfs-send-test.sh 
#!/bin/bash

btrfs subvolume delete /mnt/send/storage
btrfs subvolume delete /mnt/send/snapshots/*
btrfs subvolume delete /mnt/send/snapshots/
btrfs subvolume delete /mnt/rec/diff
btrfs subvolume delete /mnt/rec/snapshots/*
btrfs subvolume delete /mnt/rec/snapshots/
sync
btrfs subvolume create /mnt/send/storage
btrfs subvolume create /mnt/send/snapshots/
btrfs subvolume create /mnt/rec/diff
btrfs subvolume create /mnt/rec/snapshots

btrfs subvolume snapshot -r /mnt/send/storage/ /mnt/send/snapshots/0
btrfs send /mnt/send/snapshots/0 | btrfs receive /mnt/rec/snapshots

onelesscounter=0
counter=1
while [ $counter -le 10 ]
do
	dd if=/dev/urandom of=/mnt/send/storage/file$( printf %03d "$counter" ).bin bs=1M count=100
	md5sum /mnt/send/storage/file$( printf %03d "$counter" ).bin >> /mnt/send/storage/md5sums.txt
	btrfs subvolume snapshot -r /mnt/send/storage /mnt/send/snapshots/$counter
	btrfs send -p /mnt/send/snapshots/0 /mnt/send/snapshots/$counter -f /mnt/rec/diff/$counter
	#btrfs send -p /mnt/send/snapshots/$onelesscounter /mnt/send/snapshots/$counter -f /mnt/rec/diff/$counter 
	btrfs receive -f /mnt/rec/diff/$counter /mnt/rec/snapshots
	((counter++))
	((onelesscounter++))
done
echo All done

# df -h
/dev/sda3       5.0G 1007M  3.6G  22% /mnt/send
/dev/sdd2       932G   11G  919G   2% /mnt/rec

# ls -lh /mtn/rec/diff
total 5.4G
-rw------- 1 root root  101M Jan 10 09:17 1
-rw------- 1 root root 1001M Jan 10 09:19 10
-rw------- 1 root root  201M Jan 10 09:17 2
-rw------- 1 root root  301M Jan 10 09:17 3
-rw------- 1 root root  401M Jan 10 09:17 4
-rw------- 1 root root  501M Jan 10 09:17 5
-rw------- 1 root root  601M Jan 10 09:18 6
-rw------- 1 root root  701M Jan 10 09:18 7
-rw------- 1 root root  801M Jan 10 09:18 8
-rw------- 1 root root  901M Jan 10 09:18 9

#rm /mtn/rec/diff/*
#sync

# df -h
/dev/sda3       5.0G 1007M  3.6G  22% /mnt/send
/dev/sdd2       932G  5.4G  924G   1% /mnt/rec  <= all data is individually stored in the snapshots?



---

Take your mailboxes with you. Free, fast and secure Mail &amp; Cloud: https://www.eclipso.eu - Time to change!



  reply	other threads:[~2021-01-10  7:41 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-09 16:01 cloning a btrfs drive with send and receive: clone is bigger than the original?  
2021-01-09 19:45 ` Andrei Borzenkov
2021-01-09 21:08   `  
2021-01-10  7:41     `   [this message]
2021-01-10  7:54       ` Andrei Borzenkov
2021-01-10 13:06       ` Re: " Graham Cobb
2021-01-10 13:21         ` Hugo Mills
2021-01-10 15:38           ` Andrei Borzenkov

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=067af02fb023de04276f14aa6f26ae8e@mail.eclipso.de \
    --to=cedric.dewijs@eclipso.eu \
    --cc=arvidjaar@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