#!/bin/sh set -x DATA=/usr/bin # use whole /usr on non-bloated VMs mkdir -p /mnt/vol1 umount /mnt/vol1; losetup -D # clean up after repeats dd if=/dev/zero bs=1048576 count=1 seek=4095 of=ra dd if=/dev/zero bs=1048576 count=1 seek=4095 of=rb dd if=/dev/zero bs=1048576 count=1 seek=4095 of=rc dd if=/dev/zero bs=1048576 count=1 seek=4095 of=rd mkfs.btrfs -draid10 -mraid1 ra rb rc rd losetup -D losetup -f ra losetup -f rb losetup -f rc losetup -f rd sleep 2 # race with fsid detection mount -onoatime /dev/loop0 /mnt/vol1 || exit $? cp -pr "$DATA" /mnt/vol1 btrfs fi sync /mnt/vol1 btrfs fi us /mnt/vol1 btrfs balance start -dconvert=raid5 -mconvert=raid6 /mnt/vol1 btrfs scrub start -B /mnt/vol1 btrfs scrub start -B /mnt/vol1 umount /mnt/vol1 dd if=/dev/urandom of=rd bs=1048576 seek=96 count=4000 mount -onoatime /dev/loop0 /mnt/vol1 || exit $? btrfs scrub start -B /mnt/vol1 btrfs scrub start -B /mnt/vol1 btrfs balance start -dconvert=raid10 -mconvert=raid1 /mnt/vol1 btrfs scrub start -B /mnt/vol1 btrfs scrub start -B /mnt/vol1 umount /mnt/vol1 dd if=/dev/urandom of=rd bs=1048576 seek=96 count=4000 mount -onoatime /dev/loop0 /mnt/vol1 || exit $? btrfs scrub start -B /mnt/vol1 btrfs scrub start -B /mnt/vol1 diff -urd --no-dereference "$DATA" /mnt/vol1/* umount /mnt/vol1