How to use the new Ext4 Inline Data feature ? (storing data directly in the inode)

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
6
down vote

favorite












If I read the Ext4 documentation correctly, starting from Linux 3.8 it should be possible to store data directly in the inode in the vase of a very small file.



I was expecting such a file to have a size of 0 blocks, but it is not the case.



#creating a small file
printf "abcde" > small_file

#checking size of file in bytes
stat --printf='%sn' small_file
5

#number of blocks used by files
stat --printf='%bn' small_file
8


I would expect this last number here to be 0. Am I am missing something ?










share|improve this question



















  • 1




    It is probably a filesystem option that needs to be enabled during creation of the filesystem, to prevent problems if you would happen to mount the filesystem with an older kernel at some later time.
    – wurtel
    Apr 21 '15 at 14:53














up vote
6
down vote

favorite












If I read the Ext4 documentation correctly, starting from Linux 3.8 it should be possible to store data directly in the inode in the vase of a very small file.



I was expecting such a file to have a size of 0 blocks, but it is not the case.



#creating a small file
printf "abcde" > small_file

#checking size of file in bytes
stat --printf='%sn' small_file
5

#number of blocks used by files
stat --printf='%bn' small_file
8


I would expect this last number here to be 0. Am I am missing something ?










share|improve this question



















  • 1




    It is probably a filesystem option that needs to be enabled during creation of the filesystem, to prevent problems if you would happen to mount the filesystem with an older kernel at some later time.
    – wurtel
    Apr 21 '15 at 14:53












up vote
6
down vote

favorite









up vote
6
down vote

favorite











If I read the Ext4 documentation correctly, starting from Linux 3.8 it should be possible to store data directly in the inode in the vase of a very small file.



I was expecting such a file to have a size of 0 blocks, but it is not the case.



#creating a small file
printf "abcde" > small_file

#checking size of file in bytes
stat --printf='%sn' small_file
5

#number of blocks used by files
stat --printf='%bn' small_file
8


I would expect this last number here to be 0. Am I am missing something ?










share|improve this question















If I read the Ext4 documentation correctly, starting from Linux 3.8 it should be possible to store data directly in the inode in the vase of a very small file.



I was expecting such a file to have a size of 0 blocks, but it is not the case.



#creating a small file
printf "abcde" > small_file

#checking size of file in bytes
stat --printf='%sn' small_file
5

#number of blocks used by files
stat --printf='%bn' small_file
8


I would expect this last number here to be 0. Am I am missing something ?







linux ext4






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 22 '15 at 16:00









Stephen Kitt

151k23337405




151k23337405










asked Apr 21 '15 at 14:02









Manu

324110




324110







  • 1




    It is probably a filesystem option that needs to be enabled during creation of the filesystem, to prevent problems if you would happen to mount the filesystem with an older kernel at some later time.
    – wurtel
    Apr 21 '15 at 14:53












  • 1




    It is probably a filesystem option that needs to be enabled during creation of the filesystem, to prevent problems if you would happen to mount the filesystem with an older kernel at some later time.
    – wurtel
    Apr 21 '15 at 14:53







1




1




It is probably a filesystem option that needs to be enabled during creation of the filesystem, to prevent problems if you would happen to mount the filesystem with an older kernel at some later time.
– wurtel
Apr 21 '15 at 14:53




It is probably a filesystem option that needs to be enabled during creation of the filesystem, to prevent problems if you would happen to mount the filesystem with an older kernel at some later time.
– wurtel
Apr 21 '15 at 14:53










2 Answers
2






active

oldest

votes

















up vote
3
down vote



accepted










To enable inline data in ext4, you'll need to e2fsprogs 1.43 or later. Support for inline data was added in March 2014 to the git repository but was only released in May 2016.



Once you have that, you can run mke2fs -O inline_data on an appropriate device to create a new filesystem with inline data support; this will erase all your data. It's apparently not yet possible to activate inline data on an existing filesystem (at least, tune2fs doesn't support it).



Now create a small file, and run debugfs on the filesystem. cd to the appropriate directory, and run stat smallfile; you'll get something like



