如何將多個選項傳遞給「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

正如托馬斯所說,sparated by commas是為了擴展期權分離。然而,mount_opts選項分離也是使用,(參見Linux核心fs/ext4/super.c:parse_options())完成的,並且從這個答案開始e2fsprogs'mke2fs tune2fs無法在語義上區分彼此。

A與 Theodore Y. Ts'o 的郵件往來透露:

是的,這是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

相關內容