To enable inline data in ext4, you'll need to use 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.