对于逻辑卷,如何修改默认的lvs输出?

对于逻辑卷,如何修改默认的lvs输出?

lvs得到默认输出:

~$ sudo lvs
  LV                     VG       Attr       LSize  Pool Origin  Data%  Meta%  Move Log Cpy%Sync Convert
  pre_upgrade_2020-10-31 rpi.vg06 swi-a-s---  2,19g      root.lv 64,37
  pre_upgrade_2020-12-02 rpi.vg06 swi-a-s--- <2,20g      root.lv 0,02
  root.lv                rpi.vg06 owi-aos---  3,00g

但这不是我最感兴趣的。我想得到:

~$ sudo lvs -o lv_full_name,lv_attr,origin,lv_size,seg_size_pe,data_percent,lv_time -O lv_time
  LV                              Attr       Origin  LSize  SSize Data%  CTime
  rpi.vg06/root.lv                owi-aos---          3,00g   768        2020-04-05 22:34:46 +0200
  rpi.vg06/pre_upgrade_2020-10-31 swi-a-s--- root.lv  2,19g   561 64,37  2020-10-31 20:52:45 +0100
  rpi.vg06/pre_upgrade_2020-12-02 swi-a-s--- root.lv <2,20g   562 0,02   2020-12-02 23:15:47 +0100

命令有点长,不好记。我尝试使用别名,但sudo不知道用户别名。有没有办法配置 lvs 默认输出这个sudo lvs?也许在*.conf*rc文件中?

答案1

lvs可以在 中更改默认输出/etc/lvm/lvm.conf。找到该report部分并将值更改lvs_cols为您想要在lvs输出中看到的列。

# Configuration section report.
# LVM report command output formatting.
# This configuration section has an automatic default value.
report {
...
        # Configuration option report/lvs_cols.
        # List of columns to report for 'lvs' command.
        # See 'lvs -o help' for the list of possible fields.
        # This configuration option has an automatic default value.
        lvs_cols = lv_full_name,lv_attr,origin,lv_size,seg_size_pe,data_percent,lv_time
...
}
$ sudo lvs
  LV          Attr       Origin LSize   SSize  Data%  CTime                     
  fedora/home -wi-ao----        852,64g 218277        2019-06-07 14:08:45 +0200 
  fedora/root -wi-ao----         69,98g  17916        2019-06-07 14:08:48 +0200 
  fedora/swap -wi-ao----          7,86g   2013        2019-06-07 14:08:45 +0200

相关内容