Inode: 32770 Type: regular Mode: 0644 Flags: 0x10000000
Generation: 2302340561 Version: 0x00000000:00000001
User: 1000 Group: 1000 Size: 6
File ACL: 0 Directory ACL: 0
Links: 1 Blockcount: 0
Fragment: Address: 0 Number: 0 Size: 0
ctime: 0x553731e9:330badf8 -- Wed Apr 22 07:30:17 2015
atime: 0x553731e9:330badf8 -- Wed Apr 22 07:30:17 2015
mtime: 0x553731e9:330badf8 -- Wed Apr 22 07:30:17 2015
crtime: 0x553731e9:330badf8 -- Wed Apr 22 07:30:17 2015
Size of extra inode fields: 28
Extended attributes:
system.data (0)
Size of inline data: 60


As you can see the data was stored inline. This can also be seen using df; before creating the file:



% df -i /mnt/new 
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/mapper/vg--large--mirror-inline 65536 12 65524 1% /mnt/new
% df /mnt/new
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/vg--large--mirror-inline 1032088 1280 978380 1% /mnt/new


After creating the file:



% echo Hello >| smallfile
% ls -l
total 1
-rw-r--r-- 1 steve steve 6 Apr 22 07:35 smallfile
% df -i /mnt/new
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/mapper/vg--large--mirror-inline 65536 13 65523 1% /mnt/new
% df /mnt/new
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/vg--large--mirror-inline 1032088 1280 978380 1% /mnt/new


The file is there, it uses an inode but the storage space available hasn't changed.






