make-btrfs-fs: start with 4G and auto-shrink
This commit is contained in:
parent
361c658230
commit
c2f8b5d71f
@ -58,13 +58,9 @@ pkgs.stdenv.mkDerivation {
|
||||
# Make a crude approximation of the size of the target image.
|
||||
# If the script starts failing, increase the fudge factors here.
|
||||
numInodes=$(find ./rootImage | wc -l)
|
||||
numDataBlocks=$(du -s -c -B 4096 --apparent-size ./rootImage | tail -1 | awk '{ print int($1 * 1.10) }')
|
||||
bytes=$((2 * 4096 * $numInodes + 4096 * $numDataBlocks))
|
||||
echo "Creating a btrfs image of $bytes bytes (numInodes=$numInodes, numDataBlocks=$numDataBlocks)"
|
||||
|
||||
truncate -s $bytes $img
|
||||
|
||||
faketime -f "1970-01-01 00:00:01" fakeroot mkfs.btrfs -L ${volumeLabel} -U ${uuid} -r ./rootImage $img
|
||||
truncate -s 4G $img
|
||||
faketime -f "1970-01-01 00:00:01" fakeroot mkfs.btrfs --shrink -L ${volumeLabel} -U ${uuid} -r ./rootImage $img
|
||||
|
||||
if [ ${builtins.toString compressImage} ]; then
|
||||
echo "Compressing image"
|
||||
|
Loading…
x
Reference in New Issue
Block a user