From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB708C433DB for ; Sat, 9 Jan 2021 16:02:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A193A239E4 for ; Sat, 9 Jan 2021 16:02:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726195AbhAIQCI convert rfc822-to-8bit (ORCPT ); Sat, 9 Jan 2021 11:02:08 -0500 Received: from mail.eclipso.de ([217.69.254.104]:34702 "EHLO mail.eclipso.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726005AbhAIQCI (ORCPT ); Sat, 9 Jan 2021 11:02:08 -0500 Received: from mail.eclipso.de (www1.eclipso.de [217.69.254.102]) by mail.eclipso.de with ESMTP id 7EE0E760 for ; Sat, 09 Jan 2021 17:01:25 +0100 (CET) Date: Sat, 09 Jan 2021 17:01:25 +0100 MIME-Version: 1.0 Message-ID: <55cef4872380243c9422595700686b79@mail.eclipso.de> X-Mailer: eclipso / 7.4.0 From: " " Subject: cloning a btrfs drive with send and receive: clone is bigger than the original? Reply-To: " " To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org ­I've got a drive with data, and 3 snapshots of that data. I've transferred all the snapshots to another drive using btrfs send and receive. The send drive has 3.62 GB of data, the receive drive has 4.99 GB of data. It seems like the snapshots don't share data between them that was unchanged. How can I transfer the snapshots in such a way that the snapshots only occupy the difference between the snapshots? The data on the original drive is organized like this: /mnt/send/storage/ <= here's all the data /mnt/send/storage_snapshots/ <= here are the 3 snapshots The data on the receiving drive is organized like this: /mnt/rec/storage/ <= this folder is empty /mnt/rec/storage_snapshots/ <= here are the 3 snapshots /mnt/rec/btrfs_receive/ <= here are the 3 files generated by btrfs send How can I transfer the snapshots in such a way that /mnt/rec/storage/ holds the latest version of the data, just like on the original drive? In detail: # mkfs.btrfs -L SEND /dev/sda3 # mount /dev/sda3 /mnt/send/ -o,compress,noatime # mkfs.btrfs /dev/sdd2 -L DATA # mount /dev/sdd2 ./mnt/rec/ -o,compress,noatime # btrfs subvolume create /mnt/rec/btrfs_receive/ Create subvolume '/mnt/rec/btrfs_receive' # btrfs subvolume create /mnt/rec/storage_snapshots # btrfs subvolume create /mnt/send/storage # btrfs subvolume create /mnt/send/storage_snapshots # cd /mnt/send/storage # /home/cedric/mkfiles_and_md5.sh <> # btrfs subvolume snapshot -r /mnt/send/storage /mnt/send/storage_snapshots/storage-$(date +%Y_%m_%d-%H%m) Create a readonly snapshot of '/mnt/send/storage' in '/mnt/send/storage_snapshots/storage-2021_01_09-1301' # /home/cedric/mkfiles_and_md5.sh <> btrfs subvolume snapshot -r /mnt/send/storage /mnt/send/storage_snapshots/storage-$(date +%Y_%m_%d-%H%m%S) Create a readonly snapshot of '/mnt/send/storage' in '/mnt/send/storage_snapshots/storage-2021_01_09-130120' # /home/cedric/mkfiles_and_md5.sh <> # btrfs subvolume snapshot -r /mnt/send/storage /mnt/send/storage_snapshots/storage-$(date +%Y_%m_%d-%H%m%S) Create a readonly snapshot of '/mnt/send/storage' in '/mnt/send/storage_snapshots/storage-2021_01_09-130146' # btrfs send /mnt/send/storage_snapshots/storage-2021_01_09-1301 -f /mnt/rec/btrfs_receive/storage-2021_01_09-1301.btrfssend At subvol /mnt/send/storage_snapshots/storage-2021_01_09-1301 [root@bcache-test rec]# btrfs send -p /mnt/send/storage_snapshots/storage-2021_01_09-1301 /mnt/send/storage_snapshots/storage-2021_01_09-130120 -f /mnt/rec/btrfs_receive/storage-2021_01_09-130120.btrfssend At subvol /mnt/send/storage_snapshots/storage-2021_01_09-130120 [root@bcache-test rec]# btrfs send -p /mnt/send/storage_snapshots/storage-2021_01_09-130120 /mnt/send/storage_snapshots/storage-2021_01_09-130146 -f /mnt/rec/btrfs_receive/storage-2021_01_09-130146.btrfssend At subvol /mnt/send/storage_snapshots/storage-2021_01_09-130146 # btrfs receive -f /mnt/rec/btrfs_receive/storage-2021_01_09-1301.btrfssend /mnt/rec/storage_snapshots At subvol storage-2021_01_09-1301 # btrfs receive -f /mnt/rec/btrfs_receive/storage-2021_01_09-130120.btrfssend /mnt/rec/storage_snapshots At snapshot storage-2021_01_09-130120 # btrfs receive -f /mnt/rec/btrfs_receive/storage-2021_01_09-130146.btrfssend /mnt/rec/storage_snapshots At snapshot storage-2021_01_09-130146 # rm /mnt/rec/btrfs_receive/storage-2021_01_09-1301* # btrfs filesystem show Label: 'SEND' uuid: 61b7e45f-62a7-4b04-bc0c-ba1304548b02 Total devices 1 FS bytes used 3.62GiB devid 1 size 5.00GiB used 4.52GiB path /dev/sda3 Label: 'DATA' uuid: 95e85fa4-217c-429a-be55-833bb63e2c71 Total devices 1 FS bytes used 4.99GiB devid 1 size 931.01GiB used 10.02GiB path /dev/sdd2 --- Take your mailboxes with you. Free, fast and secure Mail & Cloud: https://www.eclipso.eu - Time to change!