All of lore.kernel.org
 help / color / mirror / Atom feed
From: Carsten Behling <carsten.behling@googlemail.com>
To: linux-btrfs@vger.kernel.org, Qu Wenruo <quwenruo.btrfs@gmx.com>
Subject: Fwd: How do damaged root trees happen and how to protect against power cut?
Date: Tue, 24 Mar 2020 08:54:18 +0100	[thread overview]
Message-ID: <CAPuGWB_D-waGWv4YNsF9N0dbnA+2ztJvMjmxs9PK5qG_PUFU7Q@mail.gmail.com> (raw)
In-Reply-To: <CAPuGWB-XyYya263K2gWriv5sGVLQbbzpKD3R01GkxiwNw-LdTA@mail.gmail.com>

---------- Forwarded message ---------
Von: Carsten Behling <carsten.behling@googlemail.com>
Date: Di., 24. März 2020 um 08:51 Uhr
Subject: Re: How do damaged root trees happen and how to protect
against power cut?
To: Chris Murphy <lists@colorremedies.com>


Carsten Behling <carsten.behling@googlemail.com>

Mo., 23. März, 16:58 (vor 15 Stunden)
an Chris
> Seed device?
>
> Create a Btrfs file system, use space_cache v2,
> compress-force=zstd:16, and write the root image. Resize the file
> system to minimum. Set the seed flag. That's the base image. Part of
> the provisioning will be to 'btrfs device add' a 2nd partition, and
> remount read-write. This means two Btrfs file systems exist, each with
> their own UUID. You can reference the read-only seed by its UUID; and
> you can reference the read-write volume by its own UUID. On-disk
> metadata for this read-write volume points to both the read-only seed
> devid1, and the writable 2nd device devid2.
>
> Make sure write cache on the physical media is disabled.

Are this the correct steps in detail:

1. Partition SD card with:
- (write Bootloader ...)
- first partition boot (FAT32 (0x0b), 50MB)
- second partition (Linux Native (0x83), minimum possible size to fit rootfs)
- third partition (Linux Native (0x83), rest
- (write boot files (kernel ...))

2. Create seed device on development host:

# mkfs.btrfs --rootdir ~/rootfs --shrink /dev/sda2 # sda is my SD card device
# btrfstune -S 1 /dev/sda2
# dd if=/dev/zero of=/dev/sda3 bs=1024
# mount /dev/sda2 /mnt
# btrfs device add /dev/sda3 /mnt
# hdparm -W 0 /dev/sda3 # disable write cache

3. Mount on embedded device

- Kernel command line option: "root=/dev/mmcblk0p2 ro rootwait"
- Later, 'systemd-remount-fs.service' remounts seed device 'rw' by
appliying mmount options from fstab:
...
# 'defaults' includes 'rw', 'ROOT' is /dev/mmcblk0p2 (seed device)
LABEL=ROOT       /                    btrfs
defaults,noatime,nodiratime,space_cache=v2,compress-force=zstd:16
 1  1
...

Is this correct?

Regards
Carsten

  parent reply	other threads:[~2020-03-24  7:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-19 15:14 How do damaged root trees happen and how to protect against power cut? Carsten Behling
2020-03-19 19:45 ` Chris Murphy
     [not found]   ` <CAPuGWB-XyYya263K2gWriv5sGVLQbbzpKD3R01GkxiwNw-LdTA@mail.gmail.com>
2020-03-24  7:54     ` Carsten Behling [this message]
2020-03-30 22:43       ` Chris Murphy
2020-03-20  0:46 ` Qu Wenruo

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=CAPuGWB_D-waGWv4YNsF9N0dbnA+2ztJvMjmxs9PK5qG_PUFU7Q@mail.gmail.com \
    --to=carsten.behling@googlemail.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=quwenruo.btrfs@gmx.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.