Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Basic balance scripts
#!/bin/bash
dev=/dev/test/test
mnt=/mnt/btrfs
_fail()
{
echo "!!! FAILED: $@ !!!"
exit 1
}
dmesg -C
umount $mnt &> /dev/null
umount $dev &> /dev/null
mkfs.btrfs -f $dev -n 4k -m single
mount $dev $mnt -o nospace_cache,max_inline=2048
btrfs sub create $mnt/subv
cp -r /lib $mnt/subv
cp -r /usr $mnt/subv
#for i in $(seq -w 1 8); do
# fallocate -l 4k $mnt/subv/regular_$i
# xfs_io -f -c "pwrite 0 2K" $mnt/subv/inline1_$i > /dev/null
# xfs_io -f -c "pwrite 0 2K" $mnt/subv/inline2_$i > /dev/null
# xfs_io -f -c "pwrite 0 2K" $mnt/subv/inline3_$i > /dev/null
# xfs_io -f -c "pwrite 0 2K" $mnt/subv/inline4_$i > /dev/null
# xfs_io -f -c "pwrite 0 2K" $mnt/subv/inline5_$i > /dev/null
# xfs_io -f -c "pwrite 0 2K" $mnt/subv/inline6_$i > /dev/null
# xfs_io -f -c "pwrite 0 2K" $mnt/subv/inline7_$i > /dev/null
# xfs_io -f -c "pwrite 0 2K" $mnt/subv/inline8_$i > /dev/null
#done
random_touch()
{
basedir=$1
random_file="$(ls $basedir | sort -R | tail -1)"
touch "$basedir/$random_file"
}
for i in $(seq -w 1 16); do
btrfs subvolume snapshot $mnt/subv $mnt/snapshot_$i
random_touch "$mnt/snapshot_$i/usr/lib"
random_touch "$mnt/snapshot_$i/usr/include"
random_touch "$mnt/snapshot_$i/usr/bin"
done
sync
#btrfs quota enable $mnt
#btrfs quota rescan -w $mnt
time btrfs balance start -m $mnt
umount $mnt
btrfs check $dev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.