大网数据广告活动
服务器运维问答

How to pass multiple options to `tune2fs -E mount_opts`?

· 52CE 我爱测

According to the manual: mount_opts=mount_option_string Set a set of default mount options which will be used when the file system is mounted. Unlike the bitmask-based default mount options which can be specified with the -o opti…

问题原文

原帖链接 · lvella · CC BY-SA 3.0

According to the manual:

mount_opts=mount_option_string
                      Set  a  set  of  default mount options which will be used when the file
                      system is mounted.  Unlike  the  bitmask-based  default  mount  options
                      which  can  be  specified with the -o option, mount_option_string is an
                      arbitrary string with a maximum length of 63 bytes, which is stored  in
                      the superblock.

If I try to set a single option, it works:

$ tune2fs -E mount_opts=data=writeback /dev/sde2
tune2fs 1.43.5 (04-Aug-2017)
Setting extended default mount options to 'data=writeback'

But if I try to set multiple options, it seems to conflicts with tune2fs own parsing mechanism:

$ tune2fs -E mount_opts=data=writeback,noatime /dev/sde2 
tune2fs 1.43.5 (04-Aug-2017)

Bad options specified.

Extended options are separated by commas, and may take an argument which
    is set off by an equals ('=') sign.

Valid extended options are:
    clear_mmp
    hash_alg=<hash algorithm>
    mount_opts=<extended default mount options>
    stride=<RAID per-disk chunk size in blocks>
    stripe_width=<RAID stride*data disks in blocks>
    test_fs
    ^test_fs

How to pass a string with multiple options on 'mount_opts'?

已采纳解答

原帖链接 · ElementW · CC BY-SA 4.0

As Thomas says, sparated by commas is for extended option separation. However, mount_opts option separation is also done using , (see Linux kernel fs/ext4/super.c:parse_options()), and as of this answer e2fsprogs' mke2fs and tune2fs fail to semantically distinguish one from the other.

A mail exchange with Theodore Y. Ts'o reveals:

Yes, this is a shortcoming in tune2fs.

There is no syntax to achieve this using the common ext manipulation tools. Ts'o instead advises to use debugfs as a workaround:

You can set extended mount options using debugfs:
debugfs -w -R "set_super_value mount_opts foo,bar" /dev/sda1

In this case, you would need debugfs -w -R "set_super_value mount_opts data=writeback,noatime" /dev/sde2, but this doesn't have the effect you expect.

Upon mounting, the ext4 kernel module will complain about an Unrecognized mount option "noatime" or missing value; in fact, it is only possible to specify ext-specific options, and noatime is not (see same kernel source file, the available options are listed in the tokens array). The functionally closest match is lazytime.

So, use debugfs -w -R "set_super_value mount_opts data=writeback,lazytime" /dev/sde2.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-02-24)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0 / CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。