如何将多个选项传递给“tune2fs -E mount_opts”?

如何将多个选项传递给“tune2fs -E mount_opts”?

根据手册:

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.

如果我尝试设置一个选项,它会起作用:

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

但如果我尝试设置多个选项,它似乎与tune2fs自己的解析机制冲突:

$ 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

如何在‘mount_opts’上传递包含多个选项的字符串?

答案1

正如 Thomas 所说,sparated by commas是用于扩展选项分离。但是,选项分离也可以使用(参见 Linux 内核)mount_opts完成,并且从这个答案开始',fs/ext4/super.c:parse_options()e2fsprogsmke2fs tune2fs无法在语义上区分彼此。

A与左宗棠的邮件往来显示

是的,这是tune2fs的一个缺点。

没有使用常见ext操作工具实现此目的的语法。Ts'o 建议使用debugfs以下解决方法:

您可以使用 debugfs 设置扩展挂载选项:
debugfs -w -R "set_super_value mount_opts foo,bar" /dev/sda1

在这种情况下,您需要debugfs -w -R "set_super_value mount_opts data=writeback,noatime" /dev/sde2,但是这并没有达到你预期的效果

在安装时,ext4内核模块会抱怨Unrecognized mount option "noatime" or missing value;事实上,它只能指定ext特定于选项,并且noatime不能(参见相同的内核源文件,可用的选项列在数组中tokens)。功能上最接近的匹配是lazytime

因此,使用debugfs -w -R "set_super_value mount_opts data=writeback,lazytime" /dev/sde2

答案2

sparated by commas与不同的扩展选项相关,如,clear_mmp等。hash_algmount_opts

因此正确的语法如下。

tune2fs -E mount_opts="data=writeback noatime" /dev/sde1

相关内容