e2fsprogs library

I need Ext4 partition that filled with inodes and block with given pattern. Let’s use e2fsprogs to modificative (create?) ext4 partition.

Library code exists in lib/ext2fs directory. There are some using examples here.

lib/ext2fs/tst_iscan.c – is good example, how FS structures are created and used in memory, without writing to file.

The best library using example is mke2fs (misc/mke2fs.c). This general steps required to prepare FS image:

  • ext2fs_initialize
  • set_options
  • write_inode_tables
  • create_root_dir;       
  • create_lost_and_found
  • reserve_inodes
  • create_bad_block_inode
  • create journal node
  • create quota nodes
  • mk_hugefile
  • ext2fs_close_free

Some steps are mandatory.

Leave a Reply

Your email address will not be published. Required fields are marked *