Rate this page del.icio.us  Digg slashdot StumbleUpon

How can I change the default size of an inode when I create an ext2/ext3 filesystem?

by The editorial team

Contributed by Eugene Teo

It is possible to define a non-standard sized inode by using the mke2fs tool with an undocumented option, -I. The size of the inode has to be a power of two and between the size of EXT2_GOOD_OLD_INODE_SIZE (128 bytes) and size of blocks in bytes. One reason for doing this could be that user is going to use extended attributes. Extended attributes are arbitrary name/value pairs used to store system objects like Access Control Lists (ACL). If the size of the inodes is larger than the default size, then sufficiently small attributes can be stored in inode. However, use this option with caution because of compatibility issues. It may render the filesystem unusable on most systems. Use the command man 8 mke2fs for more details.

Below is a part of the source file of mke2fs. The source files can be downloaded from http://e2fsprogs.sourceforge.net/. As this is an undocumented feature, the code below shows what the -I option do.
The source file can be found under the directory e2fsprogs-1.39/misc/mke2fs.c

        while ((c = getopt (argc, argv,
                    "b:cf:g:i:jl:m:no:qr:s:tvE:FI:J:L:M:N:O:R:ST:V")) != EOF) {
                switch (c) {
        ...
                case 'I':
                        inode_size = strtoul(optarg, &tmp, 0);
        ...
        if (inode_size) {
                if (inode_size  EXT2_BLOCK_SIZE(&fs_param) ||
                    inode_size & (inode_size - 1)) {
                        com_err(program_name, 0,
                                _("invalid inode size %d (min %d/max %d)"),
                                inode_size, EXT2_GOOD_OLD_INODE_SIZE,
                                blocksize);
                        exit(1);
                }
                if (inode_size != EXT2_GOOD_OLD_INODE_SIZE)
                        fprintf(stderr, _("Warning: %d-byte inodes not usable "
                                "on most systems\n"),
                                inode_size);
                fs_param.s_inode_size = inode_size;
        }

Here are some examples how a user can specify the -I option:

# mke2fs -I 127 /dev/hda1
mke2fs 1.39 (29-May-2006)
mke2fs: invalid inode size 127 (min 128/max 4096)
# mke2fs -I 4097 /dev/hda1
mke2fs 1.39 (29-May-2006)
mke2fs: invalid inode size 4097 (min 128/max 4096)
# mke2fs -I 256 /dev/hda1
mke2fs 1.39 (29-May-2006)
Warning: 256-byte inodes not usable on most systems
...
# mke2fs -j -I 256 /dev/hda1
mke2fs 1.39 (29-May-2006)
Warning: 256-byte inodes not usable on most systems
...
Creating journal (8192 blocks): done

Red Hat’s customer service and support teams receive technical support questions from users all over the world. Red Hat technicians add the questions and answers to Red Hat Knowledgebase on a daily basis. Access to Red Hat Knowledgebase is free. Every month, Red Hat Magazine offers a preview into the Red Hat Knowledgebase by highlighting some of the most recent entries.

3 responses to “How can I change the default size of an inode when I create an ext2/ext3 filesystem?”

  1. Abhishek says:

    This command has to be given in the terminal window. Whether we can have any solution in the GUI interface too.

    Let me know at the earliest

    Thanks & Regards

    Abhishek

  2. Jef says:

    “This command has to be given in the terminal window. Whether we can have any solution in the GUI interface too.”

    No.

    “Let me know at the earliest”

    It is not courteous to express urgency when seeking volunteer help.

  3. Dawid Zamirski says:

    “One reason for doing this could be that user is going to use extended attributes. Extended attributes are arbitrary name/value pairs used to store system objects like Access Control Lists (ACL)”

    Please clarify. Does it mean that in order to use ACL the inode size must be greater than default? I recall that newer versions of GNOME have support for ACL in GUI and to enable it, it is sufficient to add acl option in fstab.

Leave a reply