I have mounted an ext4 file system on Dir directory and tweaked some code of directory read which requires having files in the directory inodes with non-sequential inode numbers for its testing. As I am creating files with the shell script, which allocates inodes to the files with sequential inode numbers. Because for the files being created at the same time, inodes are allocated sequentially from the inode freelist, which generally have inode numbers sequentially. I have used following shell script to create files in Dir,
#! /bin/bash
for n in {1..1000}; do
dd if=/dev/urandom of=file$( printf %03d "$n" ).bin bs=1 count=$(( RANDOM + 1024 ))
done
ls -i Dir gives following o/p
567 file001.bin
568 file002.bin
569 file002.bin
570 file004.bin
571 file005.bin
572 file006.bin
573 file007.bin
574 file008.bin
575 file009.bin
576 file010.bin
..
How can I make these files have nonsequential inodes?