tag:blogger.com,1999:blog-79213260749801359182024-03-08T12:31:14.454+01:00Karel Zak's blogUnknownnoreply@blogger.comBlogger58125tag:blogger.com,1999:blog-7921326074980135918.post-46266304457517888902024-01-31T19:18:00.000+01:002024-01-31T19:18:35.709+01:00What's New in util-linux v2.40?<div class="flex flex-grow flex-col max-w-full"><div class="min-h-[20px] text-message flex flex-col items-start gap-3 whitespace-pre-wrap break-words [.text-message+&]:mt-5 overflow-x-auto" data-message-author-role="assistant" data-message-id="f9ddb6fc-33f7-4163-bab3-66be3bfb49a0"><div class="markdown prose w-full break-words dark:prose-invert light"><p>The util-linux v2.40-rc1 was released just a few days ago. Let's explore the new features introduced in this release.</p><p>We have a new small shared library in the project, liblastlog, to implement a replacement for the lastlog file and lastlog-related utils. The main goal is to fix the Y2038 issue and use a more advanced file format to store the log. The original lastlog implementation uses 32-bit time values and a file format where an entry location is based on UID, so on systems with huge UIDs, it creates a huge lastlog file (fortunately, a file with holes). The new library uses the SQLite3 library to store data. It makes things easy to extend, efficient, and fast. There is also the pam_lastlog2 module as a replacement for the original pam_lastlog. Thanks to Suse, namely Stefan Schubert and Thorsten Kukuk.</p><p>The library libuuid has also been improved to support 64-bit time.</p><p>The next big change is within libsmartcols. The library now supports filtering expressions and counters. The idea and first implementation come from Masatake Yamato; it was originally designed for lsfd, but we found it very useful to make it generic and usable for arbitrary applications, so now all the functionality is exported by the public library API.</p><p>Applications can utilize the filter before gathering all data for output, reducing resource usage and improving performance. This is important for tools like lsblk where gathering data can be time-consuming in some cases (for example, read details from partition tables, filesystems superblocks, or fetch data from udevd). The expressions use lazy evaluation, so only necessary data comes to the game.</p><p>The filter expression uses C-like format with human-readable aliases ("&&" alias "and"), for example:</p><pre><div class="dark bg-black rounded-md"><div class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs language-bash"><span class="hljs-comment"> # lsfd -Q 'TIMERFD.remaining < 0.5 && TIMERFD.remaining > 0.0'</span>
</code></div></div></pre><p>It supports basic operators, including regular expressions for strings:<span></span><span class="" data-state="closed"></span></p><pre><div class="dark bg-black rounded-md"><div class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs language-bash"><span class="hljs-comment"> # lsfd -Q 'COMMAND =~ ".*qemu.*" && FD >= 0'</span></code></div></div></pre><p>The parser is generated by flex and bison.</p><p>The expression can contain data from fields (columns) which will not be printed.</p><p>An extension to the expression are counters. The counter uses an aggregation function to count lines or summarize numbers (supported functions are count, min, max, and sum).</p><p>The counter is possible to restrict by expression, for example:</p><pre><div class="dark bg-black rounded-md"><div class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs language-bash"><span class="hljs-comment"># lsfd --summary=only \</span>
-C <span class="hljs-string">'netlink sockets'</span>:<span class="hljs-string">'(NAME =~ "NETLINK:.*")'</span> \
-C <span class="hljs-string">'unix sockets'</span>:<span class="hljs-string">'(NAME =~ "UNIX:.*")'</span>
VALUE COUNTER
57 netlink sockets
1552 unix sockets
</code></div></div></pre><p>In future releases, I'd like to add the possibility to colorize data in libsmartcols tables based on expressions and cell types. For now, a very basic possibility is available in lsblk by using the "--highlight <expr>" command line option.</p><p>You probably know that in Linux we have more system clocks, but do you know any elegant way to see all the clocks? ;-) Ladies and gentlemen, welcome lsclocks, a new util-linux command.</p><pre><div class="dark bg-black rounded-md"><div class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs language-bash"><span class="hljs-comment"># lsclocks</span>
ID NAME TYPE TIME RESOL ISO_TIME
0 realtime sys 1706702926.075958226 1ns 2024-01-31T12:08:46.075958226+00:00
1 monotonic sys 332686.333569506 1ns 1970-01-04T20:24:46.333569506+00:00
4 monotonic-raw sys 332685.732374681 1ns 1970-01-04T20:24:45.732374681+00:00
5 realtime-coarse sys 1706702926.074719228 1ms 2024-01-31T12:08:46.074719228+00:00
6 monotonic-coarse sys 332686.332298188 1ms 1970-01-04T20:24:46.332298188+00:00
7 boottime sys 435547.110588884 1ns 1970-01-06T00:59:07.110588884+00:00
8 realtime-alarm sys 1706702926.075996923 1ns 2024-01-31T12:08:46.075996923+00:00
9 boottime-alarm sys 435547.110592620 1ns 1970-01-06T00:59:07.110592620+00:00
11 tai sys 1706702963.076000869 1ns 2024-01-31T12:09:23.076000869+00:00
</code></div></div></pre><p>It can also read time from RTC, time offsets from namespaces, and process CPU time. Like all ls-like tools in util-linux, it supports parsable outputs, including JSON. Thanks to Thomas Weißschuh.</p><p>If you use systemd credentials system, then agetty(8) and login(1) can follow this system. For now, it's supported for autologin. Thanks to Daan De Meyer.</p><p>dmesg(1) parses caller-id from kernel messages and prints it. Thanks to Edward Chron. It can also now print timestamps in multiple formats at the same time for each message (--time-format may be specified more than once). Thanks to Rishabh Thukral.<br /></p><p>Sounds strange, but sometimes the goal is to break things :-) For this purpose, we have introduced a new command "enosys". It can call an arbitrary program with disabled syscall. The same functionality provides, for example, strace, but it seems useful to have a tiny dedicated tool for this purpose. For example:</p><pre><div class="dark bg-black rounded-md"><div class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs language-bash"><span class="hljs-comment"># enosys --syscall ioprio_get ionice</span>
ionice: ioprio_get failed: Function not implemented
</code></div></div></pre><p>Thanks to Thomas Weißschuh.</p><div class="flex flex-grow flex-col max-w-full"><div class="min-h-[20px] text-message flex flex-col items-start gap-3 whitespace-pre-wrap break-words [.text-message+&]:mt-5 overflow-x-auto" data-message-author-role="assistant" data-message-id="bc19a2fa-6f77-4f00-ab2e-267ed2b058a9"><div class="markdown prose w-full break-words dark:prose-invert light"><p>Atomicity matters in many cases. The new small command "exch" can atomically exchange paths between two files. Thanks to Masatake Yamato.</p><p>Again, your upstream CI tests have been improved. Every pull request has to pass 32 checks, including a static analyzer, fuzzing, build tests on multiple architectures (including riscv64, s390), and multiple distros (Ubuntu, Fedora). It undergoes building by GCC (versions 13 and 14) and Clang compilers, along with more than 300 regression tests and countless subtests.</p><p>And many, many other changes – the Release Notes file has approximately 1160 lines. Thanks to all contributors!</p></div></div></div><div class="mt-1 flex justify-start gap-3 empty:hidden"><div class="text-gray-400 flex self-end lg:self-center justify-center lg:justify-start mt-0 -ml-1 visible"><span class="" data-state="closed"></span></div></div><span class="" data-state="closed"></span><span class="" data-state="closed"></span><p> </p></div></div></div><div class="mt-1 flex justify-start gap-3 empty:hidden"><div class="text-gray-400 flex self-end lg:self-center justify-center lg:justify-start mt-0 -ml-1 visible"><span class="" data-state="closed"></span></div></div><span class="" data-state="closed"></span><span class="" data-state="closed"></span><p> </p>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7921326074980135918.post-82225316139137536992023-06-01T13:52:00.001+02:002023-06-16T16:59:33.294+02:00util-linux v2.39: Improved Mount Interface and Exciting Updates<p>This release comes with dramatic changes, and the most noticeable change is the support for a new kernel mount API in libmount.</p><p>The classic mount(2) system call has been with us since the early days of Linux. This interface is quite simple: you specify the source, target, filesystem options, mount flags, and ask the kernel to do the job. Unfortunately, the interface is too simplistic. These days, attaching a filesystem requires multiple steps, and it's important for userspace to assist in these steps and receive feedback from the kernel after each one.</p><p>We are all familiar with the infamous error message:</p><pre><code class="!whitespace-pre hljs language-vbnet"><span class="hljs-symbol">mount:</span> wrong fs type, bad <span class="hljs-keyword">option</span>, bad superblock <span class="hljs-keyword">on</span> /mnt missing
codepage <span class="hljs-built_in">or</span> helper program, <span class="hljs-built_in">or</span> other <span class="hljs-keyword">error</span>.</code></pre><pre><code class="!whitespace-pre hljs language-vbnet"> </code></pre><p>This error message can be quite cryptic. In this case, mount(8) attempted to guess a few possibilities for the EINVAL errno, but nothing seemed relevant, so it prints this error message.</p><p>With the new interface, after the syscall <code>fsopen("nonsense", 0)</code>, we can inform the user that "mount -t nonsense" is a bad idea.</p><p>Please note that you can still see this generic error in mount(8) from v2.39, as the goal for this release was to adopt the new interface. Optimization will come in future releases, so please be patient.</p><p>The new kernel mount interface is a set of syscalls that use file descriptors as a glue between them. This kind of interface is open to new extensions (new syscalls), and userspace and filesystem developers don't have to try to explain the entire universe in a comma-separated mount options string.</p><p>File descriptors are a game changer. We have a file descriptor to configure the superblock (the filesystem itself) and another file descriptor to set VFS (Virtual File System) node attributes and attach the node to the VFS tree. The file descriptor remains usable even when you change a namespace, etc.</p><p>The important thing is that userspace applications (like the mount(8) command) can work with a filesystem that is not yet attached. It means that mount(8) configures the filesystem, sets VFS flags (such as noexec, ...), and then attaches everything to the VFS to make it visible to other processes in the same namespace.</p><p>This is elegant, for example, when you need to set VFS flags in multiple steps. You can now set only the node in one step and recursively set all submounts in another step using "ro,noexec=recursive" in the new mount(8).</p><p>It also allows previously impossible operations to be mixed together. For example, "mount --move -oro /mnt/A /mnt/B".</p><p>Let's delve into the details, for example, the strace output for "mount -t ext4 -o ro /dev/sdc1 /mnt/test":</p><p>Classic mount(8):</p><pre><code class="!whitespace-pre hljs language-arduino"><span class="hljs-built_in">mount</span>(<span class="hljs-string">"/dev/sdc1"</span>, <span class="hljs-string">"/mnt/test"</span>, <span class="hljs-string">"ext4"</span>, MS_RDONLY, <span class="hljs-literal">NULL</span>);</code></pre><p>New interface:</p><div class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs language-scss"><span class="hljs-built_in">fsopen</span>("ext4", FSOPEN_CLOEXEC) = <span class="hljs-number">3</span>
<span class="hljs-built_in"> </span></code></div><div class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs language-scss"><span class="hljs-built_in">fsconfig</span>(<span class="hljs-number">3</span>, FSCONFIG_SET_STRING, "source", "/dev/sdc1", <span class="hljs-number">0</span>) = <span class="hljs-number">0</span><span class="hljs-built_in"> </span></code></div><div class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs language-scss"><span class="hljs-built_in">fsconfig</span>(<span class="hljs-number">3</span>, FSCONFIG_SET_FLAG, "ro", NULL, <span class="hljs-number">0</span>) = <span class="hljs-number">0</span> </code></div><div class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs language-scss"><span class="hljs-built_in">fsconfig</span>(<span class="hljs-number">3</span>, FSCONFIG_CMD_CREATE, NULL, NULL, <span class="hljs-number">0</span>) = <span class="hljs-number">0</span><span class="hljs-built_in"> </span></code></div><div class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs language-scss"><span class="hljs-built_in">fsmount</span>(<span class="hljs-number">3</span>, FSMOUNT_CLOEXEC, <span class="hljs-number">0</span>) = <span class="hljs-number">4</span> </code></div><div class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs language-scss"> </code></div><div class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs language-scss"><span class="hljs-built_in">mount_setattr</span>(<span class="hljs-number">4</span>,"", AT_EMPTY_PATH,{attr_set=MOUNT_ATTR_RDONLY, attr_clr=<span class="hljs-number">0</span>, propagation=<span class="hljs-number">0</span>}) = <span class="hljs-number">0</span><span class="hljs-built_in"> </span></code></div><div class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs language-scss"><span class="hljs-built_in">move_mount</span>(<span class="hljs-number">4</span>, "", AT_FDCWD, "/mnt/test", MOVE_MOUNT_F_EMPTY_PATH) = <span class="hljs-number">0</span></code><br /><p>The steps in the interface are as follows:</p><ul><li>Create a filesystem instance with fsopen()</li><li>Configure the filesystem with fsconfig()</li><li>Create a VFS node with fsmount()</li><li>Set VFS flags (e.g., read-only)</li><li>Attach the node to the tree (now it's visible to others)</li></ul><p>Nothing is perfect. This change is so significant that it will take time to make it stable for all use cases. In some cases, the responsibility also lies with the kernel because filesystem drivers have to adopt the new interface as well. For example, btrfs does not work as expected if a SELinux context is specified between mount options, and libmount uses the classic mount(2) in this case.</p><p>Another consideration (for libmount) is backward compatibility. Let's imagine you boot an old kernel without the new interface. You probably assume functional mount(8), so libmount has to detect that the new syscalls are not available and switch back to the classic mount(2).</p><p>In the future, we could improve the mount(8) command-line interface to better reflect the mount process. Currently, we mix operation requests with mount options (e.g., -o remount,bind,ro). It would be nice to differentiate between VFS and filesystem operations. For example:</p><p>VFS operation (set /mnt and subdirectories to ro, exec):</p><pre><code class="!whitespace-pre hljs language-bash"> mount modify /mnt --recursive --<span class="hljs-built_in">set</span> ro --<span class="hljs-built_in">unset</span> noexec</code></pre></div><div class="p-4 overflow-y-auto">FS operation (set superblock to ro, all instances will be ro):<pre><code class="!whitespace-pre hljs language-bash"> mount reconfigure /mnt -o ro </code></pre><p>What do you think about the "mount <oper> [options]" command-line interface?</p><p>And here are some other mount/libmount-related changes:</p><ul><li>The classic writeable /etc/mtab is dead and no longer supported. Rest in peace.</li><li>Thanks to Christian Brauner, X-mount.idmap= is now supported, allowing you to change the ownership of all files under the mount node in the user's namespace.</li><li>We often use "auto" as the filesystem type in fstab, right? :-) It means we rely on libblkid/udev. In some cases, this freedom is unwanted. The new option X-mount.auto-fstypes specifies allowed or forbidden filesystem types.</li><li>mount(8) should now be less invasive and smarter when used on systems with an automounter and unreachable network filesystems. If you're a developer, consider using <code>statx(AT_STATX_DONT_SYNC|AT_NO_AUTOMOUNT)</code> as a replacement for the classic <code>stat()</code> if you only need very basic information about a file or directory.</li></ul><p>Util-linux v2.39 is definitely not only about mount(8)/libmount:</p><ul><li>It's time to learn something new with new commands:<ul><li>blkpr(8) is a new command to run persistent reservations ioctls on a device (typically SCSI and NVMe disk).</li><li>waitpid(1) is a new command to wait for arbitrary processes.</li><li>pipesz(1) is a new command to set or examine pipe and FIFO buffer sizes.</li></ul></li><li>lsfd(1), a modern Linux-only replacement for lsof, is one of the most actively developed codes in util-linux (thanks to Masatake YAMATO). It's now more user-friendly in the NAME and TYPE columns, supports pidfd, and improves network socket reporting. Try, for example, <code>lsfd --inet -Q '(COMMAND == "systemd")'</code>.</li><li>libblkid should be more robust, and now it verifies checksums for many RAIDs and filesystems to avoid automatically mounting obsolete or broken superblocks.</li></ul><p>Significant changes have also been made to the util-linux test suite and our CI on GitHub. Thanks to Thomas Weißschuh for these and many other improvements.</p><pre><code class="!whitespace-pre hljs language-bash"> </code></pre></div><div class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs language-scss"><span class="hljs-number"> </span></code></div><div class="p-4 overflow-y-auto"><code class="!whitespace-pre hljs language-scss"><span class="hljs-number"> </span>
</code></div><pre><code class="!whitespace-pre hljs language-arduino"> </code></pre><pre><code class="!whitespace-pre hljs language-vbnet"> </code></pre>Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-7921326074980135918.post-1393792321083321232019-06-25T14:27:00.000+02:002019-06-25T14:27:38.364+02:00util-linux v2.34 -- what's new?The code of the popular command <span style="font-family: "courier new" , "courier" , monospace;">lsblk(8)</span> has been completely rewritten. The result is more extendible and readable code. Now <span style="font-family: "courier new" , "courier" , monospace;">lsblk(8)</span> keeps all block devices tree in memory before it's printed. It allows to modify and reorder the tree independently on the way how kernel (/sys filesystem) exports the tree to userspace. The new features based on this change are:<br />
<ul>
<li>devices de-duplication (e.g. <span style="font-family: "courier new" , "courier" , monospace;">lsblk --dedup WWN</span>); this is useful for example on systems with multi-path devices where the same device is accessible by more ways</li>
<li>M:N relationships without repeating devices (e.g. <span style="font-family: "courier new" , "courier" , monospace;">lsblk --merge</span>); this feature is implemented by additional tree graph.</li>
</ul>
For example visualization of really complicated setup; thin provisioning pool with external snapshot (the pool is based on loop0 and it's created by metadata and data devices; the pool and loop1 are used for the snapshot).<br />
<br />
<pre>$ lsblk --merge
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop0 7:0 0 955.7M 0 loop
┌┈▶ ├─test-thin-metadata 253:0 0 2M 0 dm
└┬▶ └─test-thin-data 253:1 0 953.7M 0 dm
┌┈▶ └┈┈test-thin-pool 253:2 0 953.7M 0 dm
┆ └─test-thin 253:3 0 190.8M 0 dm
└┬▶ loop1 7:1 0 190.8M 0 loop
└┈┈┈┈┈test-thin-extsnap 253:4 0 190.8M 0 dm
</pre>
<br />
The same situation with classic lsblk output:<br />
<br />
<pre>$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop0 7:0 0 955.7M 0 loop
├─test-thin-metadata 253:0 0 2M 0 dm
│ └─test-thin-pool 253:2 0 953.7M 0 dm
│ ├─test-thin 253:3 0 190.8M 0 dm
│ └─test-thin-extsnap 253:4 0 190.8M 0 dm
└─test-thin-data 253:1 0 953.7M 0 dm
└─test-thin-pool 253:2 0 953.7M 0 dm
├─test-thin 253:3 0 190.8M 0 dm
└─test-thin-extsnap 253:4 0 190.8M 0 dm
loop1 7:1 0 190.8M 0 loop
└─test-thin-extsnap 253:4 0 190.8M 0 dm
</pre>
<br />
You can see that lsblk repeating test-thin and test-thin-extsnap, and loop1 seems unrelated for the setup at first glance.<br />
<br />
The repeating of the block devices in the output is more annoying for multi-path devices. See another example in my previous blog: <a href="https://karelzak.blogspot.com/2018/11/lsblk-merge.html">https://karelzak.blogspot.com/2018/11/lsblk-merge.html</a><br />
<br />
I guess that FUSE user will be very happy with v2.34; finally the command <span style="font-family: "courier new" , "courier" , monospace;">umount(8)</span> supports non-root user unmount for FUSE mounts. The requirement is FUSE specific <span style="font-family: "courier new" , "courier" , monospace;">user_id=<uid></uid></span> in <span style="font-family: "courier new" , "courier" , monospace;">/proc/self/mountinfo</span> for the filesystem. So, you do not have to call fuse specific umount tool, just use <span style="font-family: "courier new" , "courier" , monospace;">umount(8)</span> as usually.<br />
<br />
The command <span style="font-family: "courier new" , "courier" , monospace;">mount(8)</span> now allows to use "<span style="font-family: "courier new" , "courier" , monospace;">--all -o remount</span>" to remount all filesystems with specified or fstab options. It's possible to use filters (-t and -O).<br />
<br />
The new command <span style="font-family: "courier new" , "courier" , monospace;">hardlink</span> has been merged to util-linux. The command consolidates duplicate files via hardlinks. The current implementation is from Fedora, but in the next versions we will reuse also code from Debian fork to create one widely usable implementation.<br />
<br />
The command <span style="font-family: "courier new" , "courier" , monospace;">lscpu(1)</span> now prints more information about your CPU, for example 'Frequency boost' and 'Vulnerability' fields. The caches calculation has been modified to print summary from all system caches rather than per code numbers; and new command line option <span style="font-family: "courier new" , "courier" , monospace;">--caches</span> lists details about CPU caches.<br />
<br />
... and many another small changes :-) See complete release notes at kernel.org: <a href="https://mirrors.edge.kernel.org/pub/linux/utils/util-linux/v2.34/v2.34-ReleaseNotes">https://mirrors.edge.kernel.org/pub/linux/utils/util-linux/v2.34/v2.34-ReleaseNotes</a><br />
<br />
Thanks to Sami Kerola, Stanislav Brabec, Ruediger Meier and others!Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7921326074980135918.post-83488119752391103862018-11-08T12:32:00.001+01:002018-11-08T12:32:30.122+01:00lsblk --mergeFor 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.<br />
<br />
Now lsblk blindly follows slaves/holders links in /sys and in case of RAIDs or multi-path devices the output contains duplicate lines.<br />
<br />
The new version will provide de-duplication (lsblk --dedup WWN) to completely remove unnecessary lines from output.<br />
<br />
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.<br />
<br />
See the next example with one multi-path device and one RAID device.<br />
<br />
<pre>$ 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
</pre>
<br />
The original lsblk output:
<br />
<pre> </pre>
<pre>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
</pre>
<br />
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.)Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-7921326074980135918.post-67902362058150235522018-02-15T14:37:00.000+01:002018-02-15T14:37:47.268+01:00util-linux v2.32 -- what's new?This release (rc1 now) is without dramatic changes and game-changing improvements.<br />
<br />
We have again invested our time and love to make <span style="font-family: "Courier New", Courier, monospace;">cal(1)</span> more usable. The most
visible change is possibility to specify calendar system.<br />
<br />
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 <span style="font-family: "Courier New", Courier, monospace;">cal(1)</span> for old dates before 1752 and you don't want to follow UK calendar.<br />
<br />
The new command line option<span style="font-family: "Courier New", Courier, monospace;"> --reform={Julian,Gregorian,iso,1752,...}</span> 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.).<br />
<br />
<br />
<br />
Linux kernel supports multi-line log messages. Unfortunately, <span style="font-family: "Courier New", Courier, monospace;">dmesg(1)</span> support
for this feature was insufficient. Now <span style="font-family: "Courier New", Courier, monospace;">dmesg(1)</span> provides better support and by
new command line option <span style="font-family: "Courier New", Courier, monospace;">--force-prefix</span> allows to to print facility, level or
timestamp information to each line of a multi-line message.<br />
<br />
The command <span style="font-family: "Courier New", Courier, monospace;">fallocate(1) --dig-holes</span> has been significantly improved and it's
faster more effective now (thanks to Vaclav Dolezal).<br />
<br />
The command <span style="font-family: "Courier New", Courier, monospace;">lscpu(1)</span> provides more details about ARM CPUs now.<br />
<br />
The command <span style="font-family: "Courier New", Courier, monospace;">lsmem(1)</span> supports memory zones now.<br />
<br />
The command <span style="font-family: "Courier New", Courier, monospace;">lsns(8)</span> provides netnsid and nsfs columns now. <span style="font-family: "Courier New", Courier, monospace;">ip(1) </span>command allows
to create network namespace, add logical name and ID for the namespace. Now all is visible by <span style="font-family: "Courier New", Courier, monospace;">lsns(8)</span>. For example copy & past from our regression tests:<br />
<br />
<pre> 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
</pre>
<br />
where <span style="font-family: "Courier New", Courier, monospace;">dd(1)</span> is running in the net namespace, and the namespace is by nsfs mounted on
/run/netns/LSNS-TEST-NETNSID-NS. See
<a href="https://raw.githubusercontent.com/karelzak/util-linux/master/tests/ts/lsns/netnsid">https://raw.githubusercontent.com/karelzak/util-linux/master/tests/ts/lsns/netnsid</a>
for more details how to use <span style="font-family: "Courier New", Courier, monospace;">ip(8)</span> to setup this namespace.<br />
<br />
The command <span style="font-family: "Courier New", Courier, monospace;">rtcwake(8)</span> 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 <span style="font-family: "Courier New", Courier, monospace;">rtcwake(8)</span>
execution.<br />
<br />
The library libblkid has been extended to support LUKS2, Micron mpool, VDO and
Atari partition table.<br />
<br />
<br />
<br />
Thanks to all 43 contributors!
<br />
<br />
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).
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7921326074980135918.post-41313852956851217032017-10-19T15:23:00.000+02:002017-10-19T15:23:04.834+02:00util-linux v2.31 -- what's new?<div style="text-align: justify;">
<span style="font-family: "courier new" , "courier" , monospace;">uuidparse</span> -- this is a new small command to get more information about UUIDs
"hash". The command provides info about UUID type, variant and time. For
example:</div>
<br />
<pre>$ (uuidgen; uuidgen -t) | uuidparse
UUID VARIANT TYPE TIME
8f251893-d33a-40f7-9bb3-36988ec77527 DCE random
66509634-b404-11e7-aa8e-7824af891670 DCE time-based 2017-10-18 15:01:04,751570+0200
</pre>
<br />
<div style="text-align: justify;">
The command <span style="font-family: "courier new" , "courier" , monospace;">su</span> has been refactored and extended to create pseudo terminal for
the session (new option <span style="font-family: "courier new" , "courier" , monospace;">--pty</span>). The reason is CVE-2016-2779, but the issue
addressed by this CVE is pretty old and all the problem is silently ignored for
for years on many places (on only <span style="font-family: "courier new" , "courier" , monospace;">su(1)</span>). The core of the problem is that
unprivileged user (within <span style="font-family: "courier new" , "courier" , monospace;">su(1)</span> session) shares terminal file descriptor with
original root's session. The new option <span style="font-family: "courier new" , "courier" , monospace;">--pty</span> forces <span style="font-family: "courier new" , "courier" , monospace;">su(1)</span> to create
independent pseudo terminal for the session and than <span style="font-family: "courier new" , "courier" , monospace;">su(1)</span> works as proxy
between the terminals. The feature is experimental and not enabled by default
(you have to use <span style="font-family: "courier new" , "courier" , monospace;">su --pty</span>).
</div>
<br />
standard su session (all on pts/0):<br />
<pre>
24909 pts/0 S 0:02 \_ -bash
13607 pts/0 S 0:00 \_ su - kzak
13608 pts/0 S 0:00 \_ -bash
13679 pts/0 R+ 0:00 \_ ps af
</pre>
<br />
su --pty session (root pts/0; user pts/5):<br />
<pre>
24909 pts/0 S 0:02 \_ -bash
13857 pts/0 S+ 0:00 \_ su --pty - kzak
13858 <b>pts/5</b> Ss 0:00 \_ -bash
13921 <b>pts/5</b> R+ 0:00 \_ ps af
</pre>
<br />
<div style="text-align: justify;">
<span style="font-family: "courier new" , "courier" , monospace;">rfkill</span> -- this is a new command in util-linux. The command was originally
written by Johannes Berg and Marcel Holtmann and maintained for years as
standalone package. We believe that it's better to maintain and distribute it
with another commands on one place. The util-linux version is backwardly
compatible with the original implementations. The command has been also improved
(libsmartcols ouotput, etc.), the new default output:</div>
<pre># rfkill
ID TYPE DEVICE SOFT HARD
0 bluetooth tpacpi_bluetooth_sw unblocked unblocked
1 wlan phy0 unblocked unblocked
4 bluetooth hci0 blocked unblocked
</pre>
<br />
<div style="text-align: justify;">
The library libuuid and command <span style="font-family: "courier new" , "courier" , monospace;">uuidgen</span> support hash-based UUIDs v3 (md5) and
v5 (sha1) as specified by RFC-4122 now. The library also provides UUID templates
for dns, url, oid, or x500. For example:</div>
<pre>
$ uuidgen --sha1 --namespace @dns --name foobar.com
e361e3ab-32c6-58c4-8f00-01bee1ad27ec
</pre>
<br />
and it's expected to use v3 and v5 UUIDs as hierarchy, so you can use this UUID (or arbitrary other UUID)
as a namespace:<br />
<pre>
$ uuidgen --sha1 --namespace e361e3ab-32c6-58c4-8f00-01bee1ad27ec --name mystuff
513f905c-7df2-5afa-9470-4e82382dbf00
</pre>
<br />
<div style="text-align: justify;">
I can imagine system where for example per-user or per-architecture partition
UUIDs are based on this system. For example use UUID specific for the system root as <span style="font-family: "courier new" , "courier" , monospace;">--namespace</span> and username as <span style="font-family: "courier new" , "courier" , monospace;">--name</span>, or so. </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<span style="font-family: "courier new" , "courier" , monospace;">wipefs</span> and <span style="font-family: "courier new" , "courier" , monospace;">libblkid</span> have been improved to provide all possible string
permutations for a device. It means that wipefs does not return the first
detected signature, but it continues and tries another offsets for the
signature. This is important for filesystems and partitions tables where the
superblock is backuped on multiple places (e.g. GPT) or detectable by multiple
independent ways (FATs). This all is possible without a device modification
(the old version provides the same, but only in "wipe" mode). </div>
<br />
<div style="text-align: justify;">
The <span style="font-family: "courier new" , "courier" , monospace;">libfdisk</span> has been extended to use BLKPG ioctls to inform the kernel about
changes. This means that <span style="font-family: "courier new" , "courier" , monospace;">cfdisk</span> and <span style="font-family: "courier new" , "courier" , monospace;">fdisk</span> will not force your kernel to reread
all of the partition table, but untouched partitions may remain mounted and used
by the system. The typical use-case is resizing the last partition on the system
disk. </div>
<br />
You can use <span style="font-family: "courier new" , "courier" , monospace;">cfdisk</span> to resize a partition. Yep, cool.<br />
<br />
<div style="text-align: justify;">
The <span style="font-family: "courier new" , "courier" , monospace;">hwclock</span> command now significantly reduces system shutdown times by not
reading the RTC before setting it (except when the <span style="font-family: "courier new" , "courier" , monospace;">--update-drift </span>option is
used). This also mitigates other potential shutdown and RTC setting problems
caused by requiring an RTC read.</div>
<br />
<br />
<br />Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7921326074980135918.post-62656357763324533872017-06-09T10:03:00.000+02:002017-06-09T10:03:03.544+02:00util-linux v2.30 -- what's new?The command <b><span style="font-family: "courier new" , "courier" , monospace;">tailf</span></b> is dead thing. (RIP ... years ago I had nice time to improve it with inotify:) You have to use "tail -f" from coreutils project.
<br />
<br />
<b><span style="font-family: "courier new" , "courier" , monospace;">blkzone</span></b> -- this new command is excellent example of the open source collaboration. The command has been developed by people from WD, Seagate and SanDisk (thanks to Shaun Tancheff, Damien Le Moal and others). The goal is to have command line interface to run zone commands on block devices that support Zoned Block Commands (ZBC) or Zoned-device ATA Commands (ZAC). For now the supported zone commands are "reset" and "report". See <a href="http://www.storagereview.com/methods_of_smr_data_management">http://www.storagereview.com/methods_of_smr_data_management</a> for more details about zones.<br />
<br />
<b><span style="font-family: "courier new" , "courier" , monospace;">fincore</span></b> (file in core)-- this is nice useful command to get information about
number of memory pages used by file content. For example my fulltext email DB:<br />
<br />
<pre># fincore ~/Mail/Maildir/.notmuch/xapian/*.DB
RES PAGES SIZE FILE
60.1M 15392 4.6G /home/kzak/Mail/Maildir/.notmuch/xapian/position.DB
687.4M 175982 3.5G /home/kzak/Mail/Maildir/.notmuch/xapian/postlist.DB
328K 82 18.6M /home/kzak/Mail/Maildir/.notmuch/xapian/record.DB
190.5M 48758 2.1G /home/kzak/Mail/Maildir/.notmuch/xapian/termlist.DB
</pre>
<br />
Fortunately RAM is cheap :) Thanks to Masatake Yamato from Red Hat.<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;"><b>lsmem</b></span> (list memory) and <span style="font-family: "courier new" , "courier" , monospace;"><b>chmem</b></span> (change memory) -- another new commands. The commands have been originally
implemented in Perl for s390-tools, now re-implemented in C in more generic way
and to be usable on another architectures too. (thanks to Clemens von Mann and Heiko
Carstens from IBM.)<br />
<br />
The command <span style="font-family: "courier new" , "courier" , monospace;"><b>fallocate</b></span> supports an "insert range" operation now.<br />
<br />
We continue on <b><span style="font-family: "courier new" , "courier" , monospace;">hwclock</span></b> cleanup, some things in the code have been simplified,
dead and useless things removed. (thanks to J William Piggott)<br />
<br />
The code behind "<span style="font-family: "courier new" , "courier" , monospace;"><b>column -t|--table</b></span>" uses libsmartcols now. This change
dramatically increased number of available features for table formatting. Now
it's possible to define header for columns, truncate text in cells, align text
to the right, change order of columns, JSON output or create tree-like output.
Now almost all libsmartcols features are available on command line, example:
<br />
pstree-like output:<br />
<br />
<pre> $ ps -h -o pid,ppid,comm | column --table --tree 3 --tree-id 1 --tree-parent 2 --table-hide 2 --table-right 1
1799 bash
2254 bash
28427 └─mutt
4263 └─vim
7409 bash
10641 └─man
10657 └─less
16775 bash
11486 ├─ps
11487 └─column
</pre>
<br />
diskstat:
<br />
<pre>
$ column /proc/diskstats --table --table-columns MAJ,MIN,NAME,READ-COMP,\
READ-MERG,READ-SECS,READ-TIME,WRITE-COMP,WRITE-MERG,WRITE-SECS,\
WRITE-TIME,IO-CURR,IO-TIME,WTIME \
--table-hide MAJ,MIN \
--table-right 4,5,6,7,8,9,10,11,12,13,14 \
NAME READ-COMP READ-MERG READ-SECS READ-TIME WRITE-COMP WRITE-MERG WRITE-SECS WRITE-TIME IO-CURR IO-TIME WTIME
sda 13486466 149085 1288469300 9715620 45556082 7788088 1600182109 150180178 0 12935701 159902109
sda1 463 170 19002 131 91 0 161 331 0 334 462
sda2 778 16 63140 276 434 261 507574 12616 0 2382 12889
sda3 10710224 109592 1052352266 8018950 43983768 7022717 1153182094 126210185 0 11002854 134299501
sda4 1630396 32476 67166050 1039837 1197142 665798 343331344 23264993 0 2148041 24306932
sda5 1140435 241 168747746 655625 225373 73891 102920032 637906 0 627834 1293105
sda6 3703 6590 99512 691 4691 25421 240904 8418 0 6402 9108
sdb 448 0 22506 3088 1887 4 128 275 0 1449 3363
sdb1 404 0 19370 3035 12 4 128 60 0 1187 3095
loop0 22086 0 347311 2025 10738 0 844888 2226 0 1129 4265
loop1 947 0 26940 325 1100 0 133316 734 0 411 1058
md8 0 0 0 0 0 0 0 0 0 0 0
</pre>
<br />
<br />
passwd in JSON:
<br />
<pre>
$ grep -v nologin /etc/passwd | \
column --separator : --table --table-name passwd --json \
--table-columns USERNAME,PWD,UID,GID,GECOS,HOME,SHELL \
--table-hide PWD
{
"passwd": [
{"username": "root", "uid": "0", "gid": "0", "gecos": "root", "home": "/root", "shell": "/bin/bash"},
{"username": "sync", "uid": "5", "gid": "0", "gecos": "sync", "home": "/sbin", "shell": "/bin/sync"},
{"username": "shutdown", "uid": "6", "gid": "0", "gecos": "shutdown", "home": "/sbin", "shell": "/sbin/shutdown"},
{"username": "halt", "uid": "7", "gid": "0", "gecos": "halt", "home": "/sbin", "shell": "/sbin/halt"},
{"username": "kzak", "uid": "1000", "gid": "1000", "gecos": "Karel Zak,Home,,,", "home": "/home/kzak", "shell": "/bin/bash"},
{"username": "gamer", "uid": "1001", "gid": "1001", "gecos": null, "home": "/home/gamer", "shell": "/bin/bash"},
{"username": "test", "uid": "1002", "gid": "1002", "gecos": null, "home": "/home/test", "shell": "/bin/bash"}
]
} </pre>
<pre> </pre>
<br />
findmnt-like output:
<br />
<pre> </pre>
<pre> $ column /proc/self/mountinfo \
--table-columns ID,PARENT,MAJMIN,ROOT,TARGET,VFS-OPTS,PROP,SEP,TYPE,SOURCE,FS-OPTS \
--table-hide=SEP,ID,PARENT,ROOT,PROP,FS-OPTS,MAJMIN \
--table-order TARGET,SOURCE,TYPE,VFS-OPTS \
--tree TARGET \
--tree-id ID \
--tree-parent PARENT
TARGET SOURCE TYPE VFS-OPTS
/ /dev/sda4 ext4 rw,relatime
├─/sys sysfs sysfs rw,nosuid,nodev,noexec,relatime
│ ├─/sys/kernel/security securityfs securityfs rw,nosuid,nodev,noexec,relatime
│ ├─/sys/fs/cgroup tmpfs tmpfs ro,nosuid,nodev,noexec
│ │ ├─/sys/fs/cgroup/systemd cgroup cgroup rw,nosuid,nodev,noexec,relatime
│ │ ├─/sys/fs/cgroup/blkio cgroup cgroup rw,nosuid,nodev,noexec,relatime
│ │ ├─/sys/fs/cgroup/cpu,cpuacct cgroup cgroup rw,nosuid,nodev,noexec,relatime
│ │ ├─/sys/fs/cgroup/devices cgroup cgroup rw,nosuid,nodev,noexec,relatime
│ │ ├─/sys/fs/cgroup/hugetlb cgroup cgroup rw,nosuid,nodev,noexec,relatime
│ │ ├─/sys/fs/cgroup/pids cgroup cgroup rw,nosuid,nodev,noexec,relatime
│ │ ├─/sys/fs/cgroup/memory cgroup cgroup rw,nosuid,nodev,noexec,relatime
│ │ ├─/sys/fs/cgroup/cpuset cgroup cgroup rw,nosuid,nodev,noexec,relatime
... and so on ... </pre>
<pre> </pre>
<pre> </pre>
Thanks to all contributors. The next version v2.31 is planned for September 2017.
Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-7921326074980135918.post-19456857849926114152017-01-06T19:02:00.000+01:002017-01-06T19:05:02.316+01:0010 years with util-linux project!I can't believe that it's already 10 years we have active community around basic Linux utils.<br />
<br />
Yes, we had util-linux before (and many thanks to <i>Adrian Bunk</i> and <i>Andries E. Brouwer</i>), but I believe that with git and close collaboration between Linux distributions and Linux kernel community it better now :-)<br />
<ul>
<iframe allowfullscreen="" class="YOUTUBE-iframe-video" data-thumbnail-src="https://i.ytimg.com/vi/YcG6hHGD-78/0.jpg" frameborder="0" height="266" src="https://www.youtube.com/embed/YcG6hHGD-78?feature=player_embedded" style="clear: right; float: right;" width="320"></iframe>
<li>~11000 commits</li>
<li>~460 unique contributors</li>
<li>~630 regression tests</li>
<li>~100 utils, 5 shared libs with public API</li>
<li>~16 major releases (from v2.13 to v2.29)</li>
<li>~26 translated languages</li>
<li>~10000 e-mails on mailing list</li>
<br />
<li>ported to GNU Hurd, FreeBSD and XOS</li>
<li>used by all mainstream Linux distros (as well as by Systemd haters ;-)</li>
<li>modern autotools based build system</li>
<br />
<li>merges from another projects </li>
<ul>
<li>libblkid, libuuid and fsck from e2fsprogs</li>
<li>sulogin, last, utmpdump and mounpoint from sysvinit</li>
<li>su from coreutils </li>
</ul>
<br />
<li>many new utils (lsblk, findmnt, wipefs, rtcwake, unshare, nsenter, prlimit, blkdiscard, flock, fstrim, ipcmk, ldattach, lscpu, lsipc, lslocks, lslogins, resizepart, setarch, setpriv, switch_root, swaplabel) </li>
<br />
<li>many rewrites (libblkid probing code, mount, fdisks, etc.) </li>
<br />
<li>new shared libraries</li>
<ul>
<li>libmount</li>
<li>libfdisk</li>
<li>libsmartcols</li>
</ul>
</ul>
<br />
...the first original announce: <a href="https://lkml.org/lkml/2006/12/18/12">https://lkml.org/lkml/2006/12/18/12</a>
<br />
<br />
... gource video with all the ten years <a href="https://youtu.be/YcG6hHGD-78">https://youtu.be/YcG6hHGD-78</a> :-)<br />
<br />
Thanks to all contributors! <br />
<br />
<br />Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7921326074980135918.post-89839606335922043342016-10-06T15:24:00.000+02:002016-10-07T01:18:53.496+02:00util-linux v2.29 -- what's new?<div style="text-align: justify;">
The release v2.29 (now rc1) is without dramatical changes, the small exception
is libsmartcols where we have many improvements. </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
The old good <b>cal(1)</b> is more user-friendly now. It's possible to specify month
by name (e.g. "cal January 2017") and use relative placeholders, for example:</div>
<br />
<pre> cal now
cal '1 year ago'
cal '+2 months'
</pre>
<br />
<div style="text-align: justify;">
<b>fdisk(8)</b> allows to wipe newly created partitions -- the feature is possible to
control by new command line option --wipe-partitions[==auto|never|default]. </div>
<div style="text-align: justify;">
The
default in the interactive mode is to ask user when a filesystem or RAID signature
is detected. The goal is to be sure that new block devices are usable without
any collisions and extra wipefs(8) step (because users are lazy and mkfs-like
programs are often no smart enough to wipe the device). </div>
<br />
<div style="text-align: justify;">
<b>findmnt --verify</b> is probably the most attractive new feature for admins. The
command scans /etc/fstab and tries to verify the configuration. The traditional
way is to use "mount -a" for this purpose, but it's overkill. The new --verify
does not call mount(2), but it checks parsability, LABEL/UUID/etc.
translation to paths, mountpoints order, support for specified FS types.
The option --verify together with --verbose provides many details. </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
For example my ext4 filesystems:</div>
<br />
<pre># findmnt --verify --verbose -t ext4
/
[ ] target exists
[ ] LABEL=ROOT translated to /dev/sda4
[ ] source /dev/sda4 exists
[ ] FS type is ext4
[W] recommended root FS passno is 1 (current is 2)
/boot
[ ] target exists
[ ] UUID=c5490147-2a6c-4c8a-aa1b-33492034f927 translated to /dev/sda2
[ ] source /dev/sda2 exists
[ ] FS type is ext4
/home
[ ] target exists
[ ] UUID=196972ad-3b13-4bba-ac54-4cb3f7b409a4 translated to /dev/sda3
[ ] source /dev/sda3 exists
[ ] FS type is ext4
/home/misc
[E] unreachable on boot required target: No such file or directory
[ ] UUID=e8ce5375-29d4-4e2f-a688-d3bae4b8d162 translated to /dev/sda5
[ ] source /dev/sda5 exists
[ ] FS type is ext4
0 parse errors, 1 error, 1 warning
</pre>
<br />
<br />
<div style="text-align: justify;">
When you create multiple loop block devices from
one backing file then Linux kernel does not care about possible collisions
and the same on-disk filesystem is maintained by multiple independent in-memory
filesystem instances. The result is obvious -- data lost and filesystem damage.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Now <b>mount(8)</b> rejects requests to create another device and mount filesystem for the same backing file.
The command <b>losetup --nooverlap</b> reuse loop device if already exists for the
same backing file. All the functionality calculate with offset and sizelimit
options of course, so it's fine to have multiple regions (partitions) in the same image file and mount all of them in the same time. The restriction is that the regions should not overlap. Thanks to Stanislav Brabec from Suse! </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Heiko Carstens from IBM (thanks!) has improved <b>lscpu(1)</b> for s390. Now it supports
"drawer" topology level, static and dynamic MHz, machine type and a new option
--physical. </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
The most important <b>libsmartcols</b> change is probably better support for
multi-line cells. Now the library supports custom cell wrap functions -- this
allows to wrap your text in cells after words, line breaks, etc.
See multi-line cells (WRAPNL column) output: </div>
<br />
<pre>TREE ID PARENT WRAPNL
aaaa 1 0 aaa
├─bbb 2 1 bbbbb
│ ├─ee 5 2 hello
│ │ baby
│ └─ffff 6 2 aaa
│ bbb
│ ccc
│ ddd
├─ccccc 3 1 cccc
│ │ CCCC
│ └─gggggg 7 3 eee
│ ├─hhh 8 7 fffff
│ │ └─iiiiii 9 8 g
│ │ hhhhh
│ └─jj 10 7 ppppppppp
└─dddddd 4 1 dddddddd
DDDD
DD
</pre>
<br />
<div style="text-align: justify;">
The another change is support for user defined padding chars; we use this feature
for LIBSMARTCOLS_DEBUG_PADDING=on|off, for example: </div>
<br />
<pre> $ LIBSMARTCOLS_DEBUG=all LIBSMARTCOLS_DEBUG_PADDING=on findmnt 2> /dev/null
</pre>
<br />
<div style="text-align: justify;">
For me really important is that we have regression tests for all libsmartcols
table and tree formatting code now :-) </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Igor Gnatenko from Red Hat (thanks!) continues to work on Python binding for
libsmartcols, see <a href="https://github.com/ignatenkobrain/python-smartcols">https://github.com/ignatenkobrain/python-smartcols</a> and see example below.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
The idea
is to use libsmartcols as output formatter for Fedora/RHEL dnf (package manager
for RPM-based Linux distributions, yum replacement). This is also reason why
libsmartcols has been massively extended and improved in the last releases. </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
That's all. Thanks also to Werner Fink, Sami Kerola, Ruediger Meier and many others contributors! </div>
<br />
<pre>#!/bin/python3
import smartcols
tb = smartcols.Table()
name = tb.new_column("NAME")
name.tree = True
age = tb.new_column("AGE")
age.right = True
ggf = tb.new_line()
ggf[name] = "John"
ggf[age] = "70"
gfa = tb.new_line(ggf)
gfa[name] = "Donald"
gfa[age] = "50"
fa = tb.new_line(gfa)
fa[name] = "Benny"
fa[age] = "30"
ln = tb.new_line(fa)
ln[name] = "Arlen"
ln[age] = "5"
ln = tb.new_line(fa)
ln[name] = "Gerge"
ln[age] = "7"
fa = tb.new_line(gfa)
fa[name] = "Berry"
fa[age] = "32"
ln = tb.new_line(ggf)
ln[name] = "Alex"
ln[age] = "44"
print(tb)</pre>
<pre> </pre>
<pre>NAME AGE
John 70
├─Donald 50
│ ├─Benny 30
│ │ ├─Arlen 5
│ │ └─Gerge 7
│ └─Berry 32
└─Alex 44
</pre>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7921326074980135918.post-50202705742934137572016-03-22T12:40:00.002+01:002016-03-22T12:42:35.702+01:00util-linux v2.28 -- what's new?The release v2.28 does not contain any dramatical changes and huge
improvements. It's another release to keep users happy and absorb new features
provided by kernel. We all love this kind of release, right? :-)<br />
<br />
The fdisk programs (<span style="font-family: "courier new" , "courier" , monospace;">sfdisk</span>, <span style="font-family: "courier new" , "courier" , monospace;">cfdisk</span> and <span style="font-family: "courier new" , "courier" , monospace;">fdisk</span>) have been improved to wipe old filesystem, RAID and
partition tables from the device before libfdisk writes a new partition table.<br />
<br />
The fdisk-like programs traditionally care about begin of the device, but it's
insufficient. This new feature has been introduced to avoid collisions between
new partition table and old unwanted signatures and it's possible to control
it by <span style="font-family: "courier new" , "courier" , monospace;">--wipe[=auto|never|always]</span>. For backward compatibility on non-terminals
(non interactive fdisk execution) the feature is disabled by default.<br />
<br />
We have a new command <span style="font-family: "courier new" , "courier" , monospace;"><b>lsns</b></span>, see <a href="http://karelzak.blogspot.cz/2015/12/lsns8-new-command-to-list-linux.html">http://karelzak.blogspot.cz/2015/12/lsns8-new-command-to-list-linux.html</a>
and <span style="font-family: "courier new" , "courier" , monospace;">sfdisk</span> provides new functionality, see: <a href="http://karelzak.blogspot.cz/2015/09/whats-cooking-in-sfdisk-for-v228.html">http://karelzak.blogspot.cz/2015/09/whats-cooking-in-sfdisk-for-v228.html</a><br />
<br />
Linux kernel 3.14 is really not a hot news, but standard Linux userspace still does not
support DEADLINE scheduler. <span style="font-family: "courier new" , "courier" , monospace;">chrt</span> since v2.28 supports the DEADLINE scheduling class and
the new options --sched-runtime --sched-period and --sched-deadline.<br />
<br />
The command <span style="font-family: "courier new" , "courier" , monospace;">logger</span> supports RFC 5424 structured data through the new options
--sd-id and --sd-param. For example:<br />
<pre> logger --rfc5424 --sd-id zoo@123 \
--sd-param tiger=\"hungry\" \
--sd-param zebra=\"running\" \
--sd-id manager@123 \
--sd-param onMeeting=\"yes\" \
"this is message"
</pre>
produces:
<br />
<pre> <13>1 2015-10-01T14:07:59.168662+02:00 ws kzak - - [timeQuality tzKnown="1" isSynced="1" syncAccuracy="218616"][zoo@123 tiger="hungry" zebra="running"][manager@123 onMeeting="yes"] this is message
</pre>
<br />
The library <span style="font-family: "courier new" , "courier" , monospace;">libsmartcols</span> has been massively improved (thanks to Igor Gnatenko
for testing and reviews). Now it's possible to specify title for table, table
supports multi-line cells, it's possible to print subset of table and the
library supports continuous printing.<br />
<br />
Igor works on Python binding, it's
available at <a href="https://github.com/ignatenkobrain/python-smartcols">https://github.com/ignatenkobrain/python-smartcols</a>.<br />
<br />
The portability of the util-linux package is not our primary goal, but in many
cases port code to the another libc or another operation system (if possible)
is a way how to detect code disadvantages, obsolete functions etc. v2.28 is
possible to compile on OSX and improved has been also support for kFreeBSD and GNU Hurd (of
course you cannot compile Linux specific stuff, but build-system is smart
enough to automatically disable utils irrelevant for your OS).<br />
<br />
This is in
connection with our regression tests suite, where many things have been
improved to make the tests more stable in all random environments.
(thanks to Ruediger Meier).<br />
<br />
The complete list of all changes (~480 patches) is at
<br />
<a href="http://ftp.kernel.org/pub/linux/utils/util-linux/v2.28/v2.28-ReleaseNotes">http://ftp.kernel.org/pub/linux/utils/util-linux/v2.28/v2.28-ReleaseNotes</a><br />
<br />
and in details at:
<a href="http://ftp.kernel.org/pub/linux/utils/util-linux/v2.28/v2.28-rc1-ChangeLog">http://ftp.kernel.org/pub/linux/utils/util-linux/v2.28/v2.28-rc1-ChangeLog</a>
<br />
<br />
<b>Thanks to all (~40) contributors!</b>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7921326074980135918.post-81143449157096622882015-12-01T17:19:00.001+01:002015-12-01T17:19:36.042+01:00lsns(8) new command to list Linux namespacesThe namespaces are commonly used way how to isolate global (ipc, mount, net, ...) resource instances. Unfortunately, we have no command line tool to list namespaces. The new command lsns(8) tries to fill this gap.
<p>
Examples:<pre>
# lsns
NS TYPE NPROCS PID USER COMMAND
4026531836 pid 276 1 root /usr/lib/systemd/systemd --system --deserialize 15
4026531837 user 276 1 root /usr/lib/systemd/systemd --system --deserialize 15
4026531838 uts 276 1 root /usr/lib/systemd/systemd --system --deserialize 15
4026531839 ipc 276 1 root /usr/lib/systemd/systemd --system --deserialize 15
4026531840 mnt 269 1 root /usr/lib/systemd/systemd --system --deserialize 15
4026531857 mnt 1 63 root kdevtmpfs
4026531963 net 275 1 root /usr/lib/systemd/systemd --system --deserialize 15
4026532189 mnt 1 545 root /usr/lib/systemd/systemd-udevd
4026532390 net 1 776 rtkit /usr/libexec/rtkit-daemon
4026532478 mnt 1 776 rtkit /usr/libexec/rtkit-daemon
4026532486 mnt 1 847 colord /usr/libexec/colord
4026532518 mnt 3 6500 root -bash</pre>
and list namespace content:<pre>
# lsns 4026532518
PID PPID USER COMMAND
6500 6372 root -bash
19572 6500 root └─/usr/bin/mc -P /tmp/mc-root/mc.pwd.6500
19575 19572 root └─bash -rcfile .bashrc</pre>
help output with columns description:
<pre># lsns -h
Usage:
lsns [options] [namespace]
List system namespaces.
Options:
-J, --json use JSON output format
-l, --list use list format output
-n, --noheadings don't print headings
-o, --output list define which output columns to use
-p, --task pid print process namespaces
-r, --raw use the raw output format
-u, --notruncate don't truncate text in columns
-t, --type name namespace type (mnt, net, ipc, user, pid, uts)
-h, --help display this help and exit
-V, --version output version information and exit
Available columns (for --output):
NS namespace identifier (inode number)
TYPE kind of namespace
PATH path to the namespace
NPROCS number of processes in the namespace
PID lowers PID in the namespace
PPID PPID of the PID
COMMAND command line of the PID
UID UID of the PID
USER username of the PID
For more details see lsns(8).</pre>
The important detail is that you can see only namespaces accessible from currently mounted /proc filesystem. The lsns(8) is not able to list persistent namespaces without processes where the namespace instance is hold by bind mounts of the /proc/[pid]/ns/[type] files and the output may be affected by unshared PID namespace and unshared /proc (see unshare(8) for more details).
<p>
... it will be probably available in util-linux v2.28 (~ January 2016).
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7921326074980135918.post-78808167500518530042015-10-06T18:27:00.000+02:002015-10-06T18:27:15.443+02:00logger v2.28logger is small util to send log messages from command line. It supports
(relatively) a new systemd journal as well as classic syslog. The syslog is still
de-facto standard for enterprise admins and the latest logger version add support
for RFC5424. This RFC introduces "structured-data" and since v2.28 logger is
going to support this feature too.
<p>
The structured data is parse-able part of the message in format:<pre>
[SD-ID[@digits] SD-PARAM="value" SD-PARAM="value" ...]</pre>
for exmaple:<pre>
<13>1 2015-10-01T14:07:59.168662+02:00 ws kzak - - [timeQuality tzKnown="1" isSynced="1" syncAccuracy="218616"] message</pre>
is complete message. The message structured data contains one element with ID
"timeQuality". This is standardized element, the custom user defined elements
have to use "@digits" suffix in the ID name. It's possible to have arbitrary
number of the structured data elements.
<p>
And now this functionality is completely exported to logger command line to provide control over the elements, v2.28 is going to introduce two new options, --sd-id to specify structured data element ID and --sd-param to specify one SD-PARAM=value pair, for example:<pre>
logger --rfc5424 --sd-id zoo@123 \
--sd-param tiger=\"hungry\" \
--sd-param zebra=\"running\" \
--sd-id manager@123 \
--sd-param onMeeting=\"yes\" \
"this is message"
</pre>
produces:<pre>
<13>1 2015-10-01T14:07:59.168662+02:00 ws kzak - - [timeQuality tzKnown="1" isSynced="1" syncAccuracy="218616"][zoo@123 tiger="hungry" zebra="running"][manager@123 onMeeting="yes"] this is message</pre>
message with three SD elements: timeQuality build-in element, zoo@123 and manager@123 user defined elements.
<p>
Now all you need is smart server side or log indexing tool that understand
RFC5424 (e.g. rsyslog).Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7921326074980135918.post-24413346481898336932015-09-17T15:34:00.000+02:002015-09-17T15:37:24.331+02:00what's cooking in sfdisk for v2.28I have worked on new features for sfdisk during v2.27 stabilisation. The most user visible change is partitions resize/move improvements. Now (in git tree) sfdisk is able to move partition together with data on the partition.
Let's imagine you have disk with three partitions:<pre>
Device Start End Sectors Size Type
/dev/sdc1 2048 206847 204800 100M Linux filesystem
/dev/sdc2 206848 1230847 1024000 500M Linux filesystem
/dev/sdc3 1230848 2047966 <b>817119</b> 399M Linux filesystem</pre>
where the last partition is your ex-girlfriend /home and the first partition is almost full of pictures. Now you want to remove the last unnecessary partition and enlarge the first partition. And you don't want to lost data on the first and second partitions.
<p>
<i>(You have backup of all data, because you understand that all operations related to the partition table are risky. Right? :-)</i>
<p>
Let's delete the last partition:<pre>
# sfdisk /dev/sdc --delete 3</pre>
Now move the second partition to the end of the device. The size of the deleted sdc3 was 817119 sectors. The sfdisk expects input in format<pre>
[+]start[,[+]size[,type]]</pre>
where "+num" means offset or size relative to the original partition setting. If any number is unspecified than default is to use the current setting -- it means that "+817119" is enough. (Note that -N 2 means second partition.)<pre>
# echo '+817119' | sfdisk /dev/sdc -N 2 --move-data
...
Old situation:
Device Start End Sectors Size Type
/dev/sdc1 2048 206847 204800 100M Linux filesystem
/dev/sdc2 <b>206848</b> 1230847 1024000 500M Linux filesystem
New situation:
Device Start End Sectors Size Type
/dev/sdc1 2048 206847 204800 100M Linux filesystem
/dev/sdc2 <b>1023967</b> 2047966 1024000 500M Linux filesystem
Data move:
typescript file: /root/sfdisk-sdc2.move
old start: 206848, new start: 1023967 (move 1024000 sectors)</pre>
The important detail is <b>--move-data</b> option, it forces sfdisk after partition table modification copy data from old area to the new offsets. The source and target may overlap (sfdisk copy sectors in backward order if necessary). The file /root/sfdisk-sdc2.move is log with details about the change.
<p>
The last step is to enlarge the first partition to use all available free space (space originally used by the second partition). The string ",+" keeps start offset unchanged and the size is specified as "+" (all available space).<pre>
# echo ',+' | sfdisk /dev/sdc -N 1
...
Old situation:
Device Start End Sectors Size Type
/dev/sdc1 2048 206847 <b>204800</b> 100M Linux filesystem
/dev/sdc2 1023967 2047966 1024000 500M Linux filesystem
New situation:
Device Start End Sectors Size Type
/dev/sdc1 2048 1023966 <b>1021919</b> 499M Linux filesystem
/dev/sdc2 1023967 2047966 1024000 500M Linux filesystem</pre>
And now inform filesystem about a new space:<pre>
# resize2fs /dev/sdc1</pre>
and test all by mount:<pre>
# mount /dev/sdc1 /mnt/A
# mount /dev/sdc2 /mnt/B
# lsblk /dev/sdc
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdc 8:32 0 1000M 0 disk
├─sdc1 8:33 0 499M 0 part /mnt/A
└─sdc2 8:34 0 500M 0 part /mnt/B</pre>
Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-7921326074980135918.post-76936541374825250912015-07-23T11:31:00.000+02:002015-07-23T11:31:14.122+02:00lsipc new command to list IPC facilitiesAlthough it seems that System V IPC is obsolete thing, it's still used by many (enterprise) tools like databases, application servers etc.
</p>
The classic tool ipcs(1) provides basic overview, unfortunately the output is very fixed and it's impossible to mix the output columns (for example --pid and --creator cannot be used together etc.). It's also very difficult to extend the current implementation without break backward compatibility.
</p>
The solution is a new libsmartcols based tool: lsipc(1). It's like many another util-linux ls-like tools, columns are maintains independently, it's easy to extend, user has absolute control on the output and it provides more output formats (including JSON).
</p>
The important and unique is the default (--global) output:<pre>
# lsipc
RESOURCE DESCRIPTION LIMIT USED USE%
MSGMNI Number of message queues 32000 0 0.00%
MSGMAX Max size of message (bytes) 8192 0 0.00%
MSGMNB Default max size of queue (bytes) 16384 0 0.00%
SHMMNI Shared memory segments 4096 21 0.51%
SHMALL Shared memory pages 268435456 294049 0.11%
SEMMNS Total number of semaphores 1024000000 0 0.00%
SEMMNI Number of Semaphore IDs 32000 0 0.00%
</pre>
the information about shared memory is provided with COMMAND column, that makes things more human friendly:<pre>
# lsipc --shmem
KEY ID PERMS OWNER SIZE NATTCH STATUS CTIME CPID LPID COMMAND
0x6c6c6536 0 rw------- root 4K 0 Jul16 288 288
0x00000000 327681 rw------- kzak 4M 2 dest Jul16 1487 992 gjs /home/kzak/.local/share/gnome-shell/extensions/
0x00000000 393219 rw------- kzak 512K 2 dest Jul16 1141 2853 /usr/bin/gnome-shell
0x00000000 2064389 rw------- kzak 384K 2 dest Jul17 9443 992 xchat
0x00000000 47611910 rw------- kzak 8M 2 dest 10:07 2853 804 /usr/lib64/firefox/firefox
0x00000000 2228231 rw------- kzak 384K 2 dest Jul17 9443 992 xchat
0x00000000 2195464 rw------- kzak 2M 2 dest Jul17 9443 992 xchat
0x00000000 42303503 rw------- kzak 8M 2 dest Jul22 1340 992 /usr/bin/gnome-software --gapplication-service
0x00000000 42270736 rw------- kzak 4M 2 dest Jul22 1340 992 /usr/bin/gnome-software --gapplication-service
0x00000000 43188243 rw------- kzak 4M 2 dest Jul22 8873 1845 /usr/libexec/gnome-terminal-server
0x00000000 33882133 rw------- kzak 384K 2 dest Jul20 26049 992 /usr/bin/python3 /usr/bin/hp-systray --force-startup
</pre>
and you can define your own output:<pre>
# lsipc --shmem -o KEY,SIZE,PERMS
KEY SIZE PERMS
0x6c6c6536 4K rw-------
0x00000000 4M rw-------
0x00000000 512K rw-------
0x00000000 384K rw-------
0x00000000 8M rw-------
0x00000000 384K rw-------
0x00000000 2M rw-------
0x00000000 8M rw-------
0x00000000 4M rw-------
0x00000000 4M rw-------
0x00000000 384K rw-------
</pre>
or ask for specific segment:<pre>
# lsipc --shmem --id 47611910
Key: 0x00000000
ID: 47611910
Owner: kzak
Permissions: rw-------
Creator UID: 1000
Creator user: kzak
Creator GID: 1000
Creator group: kzak
UID: 1000
User name: kzak
GID: 1000
Group name: kzak
Last change: Thu Jul 23 10:07:46 2015
Segment size: 8M
Attached processes: 2
Status: dest
Attach time: Thu Jul 23 10:07:46 2015
Creator command: /usr/lib64/firefox/firefox
Creator PID: 2853
Last user PID: 804
</pre>
and it should be easy to export complex info about IPC to the monitoring tool:<pre>
# lsipc --json -o resource,limit,used
{
"ipclimits": [
{"resource": "MSGMNI", "limit": "32000", "used": "0"},
{"resource": "MSGMAX", "limit": "8192", "used": "0"},
{"resource": "MSGMNB", "limit": "16384", "used": "0"},
{"resource": "SHMMNI", "limit": "4096", "used": "11"},
{"resource": "SHMALL", "limit": "268435456", "used": "8097"},
{"resource": "SEMMNS", "limit": "1024000000", "used": "0"},
{"resource": "SEMMNI", "limit": "32000", "used": "0"}
]
}
</pre>
lsipc(1) will be available in util-linux v2.27 (probaly August 2015).Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7921326074980135918.post-55055412146348719992015-06-15T15:42:00.000+02:002015-06-15T15:42:23.792+02:00sfdisk --jsonAs promised by the previous blog I have merged support for JSON dump to sfdisk/libfdisk.
<pre>
# sfdisk --json /dev/sda
{
"partitiontable": {
"label": "gpt",
"id": "E471810B-5954-48E6-B4F0-5D369ADCC514",
"device": "/dev/sda",
"unit": "sectors",
"firstlba": 34,
"lastlba": 468862094,
"partitions": [
{"node": "/dev/sda1", "start": 2048, "size": 409600, "type": "C12A7328-F81F-11D2-BA4B-00A0C93EC93B", "uuid": "2062335E-51B6-49E8-BC3C-4C6D449E6805", "name": "EFI System Partition"},
{"node": "/dev/sda2", "start": 411648, "size": 409600, "type": "0FC63DAF-8483-4772-8E79-3D69D8477DE4", "uuid": "DF378D5F-B7BA-4887-BAEB-A81E48DE903D"},
{"node": "/dev/sda3", "start": 821248, "size": 273266688, "type": "0FC63DAF-8483-4772-8E79-3D69D8477DE4", "uuid": "6073277F-87BC-43FF-BCFD-724C4484A63A"},
{"node": "/dev/sda4", "start": 274087936, "size": 104857600, "type": "0FC63DAF-8483-4772-8E79-3D69D8477DE4", "uuid": "EC5A52E0-FE99-4B38-91E7-B5FF1120E0E5"},
{"node": "/dev/sda5", "start": 378945536, "size": 73531392, "type": "0FC63DAF-8483-4772-8E79-3D69D8477DE4", "uuid": "11A62EAE-5ECA-4EF5-8BF5-DD18A4115F4A"},
{"node": "/dev/sda6", "start": 452476928, "size": 16384000, "type": "0657FD6D-A4AB-43C4-84E5-0933C84B4F4F", "uuid": "A13DACFE-6FFB-4B2C-BD89-B91B768A4F77"}
]
}
}</pre>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7921326074980135918.post-76140116813389898562015-06-05T12:47:00.000+02:002015-06-05T12:49:06.429+02:00JSON output for basic toolsI have merged into libsmartcols support for JSON format. The feature is currently enabled for lsblk(8), findmnt(8), lslocks(8) and losetup(8). The library already uses structured data, so add a different output format is pretty trivial. For example findmnt(8) and lsblk(8) are able to gather much information and standardized parsable format makes it easy to use it monitoring tools, automatic bug reporting tools, etc.
<pre>
$ lsblk --json -o name,type,mountpoint
{
"blockdevices": [
{"name": "sda", "type": "disk", "mountpoint": null,
"children": [
{"name": "sda1", "type": "part", "mountpoint": "/boot/efi"},
{"name": "sda2", "type": "part", "mountpoint": "/boot"},
{"name": "sda3", "type": "part", "mountpoint": "/home"},
{"name": "sda4", "type": "part", "mountpoint": "/"},
{"name": "sda5", "type": "part", "mountpoint": "/home/wine"},
{"name": "sda6", "type": "part", "mountpoint": "[SWAP]"}
]
},
{"name": "sdb", "type": "disk", "mountpoint": null,
"children": [
{"name": "sdb1", "type": "part", "mountpoint": "/home/archive"}
]
}
]
}
</pre>
<pre>
$ findmnt --json --submounts /home
{
"filesystems": [
{"target": "/home", "source": "/dev/sda3", "fstype": "ext4", "options": "rw,relatime,data=ordered",
"children": [
{"target": "/home/wine", "source": "/dev/sda5", "fstype": "ext4", "options": "rw,relatime,data=ordered"},
{"target": "/home/archive", "source": "/dev/sdb1", "fstype": "ext4", "options": "rw,relatime,data=ordered"}
]
}
]
}
</pre>
For the next Monday my TODO contains "JSON sfdisk/libfdisk dump output"...Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7921326074980135918.post-21038392227362062972015-05-06T15:20:00.000+02:002015-05-06T15:20:44.981+02:00resize by sfdiskThe last week released util-linux v2.26.2 contains improved (fixed:-) sfdisk.
The most visible change is that the new version supports partition resize and
start offset move.
<p>
For example 1GiB disk with GPT:<pre>
echo ", +10M" | ./sfdisk -N 1 /dev/sdc
...
Old situation:
Device Start End Sectors Size Type
/dev/sdc1 2048 206847 204800 100M Linux filesystem
New situation:
Device Start End Sectors Size Type
/dev/sdc1 2048 227327 225280 <b>110M</b> Linux filesystem
</pre>
the first partition (-N 1) has been enlarged from 100MiB to 110MiB.
<p>
You can also move begin of the partition:<pre>
echo "+2M" | ./sfdisk -N 1 /dev/sdc
...
Old situation:
Device Start End Sectors Size Type
/dev/sdc1 2048 227327 225280 110M Linux filesystem
New situation:
Device Start End Sectors Size Type
/dev/sdc1 <b>6144</b> 231423 225280 110M Linux filesystem
</pre>
and it's possible to enalarge as much as possible:<pre>
echo ", +" | ./sfdisk -N 1 /dev/sdc
...
Old situation:
Device Start End Sectors Size Type
/dev/sdc1 6144 231423 225280 110M Linux filesystem
New situation:
Device Start End Sectors Size Type
/dev/sdc1 6144 2047966 2041823 <b>997M</b> Linux filesystem
</pre>
the '+' means "all available space". And vice-versa you can reduce the size of the partition;
it's possioble to specify the size in absolute numbers (without +/- signs), or
in sectors. The next example reduce size to 100MiB and move to old good offset 2048: <pre>
echo "2048,100M" | ./sfdisk -N 1 /dev/sdc
...
Old situation:
Device Start End Sectors Size Type
/dev/sdc1 6144 2047966 2041823 997M Linux filesystem
New situation:
Device Start End Sectors Size Type
/dev/sdc1 <b>2048</b> 206847 204800 <b>100M</b> Linux filesystem
</pre>
Note that fdisks are too low-level to care about filesystems when resize, it's all about partition
tables only.
Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-7921326074980135918.post-48523061878848557902015-04-14T14:59:00.001+02:002015-04-14T14:59:57.873+02:00persistent namespacesToday I merged support for persistent namespaces to <span style="font-family: "Courier New",Courier,monospace;">unshare(1)</span>. The persistent namespace does not require any running process with in the namespace and it's possible to enter the namespace by <span style="font-family: "Courier New",Courier,monospace;">nsenter(1)</span>.<br />
<br />
For example let's create a new UTS namespace and set a different hostname within the
namespace:<pre>
# hostname
ws
# touch /root/ns-uts
# unshare --uts=/root/ns-uts
# hostname FooBar
# exit
</pre>
Now there is no process in the namespace, try to enter the namespace by
<span style="font-family: "Courier New",Courier,monospace;">--uts=/root/ns-uts</span> reference:<pre>
# nsenter --uts=/root/ns-uts
# hostname
FooBar
# exit
</pre>
The reference to the namespace is bind mount to <span style="font-family: "Courier New",Courier,monospace;">/proc/[pid]/ns/[type]</span>, so
<span style="font-family: "Courier New",Courier,monospace;">umount(8)</span> is enough to remove the reference:<pre>
# umount /root/ns-uts
</pre>
If there is no another reference or any running process within the namespace
then the namesapce is destoyed.
<p/>
It's also possible to create another types of the persistent namespaces
(--net, --ipc, ...). Don't forget that if you want to create a persistent
mount namespace than the file (<span style="font-family: "Courier New",Courier,monospace;">--mount=file</span>) has to be on "<i>private</i>"
filesystem, for example on Fedora where all is "<i>shared</i>" you have
to use:<pre>
# mount --bind /mnt/test /mnt/test
# mount --make-rprivate /mnt/test
# touch /mnt/test/my-ns
# unshare --mount=/mnt/test/my-ns
...
</pre>
Note that PID namespace cannot be without a running process (or more
precisely the PID namespace is dead thing after init process (PID 1)
termination).
Unknownnoreply@blogger.com4tag:blogger.com,1999:blog-7921326074980135918.post-52923021461400173102015-03-31T11:51:00.000+02:002015-03-31T11:51:23.461+02:00cfdisk extra partition infoI have merged a new cfdisk(8) improvement. It allows to display/hide additional information about the current (selected) partition:<br />
<ul>
<li>filesystem type, LABEL, UUID<br /><br /> The important detail is that libblkid gathers the info by seeking on whole-disk device according to partition offsets from partition table -- so /dev/sda[n] devices do not have to exist or you can use cfdisk for disk images (e.g. "cfdisk file.img").</li>
<li>partition NAME, TYPE (hex/uuid and human readable name)</li>
<li>mountpoint -- for mounted filesystem as well as for not mounted (then from /etc/fstab)</li>
</ul>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhzbgLZLFExW7dxrMCWUwVUv0cHE3rGmKq_YHsHUo95VexFk8IMJ_toDU_Zcl3E2pw7RQEAGkJmmuHYvemJ_lXbmJQyBzdVsH384UghaDI5-XjfS5n366mejomIITo_5ZYVQ39486aklM/s1600/cfdisk-extra.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhzbgLZLFExW7dxrMCWUwVUv0cHE3rGmKq_YHsHUo95VexFk8IMJ_toDU_Zcl3E2pw7RQEAGkJmmuHYvemJ_lXbmJQyBzdVsH384UghaDI5-XjfS5n366mejomIITo_5ZYVQ39486aklM/s1600/cfdisk-extra.png" height="400" width="640" /></a></div>
<br />
All you need is press 'x'. <br />
<br />
The change is going to be available in util-linux v2.27 (May/Jun 2015). Thanks to Ondrej Oprala who has worked on this with me.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7921326074980135918.post-77764271692213966022014-11-14T13:49:00.004+01:002014-11-14T13:51:16.915+01:00(s)fdisk scriptsYesterday I merged support for sfdisk scripts to fdisk and cfdisk. Now it's possible to save your partitioning layout to text files and (re)use it in all fdisks.<br />
<br />
It means that you don't have to start your partitioning from scratch in programs like
cfdisk or fdisk, but you can reuse and finalize partitioning scenario already defined by sfdisk scripts. It may be attractive for DIY system installers, admins, etc.<br />
<br />
All is based on libfdisk, so the same functionality may be very easily implemented
in another tools too.<br />
<br />
It's Friday ...sooo I tried to record video with some trivial example, all is from util-linux
git tree (not yet release v2.26).<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/7cpubjTRiog?feature=player_embedded' frameborder='0'></iframe></div>
<br />Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7921326074980135918.post-15370082186002478012014-10-13T17:21:00.001+02:002014-10-14T09:58:41.749+02:00new sfdiskThe last partitioning tool from util-linux package without support for GPT (BSD, SGI, ...) and 4K disks was sfdisk. The situation was exactly the same like with cfdisk, it was impossible to incrementally improve the code, so the new version is written from scratch and based on libfdisk.<br />
<br />
The most visible change is that the new sfdisk is all about sectors, it does not support obsolete Cylinder-Head-Sector addressing at all. This is no problem for users who use "<span style="font-family: "Courier New",Courier,monospace;">--unit S</span>", but if you still rely on old default cylinders than be careful with update. Frankly, LBA addressing is mandatory since ATA-3 (1997) and supported by Linux since beginning. <br />
<br />
The new sfdisk also does not support some obscure or rarely used options like<br />
<span style="font-family: "Courier New",Courier,monospace;">--DOS, --IBM, --DOS-extended, --unhide, --show-extended, --cylinders, --heads, --sectors, --inside-outer, --not-inside-outer</span>.<br />
<br />
The last incompatibility is in backup mode. The old implementation uses sfdisk specific backup files. The new implementation uses the same concept like "wipefs --backup". The data are stored to <span style="font-family: "Courier New",Courier,monospace;">~/sfdisk-dev-offset</span><device><span style="font-family: "Courier New",Courier,monospace;"><device><offset></offset></device></span><offset><span style="font-family: "Courier New",Courier,monospace;">.bak </span>by default and it's possible to use <span style="font-family: "Courier New",Courier,monospace;">dd(1)</span> to restore your partition table or so. The backup files contains only data from the device, nothing else. For example:</offset></device><br />
<pre># sfdisk --backup /dev/sdb
...
Backup files:
PMBR (offset 0, size 512): /root/sfdisk-sdb-0x00000000.bak
GPT Header (offset 512, size 512): /root/sfdisk-sdb-0x00000200.bak
GPT Entries (offset 1024, size 16384): /root/sfdisk-sdb-0x00000400.bak
...
</pre>
and to restore:
<br />
<pre>
# dd if=~/sfdisk-sda-0x00000200.bak of=/dev/sdb \
seek=$((0x00000200.bak)) bs=1 conv=notrunc
</pre>
<br />
All is described in the sfdisk man page.
The another change is possibility to specify partition sizes in human
readable notation <size>{K,M,G,T...}, for example</size><br />
<br />
<pre># sfdisk /dev/sdb <<EOF</pre>
<pre>label: gpt</pre>
<pre>, 10G
, 10G
EOF
</pre>
<br />
creates two 10GiB partitions. <list>Note that default is to align all partitions to I/O limits (e.g. physical sector size). The first partition offset is by default 1MiB (e.g. 2048 512-byte-sectors). The partitions are by default aligned to megabytes. The same concept we use for fdisk and cfdisk (and parted probably too).<br /><br />The default is DOS (MBR) disk label. If you want to use GPT then just add "<span style="font-family: "Courier New",Courier,monospace;">--label gpt</span>" to the command line or "<span style="font-family: "Courier New",Courier,monospace;">label: gpt</span>" to the script. The partition type shortcuts like 'L' (for Linux) or 'S' (for swap area) work for MBR as well as for GPT. If you want something else then you can use GUID for GPT or hex codes for MBR.<br /><br />The new sfdisk supports nested disk labels. This is important for people who use BSD disk labels or hybrid GPT. The new command line option "<span style="font-family: "Courier New",Courier,monospace;">--label-nested dos</span>" forces sfdisk to modify protective MBR rather than the default GPT disk label. It means that you can manually create hybrid GPT. (No, we don't plan to add any "translate GPT to MBR" high-level feature for hybrid disks, hybrid GPT sucks.)<br /><br />The nice new feature is that sfdisk allows to add new partitions to your partition table rather than always create whole partition table from scratch, all you need is the new --append command line option.<br /><br />The important feature is that you can define your own output format for <span style="font-family: "Courier New",Courier,monospace;">--list</span> by new command line option <span style="font-family: "Courier New",Courier,monospace;">"--output columns</span>". sfdisk shares this new feature with fdisk where -o modifies 'p'rint output, for example:</list><br />
<list> </list><br />
<pre># sfdisk --quiet --list -o DEVICE,SIZE,TYPE /dev/sda
Device Size Type
/dev/sda1 1000M EFI System
/dev/sda2 2G Microsoft basic data
/dev/sda3 9.7G Linux swap
/dev/sda4 34.2G Microsoft basic data
/dev/sda5 63.2G Microsoft basic data
/dev/sda6 39.1G Microsoft basic data
</pre>
<br />
You probably already know this concept from lsblk or findmnt. It's also supported to extend the default output by "-o+<columns>" notation, for example
"<span style="font-family: "Courier New",Courier,monospace;">fdisk --list -o+UUID /dev/sda</span>" to see UUIDs for GPT partitions. </columns><br />
<br />
<columns>Another features:</columns><br />
<ul>
<li><columns>--part-uuid print or change GPT partition UUID</columns></li>
<li><columns>--part-type (or original --id) print or change partition type</columns></li>
<li><columns>--part-label print or changes GPT partition label (name)</columns></li>
<li><columns>--part-attrs print or change GPT partition attribute bites</columns></li>
</ul>
<br />
<columns>The script parsing and <span style="font-family: "Courier New",Courier,monospace;">--dump</span> functionality is within libfdisk. The
goal is to support partitioning dumps in fdisk and cfdisk too. It is going to
be possible to "<span style="font-family: "Courier New",Courier,monospace;">sfdisk --dump /dev/sda > foo</span>" and then read the "foo" file to
cfdisk or fdisk. And vice-versa, you can compose all your partition table by
user-friendly cfdisk, save to the script file (rather than to device) and later
use the file by sfdisk, etc.</columns>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7921326074980135918.post-85926912357446117532014-08-06T14:19:00.003+02:002014-08-06T14:19:36.600+02:00zramctlI merged <span style="font-family: "Courier New",Courier,monospace;">zramctl</span> tool a few days ago. It's based on original code from Timofey Titovets and the idea is the same as for <span style="font-family: "Courier New",Courier,monospace;">losetup(8)</span>. zRam was merged to Linux kernel 3.14; the zram devices use RAM to create compressed block devices. The <span style="font-family: "Courier New",Courier,monospace;">zramctl</span> provides user friendly command line interface to create, reset and list the devices.<br />
<br />
It's pretty simple and easy to use from userspace. See example below (kernel 3.15.7-200.fc20)<br />
<br />
<pre># modprobe zram num_devices=4
# zramctl --find --size 10M
/dev/zram0
# mkfs.ext2 -q /dev/zram0
# mount /dev/zram0 /mnt/test
./zramctl --find --size 10M --streams 2
/dev/zram1
# mkswap /dev/zram1
Setting up swapspace version 1, size = 10236 KiB
no label, UUID=776a95b7-5876-4be4-a66b-9b869cf35bd1
# swapon UUID=776a95b7-5876-4be4-a66b-9b869cf35bd1
# zramctl
NAME ALGORITHM DISKSIZE DATA COMPR TOTAL STREAMS MOUNTPOINT
/dev/zram0 lzo 10M 40K 797B 40K 1 /mnt/test
/dev/zram1 lzo 10M 4K 78B 4K 2 [SWAP]
</pre>
<br />
Note that kernel 3.14 does not support more compression streams and algorithms selection.<br />
<br />
The next step will be probably to support zram initialization in swapon(8) to<br />
make it easy for users to define swap on zram in /etc/fstab.<br />
<br />
<br />Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7921326074980135918.post-12287758665359620122014-06-20T14:19:00.000+02:002014-06-20T14:19:11.743+02:00new cfdisk (util-linux v2.25)cfdisk is a popular ncurses partitioning tool. Unfortunately, it has been ignored by developers for many many years. The original version does not a have clue<br />about 4K disks, modern disk I/O limits (alignment offset, optimal I/O sizes, etc),<br />and it was all about MBR (DOS) only.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZIe4lznhZDSiUzKLdK2LKzuqJaKMg9mb3p19tvvvx0e71cH4Va9_psZRoYDVoBQacos4nTSqeOlE_E6lLRGi_XG4ku2w_Zzs7u8hrsqthGX8eA6biwfdYAmyR6kgB-1tmXfvQljKZ2RM/s1600/cfdisk-mbr.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZIe4lznhZDSiUzKLdK2LKzuqJaKMg9mb3p19tvvvx0e71cH4Va9_psZRoYDVoBQacos4nTSqeOlE_E6lLRGi_XG4ku2w_Zzs7u8hrsqthGX8eA6biwfdYAmyR6kgB-1tmXfvQljKZ2RM/s1600/cfdisk-mbr.png" height="272" width="320" /></a></div>
<br />It was impossible to improve the old code by refactoring, so the new version is written from scratch. The new cfdisk is based on on the same code like fdisk, so it shares all the necessary features required for new disks and it supports MBR, GPT, SGI and SUN disk labels. Some features have been removed:<br />
<ul>
<li>it does not have a clue about CHS addressing any more</li>
<li>it's impossible to play any games with disk geometry (use fdisk if you believe that CHS setting makes any sense)</li>
<li>'m' command (maximize disk usage of the current partition) is not implemented</li>
<li>'p' command and --print command line option are not implemented (use partx or lsblk)</li>
<li> 'u' (units) command is not implemented, all is based on sectors or real sizes</li>
</ul>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhW9qFLO_39MM1BlVNcgvsZL3tpGL9TZppEPx3Cm4gSFoOEUcvhiVT6vAQNUiWjOADYOAHjY9OpZ8nKFebJ0dc4Wx3PY9DymJ38F1Sc3BHucruaFHgJu8F-Qz1OwiR7-QFiaxAUJ2TcPa0/s1600/cfdisk-gpt.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhW9qFLO_39MM1BlVNcgvsZL3tpGL9TZppEPx3Cm4gSFoOEUcvhiVT6vAQNUiWjOADYOAHjY9OpZ8nKFebJ0dc4Wx3PY9DymJ38F1Sc3BHucruaFHgJu8F-Qz1OwiR7-QFiaxAUJ2TcPa0/s1600/cfdisk-gpt.png" height="265" width="320" /></a></div>
The idea is to keep cfdisk pretty simple and easy to use for end users. Advanced users or users who want to do some unusual things have to use fdisk or parted.<br /><br />New features:<br />
<ul>
<li>output formatting based on libsmartcols</li>
<li>tree-like output for MBR extended and logical partitions</li>
<li>show free space on place where the gap is really located</li>
<li>colors</li>
<li>new 's'ort command to reorder partition according to start sectors</li>
<li>partitions aligned to I/O limits, 1MiB start offset, etc.</li>
<li>it's still possible to recompile with slang library (although I personallyprefer ncursesw)</li>
</ul>
<br />
For full size screenshots see <a href="https://plus.google.com/photos/111319147897550904359/albums/6026982568892198609?authkey=CIH2r6n6wpSCeg">g+</a> <br />
<br />
What next? sfdisk and stable public API fro libfdisk... let's wait for v2.26 :-)<br />
<br />
<br /><a href="https://plus.google.com/photos/111319147897550904359/albums/6026982568892198609?authkey=CIH2r6n6wpSCeg"></a>
<br />
<br />Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7921326074980135918.post-60032176255892767512014-05-30T16:32:00.000+02:002014-05-30T16:32:26.376+02:00libsmartcols - pretty output for everyone!util-linux 2.25 is going to contain <span style="font-family: "Courier New",Courier,monospace;">libsmartcols</span>. The library code is based on code originally developed for <span style="font-family: "Courier New",Courier,monospace;">lsblk(8), findmnt(8), lslocks(8)</span> etc. The goal is to share formatting code to print pretty tables and trees.<br />
<br />
Features:<br />
<ul>
<li>tree-like output (see lsblk(8) or findmnt(8))</li>
<li>table-like output (see lslocks(8))</li>
<li>formatting sensitive to terminal width</li>
<li>fully supports UTF8 (correctly truncate data in cells, tree lines, ...)</li>
<li>dynamic or fixed columns width</li>
<li>truncate data in cell on demand</li>
<li>raw (no formatting) output mode</li>
<li>NAME=value output mode</li>
<li>custom cells and lines delimiters (for example for CSV output)</li>
<li>built-in ASCII, UTF8 or custom symbols to draw trees</li>
<li>per column, line or cell colors</li>
<li>colors specified by words (e.g. "red") or ESC sequences</li>
<li>sort lines</li>
<li>enable/disable heading</li>
<li>output to FILE stream (default stdout), or to string</li>
<li>all columns, lines and cells accessible by iterators (no callbacks)</li>
<li>output data specified by strings (no crazy unions or to-string conversion functions in the library)</li>
<li>reference counting</li>
<li>integrated debug output (sensitive to LIBSMARTCOLS_DEBUG env)</li>
<li>usable to keep parent<->child relationship<!-----><!-----></-></li>
<li>library symbols versioning (no soname changes)</li>
</ul>
<br />
See bellow a trivial (so no errors handling, etc.) example.<br />
<br />
<pre>int main(void)
{
struct libscols_table *tb;
struct libscols_line *ln, *dad, *gdad;
enum { COL_NAME, COL_AGE };
setlocale(LC_ALL, "");
tb = scols_new_table();
scols_table_new_column(tb, "NAME", 0.1, SCOLS_FL_TREE);
scols_table_new_column(tb, "AGE", 2, SCOLS_FL_RIGHT);
ln = gdad = scols_table_new_line(tb, NULL);
scols_line_set_data(ln, COL_NAME, "Grandfather Bob");
scols_line_set_data(ln, COL_AGE, "61");
ln = dad = scols_table_new_line(tb, ln);
scols_line_set_data(ln, COL_NAME, "Father Adam");
scols_line_set_data(ln, COL_AGE, "38");
ln = scols_table_new_line(tb, dad);
scols_line_set_data(ln, COL_NAME, "Baby Val");
scols_line_set_data(ln, COL_AGE, "9");
ln = scols_table_new_line(tb, dad);
scols_line_set_data(ln, COL_NAME, "Baby Dilbert");
scols_line_set_data(ln, COL_AGE, "5");
ln = scols_table_new_line(tb, gdad);
scols_line_set_data(ln, COL_NAME, "Aunt Gaga");
scols_line_set_data(ln, COL_AGE, "35");
scols_print_table(tb);
scols_unref_table(tb);
return 0;
}
</pre>
<br />
... and output:<br />
<br />
<pre>NAME AGE
Grandfather Bob 61
├─Father Adam 38
│ ├─Baby Val 9
│ └─Baby Dilbert 5
└─Aunt Gaga 35 </pre>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7921326074980135918.post-54181763495897536682014-04-01T14:18:00.000+02:002014-10-14T14:33:09.722+02:00terminal-colors.dI have already talked about it at <a href="https://plus.google.com/111319147897550904359/posts/FkaCSZy6crr">g+</a>. For util-linux we don't want to follow the current strange behavior when command-line utils have disabled colors by default, but distributions use shell aliases in profile files to revert the default.<br />
<br />
It does not mean that we want ignore color blind people, obscure terminals or people who just don't like colors. The solution is to provide simple, elegant and package independent way how to control (disable) colorized output. And yes, aliases are not elegant.<br />
<br />
The next util-linux release is going to introduce /etc/terminal-colors.d directory<br />
to control colors for terminal utils. It's pretty simple:<br />
<br />
Synopsis:<br />
<pre>/etc/terminal-colors.d/[name.]disable
/etc/terminal-colors.d/name.enable
</pre>
Examples:
<br />
<ul>
<li> disable colors for all utils:
<pre># touch /etc/terminal-colors.d/disable
</pre>
</li>
<li>disable colors for dmesg(1):
<pre># touch /etc/terminal-colors.d/dmesg.disable</pre>
</li>
<li>disable colors for all utils except dmesg(1):
<pre># touch /etc/terminal-colors.d/disable
# touch /etc/terminal-colors.d/dmesg.enable</pre>
</li>
</ul>
For utils from util-linux the command line option -<span style="font-family: "Courier New",Courier,monospace;">-color[={auto,never,always}] </span>overrides the setting from terminal-colors.d (so if you for some reason love shell aliases then it's still possible...).<br />
<br />
The terminal-colors.d concept is completely open, it would be nice to see it supported in another projects (hint: gcc, grep, coreutils:-) too. It's so trivial that all you need is a few access(F_OK) calls. The thing we maintain in util-linux is terminal-colors.d.5 man page only.<br />
<br />
Maybe later for util-linux we will also use the directory (or/and copy in $HOME)
to store color schemes.<br />
<br />
Keep your Bike-sheds colorized! :-)<br />
<br />
<b>UPDATE</b>: since v2.25:<br />
<ul>
<li><span style="font-family: "Courier New",Courier,monospace;">$XDG_CONFIG_HOME/terminal-colors.d</span> or <span style="font-family: "Courier New",Courier,monospace;">$HOME/.config/terminal-colors.d</span> overrides the global setting</li>
<li>terminal-colors.d is possible to use for color schemes<br /> <span style="font-family: "Courier New",Courier,monospace;">echo 'alert 37;41' >> /etc/terminal-colors.d/dmesg.scheme</span><br />changes color used for kernel alerts in dmesg output</li>
<li>synopsis is <span style="font-family: "Courier New",Courier,monospace;">/etc/terminal-colors.d/[[name][@term].][type]</span>, it means that for example <span style="font-family: "Courier New",Courier,monospace;">/etc/terminal-colors.d/@vt100.disable</span> disables colors for all vt100 terminals</li>
<li><b>we have <a href="http://man7.org/linux/man-pages/man5/terminal-colors.d.5.html">terminal-colors.d(5)</a> man page with all details</b></li>
</ul>
Unknownnoreply@blogger.com0