---------- Forwarded message --------- Von: Carsten Behling <carsten.behling@xxxxxxxxxxxxxx> 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@xxxxxxxxxxxxxxxxx> Carsten Behling <carsten.behling@xxxxxxxxxxxxxx> 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
