Skip to content

Instantly share code, notes, and snippets.

@tataranovich
Created October 18, 2020 12:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tataranovich/92cfc7573caceed292898a847d0a85ce to your computer and use it in GitHub Desktop.
Save tataranovich/92cfc7573caceed292898a847d0a85ce to your computer and use it in GitHub Desktop.
Mount bcache for pbuilder/build
#!/bin/bash
set -e
function wait_for_file() {
for i in $(seq 1 15)
do
test -e "$1" && break
sleep 1
done
test -e "$1"
return $?
}
wait_for_file /var/cache/pbuilder/build-loop.img
wipefs -a /var/cache/pbuilder/build-loop.img
losetup /dev/loop0 /var/cache/pbuilder/build-loop.img
modprobe brd rd_nr=1 rd_size=524288
wait_for_file /dev/ram0
make-bcache -B /dev/loop0 -C /dev/ram0
wait_for_file /sys/fs/bcache/register
echo /dev/ram0 > /sys/fs/bcache/register
wait_for_file /sys/block/bcache0/bcache/cache_mode
echo writeback > /sys/block/bcache0/bcache/cache_mode
wait_for_file /dev/bcache0
wipefs -a /dev/bcache0
mkfs -t ext2 /dev/bcache0
mount -t ext2 /dev/bcache0 /var/cache/pbuilder/build -o noatime
echo DONE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment