从 lsblk 输出中排除 loop* snap 设备吗?

从 lsblk 输出中排除 loop* snap 设备吗?

就我而言,我看到的是:

~$ sudo lsblk 
NAME                    MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
loop0                     7:0    0 367,3M  1 loop  /snap/clion/69
loop1                     7:1    0    44M  1 loop  /snap/ffmpeg/206
loop2                     7:2    0  14,8M  1 loop  /snap/gnome-characters/258
loop3                     7:3    0 141,8M  1 loop  /snap/skype/60
loop4                     7:4    0  14,8M  1 loop  /snap/gnome-characters/206
loop5                     7:5    0   518M  1 loop  /snap/libreoffice/117
loop6                     7:6    0  45,4M  1 loop  /snap/ffmpeg/403
loop7                     7:7    0 134,3M  1 loop  /snap/icq-im/21
loop8                     7:8    0  53,7M  1 loop  /snap/core18/941
loop9                     7:9    0 169,4M  1 loop  /snap/gimp/113
loop10                    7:10   0 154,6M  1 loop  /snap/chromium/705
loop11                    7:11   0 225,1M  1 loop  /snap/webstorm/90
loop12                    7:12   0   3,7M  1 loop  /snap/gnome-system-monitor/77
loop13                    7:13   0   372M  1 loop  /snap/pycharm-professional/125
loop14                    7:14   0 150,2M  1 loop  /snap/opera/35
loop15                    7:15   0  91,1M  1 loop  /snap/core/6531
loop16                    7:16   0   127M  1 loop  /snap/code/6
loop17                    7:17   0 222,2M  1 loop  /snap/webstorm/86
loop18                    7:18   0 456,4M  1 loop  /snap/wine-platform/128
loop19                    7:19   0 218,1M  1 loop  /snap/gimp/130
loop20                    7:20   0 300,4M  1 loop  /snap/datagrip/45
loop21                    7:21   0   151M  1 loop  /snap/gnome-

...

loop84                    7:84   0  53,7M  1 loop  /snap/core18/731
loop85                    7:85   0 140,7M  1 loop  /snap/gnome-3-26-1604/74
loop86                    7:86   0 150,2M  1 loop  /snap/opera/36
loop87                    7:87   0   368M  1 loop  /snap/clion/70
sda                       8:0    0 931,5G  0 disk  
├─sda1                    8:1    0    80G  0 part  
├─sda2                    8:2    0    68G  0 part  
└─sda4                    8:4    0 783,5G  0 part  

... 

nvme0n1                 259:0    0 238,5G  0 disk  
├─nvme0n1p1             259:1    0   512M  0 part  /boot/efi
├─nvme0n1p2             259:2    0   732M  0 part  /boot
└─nvme0n1p3             259:3    0 237,3G  0 part  
  └─nvme0n1p3_crypt     253:0    0 237,3G  0 crypt 
    ├─ubuntu--vg-root   253:1    0 236,3G  0 lvm   /
    └─ubuntu--vg-swap_1 253:2    0   976M  0 lvm   [SWAP]

但对我有用的是物理磁盘,例如sda*NVMe*..

是否可以使用一些参数临时隐藏 loop* 虚拟设备?或者请给我推荐另一个命令来监视我的设备。

答案1

由于循环块设备的主要节点类型为 7(如 中所示/proc/devices),因此您可以使用-e--exclude命令行开关按主要类型排除它们:

   -e, --exclude list
          Exclude the devices specified by  the  comma-separated  list  of
          major  device  numbers.   Note  that  RAM  disks  (major=1)  are
          excluded by default.  The filter is  applied  to  the  top-level
          devices only.

前任。

$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
loop1    7:1    0  17.9M  1 loop /snap/pdftk/1
loop2    7:2    0  89.3M  1 loop /snap/core/6673
loop3    7:3    0  91.1M  1 loop /snap/core/6531
loop4    7:4    0    20K  1 loop /snap/hello-world/27
loop5    7:5    0  50.7M  1 loop /snap/p7zip-desktop/163
loop6    7:6    0    20K  1 loop /snap/hello-world/29
loop7    7:7    0  17.9M  1 loop /snap/pdftk/9
loop8    7:8    0  89.4M  1 loop /snap/core/6818
sda      8:0    0 238.5G  0 disk
├─sda1   8:1    0   9.8G  0 part
├─sda2   8:2    0 164.7G  0 part
├─sda3   8:3    0  31.1G  0 part /
├─sda4   8:4    0     1K  0 part
├─sda5   8:5    0  15.3G  0 part /usr/local
└─sda6   8:6    0  17.7G  0 part /home
sr0     11:0    1  1024M  0 rom

$ lsblk -e7
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 238.5G  0 disk
├─sda1   8:1    0   9.8G  0 part
├─sda2   8:2    0 164.7G  0 part
├─sda3   8:3    0  31.1G  0 part /
├─sda4   8:4    0     1K  0 part
├─sda5   8:5    0  15.3G  0 part /usr/local
└─sda6   8:6    0  17.7G  0 part /home
sr0     11:0    1  1024M  0 rom

答案2

您可以使用grep来过滤输出:

lsblk | grep -v '^loop'

这将删除以 开头的行loop

相关内容