Linux

如何將多個選項傳遞給tune2fs -E mount_opts

  • December 14, 2018

根據手冊:

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”上傳遞具有多個選項的字元串?

正如托馬斯所說,sparated by commas是為了擴展選項分離。但是,mount_opts選項分離也是使用,(參見 Linux 核心fs/ext4/super.c:parse_options())完成的,並且在這個答案中e2fsprogsmke2fs 並且 tune2fs無法在語義上將一個與另一個區分開來。

與 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-specific 選項,而noatime不是(參見相同的核心源文件,可用選項列在tokens數組中)。功能上最接近的匹配是**lazytime**.

所以,使用debugfs -w -R "set_super_value mount_opts data=writeback,lazytime" /dev/sde2.

引用自:https://serverfault.com/questions/898724