Feature Request: Support tune2fs in EasyInstaller

I want to enable data=journal option for rootfs partition. It cannot be enabled inside fstab as kernel complains that the journalling option cannot be changed during a remount:

[    3.077990] EXT4-fs (mmcblk0p1): recovery complete
[    3.084907] EXT4-fs (mmcblk0p1): mounted filesystem with ordered data mode. Opts: (null)
[    4.139478] EXT4-fs (mmcblk0p1): Cannot change data mode on remount

The sensible option is to tune the journaling inside wrapup.sh script using tune2fs. However, the current EasyInstaller image lacks this command.

As a workaround to my problem, I currently pass rootflags=data=journal as one of the kernel parameters, but this solution is fragile because kernel doesn’t support all mounting options and not all tune2fs operations can be done during mounting.

It would be nice to have tune2fs in EasyInstaller as it can serve other purposes too.

Are you sure that the kernel does not support all mount options? It seems that the kernel calls ksys_mount, which is also used from user space, so I would guess that rootflags= should support all mount options.

But I agree, it would be nice to be able to tune the file system in Tezi in any possible way. Using tune2fs sounds a bit a work around to me, I would rather prefer to have it created with the correct setting in first place. mke2fs.conf has default_mntopts which allows to set default mount options. Unfortunately, /etc/mke2fs.conf is not writeable (since it on a squashfs) and it is not possible to tell mkfs.ext4 to use an alternative config file… One way out might be to use a symlink from /etc/mke2fs.conf to /var/volatile/mke2fs.conf, and then just don’t deploy any config by default (since as far as I can see, /etc/mke2fs.conf only contains the same values used by default in mkfs.ext4 anyway). This way one could create a mke2fs.conf using a prepare.sh script and control the mkfs.ext4 behavior in any way possible.

Are you sure that the kernel does not support all mount options?

Honestly I’m not sure, but I was getting error with rootflags=sync option. Here is a discussion that made me more suspicious that passing such options is not feasible: it appears to be impossible to set any of the filesystem-independent flags via rootflags, which explains the special-case code for the ‘ro’ and ‘rw’ flags.

However, I haven’t tried flags=data=journal. This might actually alleviate this issue.

Using tune2fs sounds a bit a work around to me

In some sense, yes. The other way to look around it is that by using tune2fs, we are hard-coding the mount options into the partition so that we don’t have to worry about mount/remount options. It will be always mounted as intended no matter what kernel parameters/fstab options the user set, except when the user overrides them explicitly.

mke2fs.conf has default_mntopts which allows to set default mount options

I didn’t know about that. But I doubt whether that support tuning the level of journaling. The default journaling level is data=ordered but I am trying to rise it up to data=journal (such a bad naming). This documentation only mentions enabling journaling by mke2fs.conf, but like mkfs I cannot find a way to tune the journaling level.

Setting default_mntopts via mke2fs.conf or using tune2fs -o is actually the same thing, both set the default mount option of the partition. They call both e2p_edit_mntopts() internally:

I see. This could probably solve the issue. I will let you know the outcome. Thanks Stefan.

BTW, I was completely forgetful about rootflags=data=journal kernel parameter. This did solve the problem. But as passing some other options like sync by rootflags is not supported, I got the sense that people mostly rely on either remounting with desired flags or setting default mount options inside the partition.

According to the man pages, the rootflags=data=journal is the way to go when changing journaling options for ext3/ext4, so I would use it independently of whether extra tuning is needed from tune2fs.

On the other hand rootflags can handle all but the fs-independent flags. This is not a problem because fs-independent flags can be changed in remounts without problems, so you can add them in your fstab or simply remount your fs after boot with the new options.

As for the sync option, recall that it may not have any effects for ext4, as stated in the man page of mount.

According to the man pages, the rootflags=data=journal is the way to go

Thanks Gerard. That was reassuring.

As for the sync option, recall that it may not have any effects for ext4, as stated in the man page of mount.

I couldn’t find this on man page for mount. Did you mean the barrier=1 option (since it is set to 1 by default in ext4). The sync is generally discouraged as it shorten the lifespan of media though.

From the mount man page

the sync option today has an effect only for ext2, ext3, fat, vfat and ufs

In any case we have raised a ticket to consider adding tune2fs in tezi.

Hi Gerard,

Thanks, I missed that in man page. I was still suspicious of ext4 not supporting sync and checked the mount docs in util-linuxrepo. Turns out ext4 has been added in master branch, just recently (about a week ago)! What are the odds.

While rootflags=data=journal as you said has fixed my particular issue with sync, having tune2fs in tezi would be very nice and as other options can be fune-tuned. Thanks for consideration.