ext4-realloc-inodes/mkimage.sh

28 lines
792 B
Bash

#!/bin/sh
FILE=${FILE:-test-ext4-grow1.img}
FS=${FS:-ext4}
SIZE=${SIZE:-32768}
OPTS=${OPTS:--b 1024 -g 2048 -N 2048}
dd if=/dev/zero of=$FILE bs=1k seek=$((SIZE-1)) count=1
/sbin/mkfs.$FS -F -m 0 $OPTS $FILE
mkdir -p dir
mount -o loop $FILE dir
# For block moving test: create a sparse file with many extents
dd if=/dev/urandom of=dir/f_random bs=1k count=1
for i in $(seq 1 2500); do
dd if=dir/f_random of=dir/f_sparse bs=1k count=1 seek=$((2400-i*2)) conv=notrunc 2>/dev/null
done
# For inode moving test: create 1201 1kb sized files
dd if=/dev/zero of=dir/f_zero bs=1k count=1
for i in $(seq 0 120); do
mkdir dir/dir$i
done
for i in $(seq 1 1200); do
cp dir/f_zero dir/dir$((i/10))/f$i
setfattr -n user.property -v helloworld dir/dir$((i/10))/f$i
done
sleep 1
umount dir