ext4-realloc-inodes/mkimage.sh

25 lines
750 B
Bash

#!/bin/sh
# To test shrinking: INODES=8192, then ./realloc-inodes test-clean.img 2048
# To test growing: INODES=2048, then ./realloc-inodes test-clean.img 8192
INODES=2048
FILE=test-ext4-grow.img
FS=ext4
dd if=/dev/zero of=$FILE bs=1k seek=32767 count=1
/sbin/mkfs.$FS -F -b 1024 -m 0 -g 2048 -N $INODES $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 {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 {1..1200}; do
cp dir/f_zero dir/f$i
done
umount dir