share|improve this answer





























    up vote
    1
    down vote













    If your e2fsprogs version is too old, or the filesystem is already created, you can set the feature flag using debugfs (the flag is supported since 2012, whereas mke2fs and the other tools added support on 2014+ and many distributions still don't ship them in 2016, incl. Ubuntu Xenial).



    To do so, open the partition in read-write mode:



    debugfs -w /dev/sdxx


    And then add the flag:



    feature inline_data


    (or feature -inline_data to toggle it off, but that's probably a really bad idea if there are inline files already!)



    Do note, however, if your system e2fsprogs are old, you're driving yourself into a corner, since the utilities (including debugfs itself) will refuse to touch such a filesystem after setting the flag.



    Also note that current GRUB (2.02) doesn't support this, so setting it on the boot partition will render the system unbootable. There is an unmerged patch to add support.



    As of the time of this writing, files and directories of up to inode_size-128 can be inlined, so 128 bytes for the default 256 byte inodes. You can use larger inodes if you want more inlining.






    share|improve this answer




















      Your Answer







      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "106"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      convertImagesToLinks: false,
      noModals: false,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













       

      draft saved


      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f197633%2fhow-to-use-the-new-ext4-inline-data-feature-storing-data-directly-in-the-inod%23new-answer', 'question_page');

      );

      Post as a guest






























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      3
      down vote



      accepted










      To enable inline data in ext4, you'll need to e2fsprogs 1.43 or later. Support for inline data was added in March 2014 to the git repository but was only released in May 2016.



      Once you have that, you can run mke2fs -O inline_data on an appropriate device to create a new filesystem with inline data support; this will erase all your data. It's apparently not yet possible to activate inline data on an existing filesystem (at least, tune2fs doesn't support it).



      Now create a small file, and run debugfs on the filesystem. cd to the appropriate directory, and run stat smallfile; you'll get something like



      Inode: 32770 Type: regular Mode: 0644 Flags: 0x10000000
      Generation: 2302340561 Version: 0x00000000:00000001
      User: 1000 Group: 1000 Size: 6
      File ACL: 0 Directory ACL: 0
      Links: 1 Blockcount: 0
      Fragment: Address: 0 Number: 0 Size: 0
      ctime: 0x553731e9:330badf8 -- Wed Apr 22 07:30:17 2015
      atime: 0x553731e9:330badf8 -- Wed Apr 22 07:30:17 2015
      mtime: 0x553731e9:330badf8 -- Wed Apr 22 07:30:17 2015
      crtime: 0x553731e9:330badf8 -- Wed Apr 22 07:30:17 2015
      Size of extra inode fields: 28
      Extended attributes:
      system.data (0)
      Size of inline data: 60


      As you can see the data was stored inline. This can also be seen using df; before creating the file:



      % df -i /mnt/new 
      Filesystem Inodes IUsed IFree IUse% Mounted on
      /dev/mapper/vg--large--mirror-inline 65536 12 65524 1% /mnt/new
      % df /mnt/new
      Filesystem 1K-blocks Used Available Use% Mounted on
      /dev/mapper/vg--large--mirror-inline 1032088 1280 978380 1% /mnt/new


      After creating the file:



      % echo Hello >| smallfile
      % ls -l
      total 1
      -rw-r--r-- 1 steve steve 6 Apr 22 07:35 smallfile
      % df -i /mnt/new
      Filesystem Inodes IUsed IFree IUse% Mounted on
      /dev/mapper/vg--large--mirror-inline 65536 13 65523 1% /mnt/new
      % df /mnt/new
      Filesystem 1K-blocks Used Available Use% Mounted on
      /dev/mapper/vg--large--mirror-inline 1032088 1280 978380 1% /mnt/new


      The file is there, it uses an inode but the storage space available hasn't changed.






      share|improve this answer


























        up vote
        3
        down vote



        accepted










        To enable inline data in ext4, you'll need to e2fsprogs 1.43 or later. Support for inline data was added in March 2014 to the git repository but was only released in May 2016.



        Once you have that, you can run mke2fs -O inline_data on an appropriate device to create a new filesystem with inline data support; this will erase all your data. It's apparently not yet possible to activate inline data on an existing filesystem (at least, tune2fs doesn't support it).



        Now create a small file, and run debugfs on the filesystem. cd to the appropriate directory, and run stat smallfile; you'll get something like



        Inode: 32770 Type: regular Mode: 0644 Flags: 0x10000000
        Generation: 2302340561 Version: 0x00000000:00000001
        User: 1000 Group: 1000 Size: 6
        File ACL: 0 Directory ACL: 0
        Links: 1 Blockcount: 0
        Fragment: Address: 0 Number: 0 Size: 0
        ctime: 0x553731e9:330badf8 -- Wed Apr 22 07:30:17 2015
        atime: 0x553731e9:330badf8 -- Wed Apr 22 07:30:17 2015
        mtime: 0x553731e9:330badf8 -- Wed Apr 22 07:30:17 2015
        crtime: 0x553731e9:330badf8 -- Wed Apr 22 07:30:17 2015
        Size of extra inode fields: 28
        Extended attributes:
        system.data (0)
        Size of inline data: 60


        As you can see the data was stored inline. This can also be seen using df; before creating the file:



        % df -i /mnt/new 
        Filesystem Inodes IUsed IFree IUse% Mounted on
        /dev/mapper/vg--large--mirror-inline 65536 12 65524 1% /mnt/new
        % df /mnt/new
        Filesystem 1K-blocks Used Available Use% Mounted on
        /dev/mapper/vg--large--mirror-inline 1032088 1280 978380 1% /mnt/new


        After creating the file:



        % echo Hello >| smallfile
        % ls -l
        total 1
        -rw-r--r-- 1 steve steve 6 Apr 22 07:35 smallfile
        % df -i /mnt/new
        Filesystem Inodes IUsed IFree IUse% Mounted on
        /dev/mapper/vg--large--mirror-inline 65536 13 65523 1% /mnt/new
        % df /mnt/new
        Filesystem 1K-blocks Used Available Use% Mounted on
        /dev/mapper/vg--large--mirror-inline 1032088 1280 978380 1% /mnt/new


        The file is there, it uses an inode but the storage space available hasn't changed.






        share|improve this answer
























          up vote
          3
          down vote



          accepted







          up vote
          3
          down vote



          accepted






          To enable inline data in ext4, you'll need to e2fsprogs 1.43 or later. Support for inline data was added in March 2014 to the git repository but was only released in May 2016.



          Once you have that, you can run mke2fs -O inline_data on an appropriate device to create a new filesystem with inline data support; this will erase all your data. It's apparently not yet possible to activate inline data on an existing filesystem (at least, tune2fs doesn't support it).



          Now create a small file, and run debugfs on the filesystem. cd to the appropriate directory, and run stat smallfile; you'll get something like



          Inode: 32770 Type: regular Mode: 0644 Flags: 0x10000000
          Generation: 2302340561 Version: 0x00000000:00000001
          User: 1000 Group: 1000 Size: 6
          File ACL: 0 Directory ACL: 0
          Links: 1 Blockcount: 0
          Fragment: Address: 0 Number: 0 Size: 0
          ctime: 0x553731e9:330badf8 -- Wed Apr 22 07:30:17 2015
          atime: 0x553731e9:330badf8 -- Wed Apr 22 07:30:17 2015
          mtime: 0x553731e9:330badf8 -- Wed Apr 22 07:30:17 2015
          crtime: 0x553731e9:330badf8 -- Wed Apr 22 07:30:17 2015
          Size of extra inode fields: 28
          Extended attributes:
          system.data (0)
          Size of inline data: 60


          As you can see the data was stored inline. This can also be seen using df; before creating the file:



          % df -i /mnt/new 
          Filesystem Inodes IUsed IFree IUse% Mounted on
          /dev/mapper/vg--large--mirror-inline 65536 12 65524 1% /mnt/new
          % df /mnt/new
          Filesystem 1K-blocks Used Available Use% Mounted on
          /dev/mapper/vg--large--mirror-inline 1032088 1280 978380 1% /mnt/new


          After creating the file:



          % echo Hello >| smallfile
          % ls -l
          total 1
          -rw-r--r-- 1 steve steve 6 Apr 22 07:35 smallfile
          % df -i /mnt/new
          Filesystem Inodes IUsed IFree IUse% Mounted on
          /dev/mapper/vg--large--mirror-inline 65536 13 65523 1% /mnt/new
          % df /mnt/new
          Filesystem 1K-blocks Used Available Use% Mounted on
          /dev/mapper/vg--large--mirror-inline 1032088 1280 978380 1% /mnt/new


          The file is there, it uses an inode but the storage space available hasn't changed.






          share|improve this answer














          To enable inline data in ext4, you'll need to e2fsprogs 1.43 or later. Support for inline data was added in March 2014 to the git repository but was only released in May 2016.



          Once you have that, you can run mke2fs -O inline_data on an appropriate device to create a new filesystem with inline data support; this will erase all your data. It's apparently not yet possible to activate inline data on an existing filesystem (at least, tune2fs doesn't support it).



          Now create a small file, and run debugfs on the filesystem. cd to the appropriate directory, and run stat smallfile; you'll get something like



          Inode: 32770 Type: regular Mode: 0644 Flags: 0x10000000
          Generation: 2302340561 Version: 0x00000000:00000001
          User: 1000 Group: 1000 Size: 6
          File ACL: 0 Directory ACL: 0
          Links: 1 Blockcount: 0
          Fragment: Address: 0 Number: 0 Size: 0
          ctime: 0x553731e9:330badf8 -- Wed Apr 22 07:30:17 2015
          atime: 0x553731e9:330badf8 -- Wed Apr 22 07:30:17 2015
          mtime: 0x553731e9:330badf8 -- Wed Apr 22 07:30:17 2015
          crtime: 0x553731e9:330badf8 -- Wed Apr 22 07:30:17 2015
          Size of extra inode fields: 28
          Extended attributes:
          system.data (0)
          Size of inline data: 60


          As you can see the data was stored inline. This can also be seen using df; before creating the file:



          % df -i /mnt/new 
          Filesystem Inodes IUsed IFree IUse% Mounted on
          /dev/mapper/vg--large--mirror-inline 65536 12 65524 1% /mnt/new
          % df /mnt/new
          Filesystem 1K-blocks Used Available Use% Mounted on
          /dev/mapper/vg--large--mirror-inline 1032088 1280 978380 1% /mnt/new


          After creating the file:



          % echo Hello >| smallfile
          % ls -l
          total 1
          -rw-r--r-- 1 steve steve 6 Apr 22 07:35 smallfile
          % df -i /mnt/new
          Filesystem Inodes IUsed IFree IUse% Mounted on
          /dev/mapper/vg--large--mirror-inline 65536 13 65523 1% /mnt/new
          % df /mnt/new
          Filesystem 1K-blocks Used Available Use% Mounted on
          /dev/mapper/vg--large--mirror-inline 1032088 1280 978380 1% /mnt/new


          The file is there, it uses an inode but the storage space available hasn't changed.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 25 mins ago

























          answered Apr 22 '15 at 5:37









          Stephen Kitt

          151k23337405




          151k23337405






















              up vote
              1
              down vote













              If your e2fsprogs version is too old, or the filesystem is already created, you can set the feature flag using debugfs (the flag is supported since 2012, whereas mke2fs and the other tools added support on 2014+ and many distributions still don't ship them in 2016, incl. Ubuntu Xenial).



              To do so, open the partition in read-write mode:



              debugfs -w /dev/sdxx


              And then add the flag:



              feature inline_data


              (or feature -inline_data to toggle it off, but that's probably a really bad idea if there are inline files already!)



              Do note, however, if your system e2fsprogs are old, you're driving yourself into a corner, since the utilities (including debugfs itself) will refuse to touch such a filesystem after setting the flag.



              Also note that current GRUB (2.02) doesn't support this, so setting it on the boot partition will render the system unbootable. There is an unmerged patch to add support.



              As of the time of this writing, files and directories of up to inode_size-128 can be inlined, so 128 bytes for the default 256 byte inodes. You can use larger inodes if you want more inlining.






              share|improve this answer
























                up vote
                1
                down vote













                If your e2fsprogs version is too old, or the filesystem is already created, you can set the feature flag using debugfs (the flag is supported since 2012, whereas mke2fs and the other tools added support on 2014+ and many distributions still don't ship them in 2016, incl. Ubuntu Xenial).



                To do so, open the partition in read-write mode:



                debugfs -w /dev/sdxx


                And then add the flag:



                feature inline_data


                (or feature -inline_data to toggle it off, but that's probably a really bad idea if there are inline files already!)



                Do note, however, if your system e2fsprogs are old, you're driving yourself into a corner, since the utilities (including debugfs itself) will refuse to touch such a filesystem after setting the flag.



                Also note that current GRUB (2.02) doesn't support this, so setting it on the boot partition will render the system unbootable. There is an unmerged patch to add support.



                As of the time of this writing, files and directories of up to inode_size-128 can be inlined, so 128 bytes for the default 256 byte inodes. You can use larger inodes if you want more inlining.






                share|improve this answer






















                  up vote
                  1
                  down vote










                  up vote
                  1
                  down vote









                  If your e2fsprogs version is too old, or the filesystem is already created, you can set the feature flag using debugfs (the flag is supported since 2012, whereas mke2fs and the other tools added support on 2014+ and many distributions still don't ship them in 2016, incl. Ubuntu Xenial).



                  To do so, open the partition in read-write mode:



                  debugfs -w /dev/sdxx


                  And then add the flag:



                  feature inline_data


                  (or feature -inline_data to toggle it off, but that's probably a really bad idea if there are inline files already!)



                  Do note, however, if your system e2fsprogs are old, you're driving yourself into a corner, since the utilities (including debugfs itself) will refuse to touch such a filesystem after setting the flag.



                  Also note that current GRUB (2.02) doesn't support this, so setting it on the boot partition will render the system unbootable. There is an unmerged patch to add support.



                  As of the time of this writing, files and directories of up to inode_size-128 can be inlined, so 128 bytes for the default 256 byte inodes. You can use larger inodes if you want more inlining.






                  share|improve this answer












                  If your e2fsprogs version is too old, or the filesystem is already created, you can set the feature flag using debugfs (the flag is supported since 2012, whereas mke2fs and the other tools added support on 2014+ and many distributions still don't ship them in 2016, incl. Ubuntu Xenial).



                  To do so, open the partition in read-write mode:



                  debugfs -w /dev/sdxx


                  And then add the flag:



                  feature inline_data


                  (or feature -inline_data to toggle it off, but that's probably a really bad idea if there are inline files already!)



                  Do note, however, if your system e2fsprogs are old, you're driving yourself into a corner, since the utilities (including debugfs itself) will refuse to touch such a filesystem after setting the flag.



                  Also note that current GRUB (2.02) doesn't support this, so setting it on the boot partition will render the system unbootable. There is an unmerged patch to add support.



                  As of the time of this writing, files and directories of up to inode_size-128 can be inlined, so 128 bytes for the default 256 byte inodes. You can use larger inodes if you want more inlining.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Sep 11 '16 at 20:57









                  Inlining fan

                  111




                  111



























                       

                      draft saved


                      draft discarded















































                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f197633%2fhow-to-use-the-new-ext4-inline-data-feature-storing-data-directly-in-the-inod%23new-answer', 'question_page');

                      );

                      Post as a guest













































































                      Popular posts from this blog

                      How to check contact read email or not when send email to Individual?

                      Bahrain

                      Postfix configuration issue with fips on centos 7; mailgun relay