Thursday, November 8, 2018

lsblk --merge

For uti-linux version v2.34 (next spring) I'm working on new lsblk. The goal is keep all devices as data structs in memory to have ability to modify or reorder the tree.

Now lsblk blindly follows slaves/holders links in /sys and in case of RAIDs or multi-path devices the output contains duplicate lines.

The new version will provide de-duplication (lsblk --dedup WWN) to completely remove unnecessary lines from output.

The another feature is possibility to use libsmartcols to specify group of lines and define children for the group. This allows to describe M:N relationships by chart without duplicate lines in output.

See the next example with one multi-path device and one RAID device.

$ lsblk --merge
      NAME        MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
      sda           8:0    0 223.6G  0 disk  
      ├─sda1        8:1    0   200M  0 part  /boot/efi
      ├─sda2        8:2    0   200M  0 part  /boot
      ├─sda3        8:3    0 130.3G  0 part  
      ├─sda4        8:4    0    50G  0 part  /
┌┈┄┄▶ └─sda5        8:5    0  42.9G  0 part  
┆     sdb           8:16   0  74.5G  0 disk  
┆     └─sdb1        8:17   0  74.5G  0 part  /home/archive
┆ ┌┈▶ sdc           8:32   0   100M  0 disk  
┆ ├┈▶ sdd           8:48   0   100M  0 disk  
┆ ├┈▶ sde           8:64   0   100M  0 disk  
┆ └┬▶ sdf           8:80   0   100M  0 disk  
┆  └┈┄mpatha      253:0    0   100M  0 mpath 
┆     ├─mpatha1   253:1    0    50M  0 part  
┆     └─mpatha2   253:2    0    49M  0 part  
┆     nvme0n1     259:0    0 223.6G  0 disk  
┆     ├─nvme0n1p1 259:1    0   7.8G  0 part  
┆     ├─nvme0n1p2 259:2    0   200G  0 part  /home
└┬┄┄▶ └─nvme0n1p3 259:3    0  15.8G  0 part  
 └┄┄┈┄md0           9:0    0  15.8G  0 raid1 
      ├─md0p1     259:4    0   100M  0 md    
      └─md0p2     259:5    0  15.7G  0 md    

The original lsblk output:
 
NAME        MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
sda           8:0    0 223.6G  0 disk  
├─sda1        8:1    0   200M  0 part  /boot/efi
├─sda2        8:2    0   200M  0 part  /boot
├─sda3        8:3    0 130.3G  0 part  
├─sda4        8:4    0    50G  0 part  /
└─sda5        8:5    0  42.9G  0 part  
  └─md0       9:0    0  15.8G  0 raid1 
    ├─md0p1 259:4    0   100M  0 md    
    └─md0p2 259:5    0  15.7G  0 md    
sdb           8:16   0  74.5G  0 disk  
└─sdb1        8:17   0  74.5G  0 part  /home/archive
sdc           8:32   0   100M  0 disk  
└─mpatha    253:0    0   100M  0 mpath 
  ├─mpatha1 253:1    0    50M  0 part  
  └─mpatha2 253:2    0    49M  0 part  
sdd           8:48   0   100M  0 disk  
└─mpatha    253:0    0   100M  0 mpath 
  ├─mpatha1 253:1    0    50M  0 part  
  └─mpatha2 253:2    0    49M  0 part  
sde           8:64   0   100M  0 disk  
└─mpatha    253:0    0   100M  0 mpath 
  ├─mpatha1 253:1    0    50M  0 part  
  └─mpatha2 253:2    0    49M  0 part  
sdf           8:80   0   100M  0 disk  
└─mpatha    253:0    0   100M  0 mpath 
  ├─mpatha1 253:1    0    50M  0 part  
  └─mpatha2 253:2    0    49M  0 part  
nvme0n1     259:0    0 223.6G  0 disk  
├─nvme0n1p1 259:1    0   7.8G  0 part  
├─nvme0n1p2 259:2    0   200G  0 part  /home
└─nvme0n1p3 259:3    0  15.8G  0 part  
  └─md0       9:0    0  15.8G  0 raid1 
    ├─md0p1 259:4    0   100M  0 md    
    └─md0p2 259:5    0  15.7G  0 md    

The code is still not ready to merge to the master branch and some cosmetic changes are expected, but the idea is obvious I guess. (If you want to play with it see topic/lsblk branch in util-linux repository.)

Thursday, February 15, 2018

util-linux v2.32 -- what's new?

This release (rc1 now) is without dramatic changes and game-changing improvements.

We have again invested our time and love to make cal(1) more usable. The most visible change is possibility to specify calendar system.

The current (backwardly compatible) default is to use Gregorian calendar and Julian calendar for dates before September 1752 (British Empire calendar reform). Unfortunately, this default is pretty frustrating if you want to use cal(1) for old dates before 1752 and you don't want to follow UK calendar.

The new command line option --reform={Julian,Gregorian,iso,1752,...} allows to specify exclusively calendar system or reform date. The currently supported reform is only UK reform in 1752. In the next versions we will probably add support for another reforms as it's very region specific (for example 1584 in my country, 1873 in Japan and 1926 Turkey, etc.).



Linux kernel supports multi-line log messages. Unfortunately, dmesg(1) support for this feature was insufficient. Now dmesg(1) provides better support and by new command line option --force-prefix allows to to print facility, level or timestamp information to each line of a multi-line message.

The command fallocate(1) --dig-holes has been significantly improved and it's faster more effective now (thanks to Vaclav Dolezal).

The command lscpu(1) provides more details about ARM CPUs now.

The command lsmem(1) supports memory zones now.

The command lsns(8) provides netnsid and nsfs columns now. ip(1) command allows to create network namespace, add logical name and ID for the namespace. Now all is visible by lsns(8). For example copy & past from our regression tests:

        NS TYPE NPROCS   PID USER     NETNSID NSFS                            COMMAND
4026532001 net     281     1 root  unassigned                                 /usr/lib/systemd/systemd --switched-root --system --deserialize 24
4026532400 net       1   795 rtkit unassigned                                 /usr/libexec/rtkit-daemon
4026532590 net       1  6707 root           0 /run/netns/LSNS-TEST-NETNSID-NS dd if=tests/output/lsns/FIFO-NETNSID bs=1 count=2 of=/dev/null

where dd(1) is running in the net namespace, and the namespace is by nsfs mounted on /run/netns/LSNS-TEST-NETNSID-NS. See https://raw.githubusercontent.com/karelzak/util-linux/master/tests/ts/lsns/netnsid for more details how to use ip(8) to setup this namespace.

The command rtcwake(8) has been improved to wait stdin to settle down before entering a system sleep. This is important on systems where wireless USB devices (mouse, keyboard, ...) generate "noise" for fraction of a second after rtcwake(8) execution.

The library libblkid has been extended to support LUKS2, Micron mpool, VDO and Atari partition table.



Thanks to all 43 contributors!

The next release v2.33 is planned for May 2018 (yes, the goal is to have 3-4 releases per year rather than 2 releases like in last years).