date
int64
1,220B
1,719B
question_description
stringlengths
28
29.9k
accepted_answer
stringlengths
12
26.4k
question_title
stringlengths
14
159
1,487,837,187,000
From my understanding of /etc/systemd options, noauto means that the device will not be mounted at boot time (or with mount -a). Is there any situation where adding nofail changes the behaviour if noauto is already given, or is it totally redundant? man systemd.mount(5) says: With noauto, this mount will not be added...
Just for the record: For an external USB disk which is usually not connected at startup, I have an fstab entry /dev/disk/by-label/data /data xfs noauto,user,noatime 0 0 When booting there is no error as noautokeeps the system from trying to mount. When I try to mount manually without the drive connected, I immedi...
/etc/fstab: meaning of "nofail" if "noauto" is already specified
1,487,837,187,000
After doing some research about systemd units, I found two different kinds of mount unit: the .mount and the .automount. At first, it seemed logical to me that the automount unit would mount a mount automatically. However, as it turns out, when you enable a mount unit: systemctl enable media-mydisk.mount It will auto...
The "auto" part in automount does not refer to the boot process: automount units define mount points that are mounted on-demand, i.e. only when they are accessed. automount units are optional; but, when they exist, corresponding mount units must also exist. The former are meant to add functionalities to existing insta...
Mount vs automount systemd units: which one to use for what?
1,487,837,187,000
Systemd-analyze is giving me different result depending on how much times I execute it, I'm doing Systemd-analyze verify mnt-HDDs.mount and getting: local-fs.target: Found ordering cycle on HDDs-unlock.service/start local-fs.target: Found dependency on sysinit.target/start local-fs.target: Found dependency on systemd-...
Ok, after a lot of searching (and a lot of revisits to this answer here in StackExchange) It ticked to me that this answer was about the same problem I was facing. Basically mount units implicitly occur between local-fs-pre.targe and local-fs.targe, before basic.target, the problem is services get implicit Requires=ba...
How can I solve this ordering cycle in a mount unit?
1,487,837,187,000
This is a followup to another question. I figured out something is unmounting my device right after I mount it. This device is being used by a database (Vertica), which is down and not using the directory while I'm running the mount command. I'm trying to figure out: Is systemd the one which unmounts the device? How ...
Ok, that was in interesting debugging experience... Thanks Filipe Brandenburger for leading me to it! Is systemd the one which unmounts the device? Yes. journalctl -e shows a related message: Aug 01 16:55:19 mymachine systemd[1]: Unit vols-data5.mount is bound to inactive unit dev-xvdl.device. Stopping, too. Appa...
How to check whether systemd is unmounting my device? (and why?)
1,487,837,187,000
I have a CIFS mount of a single volume which then has 2 subdirectories bind mounted. Upon boot, systemd complains of an "ordering cycle" and fails to mount 1 of the binds but the other works fine. If I run mount -a, the missing bind is mounted. I have been able to recreate this behavior in a new VM. /etc/fstab //serve...
I am not sure why even one of the bind mounts is able to work. Here is my suggestion why both might fail together, and how to fix it: Your networking.service is ordered after local filesystems. The bind mounts are being treated as local filesystems. But, the bind mounts are also ordered after a network mount - syst...
systemd mount cycle for bind mount of cifs mount
1,487,837,187,000
I'd like to mount a directory from a remote machine in my /home/stew/shared. After installing sshfs and using ssh-copy-id to my remote machine, I can do this: stew@stewbian:~$ sshfs [email protected]:/path/to/remote-dir ~/shared and then unmount with stew@stewbian:~$ umount ~/shared or stew@stewbian:~$ fusermount -u...
I have the same issue on Ubuntu 21.04 with systemd 246.6 - when you try to unmount a mount unit, systemd first tries to find a umount helper at /sbin/umount.<type> (i.e. for sshfs it would be /sbin/umount.fuse.sshfs), and when that fails - it will call umount2(<where>) - and that will fail when it is run by the user's...
Using systemd to mount remote filesystems in user-bus
1,487,837,187,000
I have a systemd service with this declaration: RuntimeDirectory=plex RuntimeDirectoryMode=750 which creates the in memory directory /run/plex. How would I list the capabilities of this mount point as I would do with mount -l?
The RuntimeDirectory= directive does not create a new mount, it only creates a new directory under the existing /run. So, in a way, you're just reusing space from the existing /run. In other words, look for /run in mount -l output to see the options of the mountpoint where /run/plex lives. You can also use the findmnt...
list systemd RuntimeDirectory mounts
1,487,837,187,000
I want to create systemd mount-unit equivalent for next fstab line /dev/sdc1 /жышы ext4 defaults 1 2 Something as жышы.mount [Unit] Description= /dev/sdc1 to /жышы [Mount] What=/dev/sdc1 Where=/жышы Type=ext4 [Install] WantedBy=multi-user.target Yes, I tried to use systemd-escape for unit file name and for Where, ...
From man systemd.mount: Mount units must be named after the mount point directories they control. Example: the mount point /home/lennart must be configured in a unit file home-lennart.mount. For details about the escaping logic used to convert a file system path to a unit name, see systemd.unit(5). OK, so from man s...
How to mount folder with nonASCII (cyrillic) letters by systemd mount-unit?
1,487,837,187,000
I have a server running on a RAID-1 mdraid on two SSDs with / encrypted. After booting the machine, /boot, which is also the EFI partition is not being mounted automatically, which it should be. State after a regular boot: $ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS sda 8:0 0 931,5G 0 disk ...
After some more tinkering, it turned out, that the filesystem had a minor issue that I detected and repaired using dosfstools: $ sudo dosfsck /dev/md126 fsck.fat 4.2 (2021-01-31) There are differences between boot sector and its backup. This is mostly harmless. Differences: (offset:original/backup) 65:01/00 1) Copy ...
/boot partition not mounted on boot
1,487,837,187,000
I'm encountering an issue with a systemd service starting before a local partition is mounted, particularly after a power loss event. I've investigated and found that this problem arises due to a system reboot and subsequent fsck operation. To easily replicate the problem, I've created a minimal proof of concept. Here...
solution from my comment from systemd.mount manpage: nofail With nofail, this mount will be only wanted, not required, by local-fs.target or remote-fs.target. Moreover the mount unit is not ordered before these target units. This means that the boot will continue without waiting for the mount unit and r...
Systemd service starting before filesystem mount after power loss
1,487,837,187,000
According to manual I thought that systemd-remount-fs.service is responsible for parsing and applying /etc/fstab entries. So I tried to test it: I removed ExecStart part (ExecStart=/lib/systemd/systemd-remount-fs) and rebooted the system. After booting and logging in I still had fstab entries in mount. And now I am wo...
The kernel usually mounts the root filesystem at the very end of the boot sequence. It is usually mounted readonly and irrespective of whatever mount option set as part of the /etc/fstab file. Control is then, given to the init system. As specified in the manual you linked to, systemd-remount-fs.service : ignores nor...
What is parsing/applying /etc/fstab entries
1,487,837,187,000
I have got two readonly root partitions (say roota and rootb) which operating system is installed. This is for a basic A/B partition update scheme and after updating my system these partitions are selected for boot in a roundrobin fashion. I have two other partitions (say data1 and data2) and I would like to mount on ...
No idea what your configuration is, but the script will essentially be something like this: #! /bin/bash default=/dev/partition1 root=`mount | grep -w / | awk '{print $1}'` # verify this works for you test "$root" = "partitionB" && default=/dev/partition2 mount $default /mnt/somewhere
Dynamically select which partition to mount based on root partition
1,487,837,187,000
How mount a mount point available in desktop/file manager under Removable Media category but has not ever been clicked so not been recognized from shell yet, by use of command line? Then only if this first click was done, it further can be recognized and used on shell by commands
On a systemd system you likely have udisksctl, from the udisks2 package. Quoting the udisks(8) manual: udisks provides interfaces to enumerate and perform operations on disks and storage devices. Any application (including unprivileged ones) can access the udisksd(8) daemon via the name org.freedesktop.UDisks2 on the...
mount point available in desktop Removable Media using shell command line
1,487,837,187,000
Two RAID SSDs partitioned as follows. Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 65536 bytes / 65536 bytes Disklabel type: gpt Disk identifier: BF152674-71D5-491B-8C35-09F3AA0015EE Device Start End Sectors Size Type /dev/sda...
Provided nothing on /u vitally depends on /, you can force /u to mount before other local filesystems. One method would be to add the x-systemd.before=local-fs.target option in fstab. E.g.: /dev/mapper/vg_u-u /u xfs defaults,x-systemd.before=local-fs.target 0 0 Then force systemd to regenerate its unit files: sud...
Local filesystem mounted as remote by systemd in OL8.6
1,487,837,187,000
I have a inotify-based service that backs up my LAN's git directory to the Dropbox. I tried keeping the git directory in the Dropbox but I have multiple git clients so often get error files there. In this early stage of development, this is a fairly busy and chatty system service that wants to log to a ram drive. I d...
On Arch, at least, systemd mounts generated from /etc/fstab are deployed to /run/systemd/generator For example on my system, with the listing below I can add to my service file [Unit] Description=backup logging to temp After=mnt-ram.mount ls -la /run/systemd/generator :> ls -la total 32 -rw-r--r-- 1 root root 362 J...
systemd service to start after mount of ram drive
1,487,837,187,000
Can multiple instances of Unit= exist in a systemd.path or systemd.timer unit? Or, must one instead specify multiple instances of the path or timer unit, each with a single instance of Unit=? I haven't been able to find or derive any guidance elsewhere. The former obviously is easier. The specific application is to ...
man systemd.timer says: Unit= The unit to activate when this timer elapses. The argument is a unit name, whose suffix is not ".timer". If not specified, this value defaults to a service that has the same name as the timer unit, except for the suffix. (See above.) It is recommended that the unit name that is activated...
Multiple Instances of Unit= in Path or Timer Unit?
1,487,837,187,000
I'm trying to mount an external usb drive to raspberry pi 4b with debian 11 bullseye. Whatever I've tried so far to set mount options gets ignored. /etc/fstab UUID="9f32de87-6800-4585-a5c5-e6a3946ba2bb" /data ext4 defaults,nofail 0 0 UUID="9f32de87-6800-4585-a5c5-e6a3946ba2bb" /data ext4 rw,suid,dev,exec,auto,nouser,a...
async, suid, dev and exec are the default states for an ext4 mount, so only the non-default options (sync, nosuid, nodev and/or noexec) may be displayed. auto and nouser affect mainly the mount command itself, and these are also the default states for these options. Normally all /etc/fstab entries that are not specifi...
mount options ignored - debian 11 bullseye on raspberry with ext. usb drive
1,487,837,187,000
Since I haven't booted into Windows in over a month and use Linux frequently (without restarting except to boot back into Linux immediately), why did I discover it mounted? If I hadn't been looking through my disks for used and free space I never would have even noticed. Then again, recently I'd siphoned a portion o...
Yes. It is normal for every OS to mount all the partitions on its startup disk.
Why is a Windows partition mounted while Linux is in use?
1,281,507,991,000
I am trying to learn Linux system programming, which is the best book to learn this?
Linux Systems Programming you can refer this also link
What is the best book to learn Linux system programming? [closed]
1,281,507,991,000
What's the difference between slow system calls and fast system calls? I have learned that slow system call can block if the process catches some signals, because the caught signals may wake up the blocked system call, but I can't exactly understand this mechanism. Any examples would be appreciated.
There are in fact three gradations in system calls. Some system calls return immediately. “Immediately” means that the only thing they need is a little processor time. There's no hard limit to how long they can take (except in real-time systems), but these calls return as soon as they've been scheduled for long enoug...
Difference between slow system calls and fast system calls
1,281,507,991,000
Is there an easy way to find out which header file a C function declaration is in? cding into /usr/include and running (grep -E 'system.*\(' *.h -R) works with some trial and error, but isn't there an easier way to do this?
$ man 2 read ... READ(2) Linux Programmer's Manual READ(2) NAME read - read from a file descriptor SYNOPSIS #include <unistd.h> ...
How to find the header file where a c function is defined?
1,281,507,991,000
Can some one explain in an easy to understand way the concept of memory mappings (achieved by mmap() system call) in Unix like systems ? When do we require this functionality ?
Consider: two processes can have the same file open for reading & writing at the same time, so some kind of communication is possible between the two. When process A writes to the file, it first populates a buffer inside its own process-specific memory with some data, then calls write which copies that buffer into ano...
Concept of memory mapping in Unix like systems
1,281,507,991,000
I'm trying to wrap my head how shells move the screen cursor around (Moving around input the arrow keys and such). I've been doing a lot of testing, and I haven't found any system call that allows for movement of the screen cursor in a terminal. Is this done using specific terminal extensions? If so, is there any docu...
There is no such system call, or set of system calls. It's all done by convention. Back in the old days, when a "terminal" was a large clunky piece of equiment linked to a computer via a cable, "smart terminals" would do things like move the cursor, or draw a line, or fill in a polygon with colors. The smart terminal...
Cursor movement in terminals
1,281,507,991,000
I am currently working on implementing my own UNIX shell in C. The basis of the shell is working, you could find the source code here. Right now my next task is to implement a logging feature for the shell. So here's my question: What are the UNIX/Linux best practices to do that? The simple way would be to open a fil...
Typically command history is saved to a hidden file in the user's home directory. Other than that, you can log to stderr or syslog.
Implementing a Unix shell in C: Logging [closed]
1,281,507,991,000
I have a machine dual booted with Arch Linux and Ubuntu (16.04). I have recently started using the Kakoune text editor, and noticed that its startup time is drastically different depending on which OS I am using. However I believe the underlying problem is not due to kakoune directly. On startup, kakoune runs a bunch ...
Debian and Ubuntu use dash as /bin/sh, it's somewhat faster than Bash: $ time for x in {1..1000} ; do /bin/bash -c 'true' ; done ...
Process creation time, shell script and system call overhead
1,281,507,991,000
I have recently purchased myself an HP rack server for use as a personal fileserver. This server currently lives under my bed as I have nowhere else to put it. For those not aware (as I was not fully) this server is VERY LOUD. I need to be able to access my files a lot of the time during the day, and due to the si...
It seems after trial and tribulation of innumerable ways to get my server to do what it's told, the best way to solve my problem of it being loud is just to put it in the garage and hope no water damage occurs during cold nights (which it shouldn't, as the server will be on 24/7). Thanks to everyone who offered actual...
How can I make my Linux server sleep and wake on LAN when not in use?
1,281,507,991,000
From Robert Love's Linux System Programming (2007, O'Reilly), this is what is given in the first paragraph (Chapter 1, Page 10): The file position’s maximum value is bounded only by the size of the C type used to store it, which is 64-bits in contemporary Linux. But in the next paragraph he says: A file may be empt...
He's saying it's bound by a 64-bit type, which has a maximum value of (2 ^ 64) - 1 unsigned, or (2 ^ 63) - 1 signed (1 bit holds the sign, +/-). The type is not FILE; it's what the implementation uses to track the offset into the file, namely off_t, which is a typedef for a signed 64-bit type.1 (2 ^ 63) - 1 = 92233...
FILE size limitation according to Robert Love's textbook
1,281,507,991,000
Is there any SDK for developers under Linux? I mean more than man pages, it would be more like MSDN Library or Windows SDK under windows, where all documentation about programming and developer guide is documented and structured in one place.
For GNOME, you can check out devhelp or help.gnome.org. But as everyone has already stated, there is no single SDK for "Linux". You need to have some idea of what you want before we can recommend specific developer resources.
SDK for Developer
1,281,507,991,000
I have recently started programming in UNIX environment. I need to write a program which creates an empty file with name and size given in the terminal using this commands gcc foo.c -o foo.o ./foo.o result.txt 1000 Here result.txt means the name of the newly created file, and 1000 means the size of the file in bytes...
If you're seeking after the end of the file, you have to write at least one byte at that position: write(fd, "", 1); to have the OS fill the hole with zeros. So if you want to create an empty file of a certain size 1000 with lseek, do: lseek(fd, 999, SEEK_SET); //<- err check write(fd, "", 1); //<- err check ftru...
Trouble with creating an empty file using C programming language in UNIX environment
1,281,507,991,000
I am trying my hand on Linux Signals. Where I have created a scenario mentioned below: Initially block all SIGINT signals using sigprocmask(). If sender send SIGUSR1 signal then unblock SIGINT for rest of the process life. However first step is successfully implemented but not able to unblock (or change) process ma...
The kernel will restore the signal mask upon returning from a signal handler. This is specified by the standard: When a thread's signal mask is changed in a signal-catching function that is installed by sigaction(), the restoration of the signal mask on return from the signal-catching function overrides...
Why below code is not able to unblock SIGINT signal
1,281,507,991,000
Yeah, I know there's actkbd which allows to assign global keyboard shortcuts which will work everywhere including the text console and a graphical session but I don't want to run an extra daemon (long unmaintained as well) for a single keyboard shortcut. I want something a lot simpler with no configuration options and...
So, Linux has quite a nice framework for such things: uinput; evdev is a nice interface to that that doesn't hide anything. It's slim. For basically all Linux distros there's a python3-evdev package (at least that's the package name on debian, ubuntu and fedora). Then, it's a few lines of code to write your daemon; th...
A simple global keyboard shortcut handler
1,281,507,991,000
Is there a good description of exactly what each of the flags you can pass to personality(2) does? I'm particularly interested in STICKY_TIMEOUTS, but a general detailed description of all of them would be nice. I've googled a bunch for this and can't find it. And I like knowing these things. This is a very specific p...
According to man 2 personality: STICKY_TIMEOUTS (since Linux 1.2.0) With this flag set, select(2), pselect(2), and ppoll(2) do not modify the returned time‐out argument when interrupted by a signal handler. You can read the rest of the man page for detailed descriptions of each of the available flags.
What does the STICKY_TIMEOUTS flag for personality(2) do?
1,281,507,991,000
Good days. I have a little problem. I have this function in bash script function denyCheck(){ file=$(readlink -f $(which $(printf "%s\n" "$1"))) if [[ -x $file ]];then return false else return true fi } denyCheck "firefox" This function I pass her a string, what is a comman, and ...
Should rather be: cmd_canonical_path() { local cmd_path cmd_path=$(command -v -- "$1") && cmd_path=$(readlink -e -- "$cmd_path") && [ -x "$cmd_path" ] && REPLY=$cmd_path } 2> /dev/null And then use for instance as: if cmd_canonical_path firefox; then printf '%s\n' "firefox found in $REPLY executable...
How to pass a parameter in a command without run the parameter content?
1,281,507,991,000
Say I'm implementing a programming language which has an interactive mode, and that interactive mode reads some ~/.foo_rc file in the user's home directory. The file contains code in that language which can be used to customize some preferences. The language isn't sandboxed when reading this file; the file can do "any...
Reasonable and prudent, provided there are clear warnings on what file is failing, and why, so the user can fix the permissions issue. bash probably dates from a more trusting (and prank-ridden) day. Note that user files can legitimately be group writable, if the site has a policy of each user going into a group that ...
Permission check on profile file in home directory: should it be done?
1,281,507,991,000
I need to check filesystem type on a thumb drive in my C++ application. It must be done before mounting a new partition. I also prefer not to call system() function. I tried to use the following test code: #include <blkid/blkid.h> #include <stdio.h> int main() { blkid_probe pr; const char *ptname; const ch...
If you are interested in what filesystem is on sdb1 you should use USAGE to first check whether it is a filesystem and then get filesystem type with TYPE. You'll need to set these flags to enable filesystem lookup: blkid_probe_set_superblocks_flags(probe, BLKID_SUBLKS_USAGE | BLKID_SUBLKS_TYPE | ...
blkid: blkid_probe_lookup_value() - strange partition types
1,281,507,991,000
The program in general is I want to implement telnet program. On the client side user send its logging name and password, and if it is correct he starts to send commands to the server On the Server side I am check on the user authentication on the system and if it is true I must run his default shell which is stored ...
You can't just use system. You have to fork and exec yourself and use pipes in both directions. You'd also have to use some kind of terminal interface if you wanted to catch Ctrl key input.
telnet implementation using C [closed]
1,281,507,991,000
I too many search on internet to found algorithm calculated %Us , %Sy , %Id , ... on result of top command . but can not found any documentation . some documents like this or this calculate cpu utilization but output not equal with output of top command . (too diff !!!) How do the top or mpstat commands calculate ...
I calculate with this formula : result=(CurrentUse-PrevUse)*100/(CurrentTotal-PrevTotal) this is a example script calculate [us,sys,idle] of cpu . #!/bin/bash prev_total=0 prev_idle=0 prev_us=0 prev_sys=0 while true do line=$(head -n1 /proc/stat) us=$(echo $line | awk '{print $2}') ...
CPU statistics calculation algorithm
1,281,507,991,000
I've been working on a Routing Protocol and looking at legacy code for different routing protocols. I constantly find different macros where I it is very hard to find it in the header files because they include ~20-50 headers. Besides looking up the macro on the Internet is there any way by finding their definitions i...
I posed this question to my mentor and he said to use grep, so I tried it out and I succeeded. Grep is an absolutely amazing tool! The code I used to find the macro was grep -rl "INADDR_ALLHOSTS_GROUP" * and I ran it from the /usr/include directory.
How to find documentation about macros in the manpages?
1,281,507,991,000
I wrote a c++ program using some libraries called linbox, givaro, gmp. Now because my computer is to slow I want to run my program on a supercomputer. I am not very familiar with networks and my programming skills are not very high. I managed to upload the data that the program uses and the c++ program itself. But of...
If the hpc doesn't contain required libs, you have 2 options: Ask the admins to install the required libs Build a static executable, which contains all the libs. If possible to go with option (2), just compile it on your machine, then upload to the hpc and run as is. I suspect unless you have mpi/pgas as part of you...
Use supercomputer to run a program [closed]
1,485,910,569,000
Wanting to play around with Trusted Platform Module stuff, I installed TrouSerS and tried to start tcsd, but I got this error: TCSD TDDL ERROR: Could not find a device to open! However, my kernel has multiple TPM modules loaded: # lsmod | grep tpm tpm_crb 16384 0 tpm_tis 16384 0 tpm_ti...
TPMs don't necessarily appear in the ACPI tables, but the modules do print a message when they find a supported module; for example [ 134.026892] tpm_tis 00:08: 1.2 TPM (device-id 0xB, rev-id 16) So dmesg | grep -i tpm is a good indicator. The definitive indicator is your firmware's setup tool: TPMs involve ownershi...
How to determine if computer has TPM (Trusted Platform Module) available
1,485,910,569,000
I'm experiencing system freezes and looking in the journal I see kernel (4.14.15-1-MANJARO) errors such as: kernel: tpm_crb MSFT0101:00: [Firmware Bug]: ACPI region does not cover the entire command/response buffer. [mem 0xfed40000-0xfed4087f flags 0x201] vs fed40080 f80 kernel: tpm_crb MSFT0101:00: [Firmware Bug]: AC...
I emailed Asus support and they say that the laptop only supports Windows. You could consider disabling TPM if it is not being used - please comment if you work out how to do this.
ACPI region does not cover the entire command/response buffer
1,485,910,569,000
I am currently aware of two recent methods to bind a LUKS encrypted root partition to a TPM2: systemd-cryptenroll and clevis. Both of them seem to release the encryption key after successfully checking the PCRs the key was sealed against. But I don't like the idea of the volume being decrypted without user interaction...
2022-05-21 - systemd v251 Support for TPM2 + PIN has been merged in systemd-cryptenroll and is available as part of release v251. Changes in disk encryption: systemd-cryptenroll can now control whether to require the user to enter a PIN when using TPM-based unlocking of a volume via the new --tpm2-with-pin= option. ...
LUKS + TPM2 + PIN
1,485,910,569,000
I have an Ubuntu 20.04 machine setup that I am trying to configure for disk encryption. I am trying to setup auto unlock, but my configuration has not worked so far, and I am always prompted for a password. To do this I followed the following steps: sudo apt-get update and sudo apt-get install cryptsetup Check /dev/n...
I was missing: clevis-initramfs that needed to be installed. Once added the auto unlocker worked.
Ubuntu 20.04 clevis-luks setup auto unlocking not working
1,485,910,569,000
TPMs are supposed to solve a chicken and egg problem of where to store unencrypted disk encryption keys such that someone can't simply pop another hard drive in the machine, boot a different OS and read the keys right off the disk / flash / BIOS / ... AFAIK TPMs basically do this by checking what software booted and, ...
Where I'm stuck is figuring out how to ensure there's a solid chain of trust from BIOS firmware to login ensuring that if the OS is tampered with it will either not boot, or the TPM will refuse to hand over the encryption key. That's built into the process; it's the --tpm-pcrs= option that you give to systemd-crypte...
How must I configure Debian or Ubuntu to ensure there's a chain of trust from TPM to Login?
1,485,910,569,000
We currently have UEFI booting up GRUB which boots up Linux. We need to implement secureboot. We're using a TPM to store our keys. Does GRUB2 support TPM - I read the only version of GRUB that supports TPM, i.e. TrustedGRUB does not support UEFI. Is there a GRUB version that supports TPM? Or, is the only alternative t...
grub2 supports TPM in the sense that it updates the PCR to include grub entries and it supports secure boot. Subsequent bootloader pieces (including clevis) can use the PCR to verify the grub binary, kernel and initrd binaries, and kernel command line have not been tampered with.
Does GRUB2 support TPM with UEFI?
1,485,910,569,000
How to find out if TPM device supports "TPM 2.0 FIFO Interface" (TCG_TIS) and "TPM 2.0 FIFO Interface - (SPI)" (TCG_TIS_SPI), when they don't specify it? I'm particularly interested in TPM SLB 9665 Xenonboard, as it has JTPM1, which is on my board (Supermicro H11SSL-i board, which recommends Infineon AOM-TPM-9665, whi...
From your third link you can get this PDF in which a product summary table specifies that only products with a sales code starting with "SLB 9670" will use the SPI interface. As you are talking about SLB 9665, that excludes TCG_TIS_SPI. On my system, I have an Asus-branded Infineon SLB 9665 TPM which works fine with t...
TPM 2.0 device which supports Linux kernel via TCG_TIS or TCG_TIS_SPI
1,485,910,569,000
For passwordless decryption of a LUKS volume I want to use clevis with my TPM 2.0 module. This module is recognised in Debian Testing (bullseye): /dev/tpm0 and /dev/tpmrm0 exist (so that I am able to run the necessary clevis commands in Debian). However, the clevis initramfs scripts fail. Having investigated this in a...
Make sure that the kernel modules that drive the TPM get loaded within initramfs by listing them in /etc/initramfs-tools/modules. Then the initramfs udev should create the devices for you. First, run lsmod | grep tpm to find your TPM driver module(s). For me, the output looks like this: # lsmod |grep tpm tpm_tis ...
How to get /dev/tpm* in initramfs?
1,485,910,569,000
I want to load unlock my LUKS partition (root file system) at boot time using a TPM 2.0. I've had no success using a keyscript=/path/to/script in my /etc/crypttab file, however I made progress using methods I found here. I am using dracut to build initial ram fs images. So in /usr/lib/dracut/modules.d/90crypt, I have...
I found a solution! I added /sbin/strace to my installed binaries in module-setup.sh so i could manually inspect the tpm2_nvread command in the dracut shell. Turns out the error was that my network was unreachable. The tpm2 commands uses libtcti to communicate with the tpm, which uses a socket at 127.0.0.1:2323. Now,...
How can I execute tpm2_nvread in the initramfs image created by dracut for centOS 7?
1,485,910,569,000
I have Debian and Linux 5.x kernel. I get the following error: # /etc/init.d/tpm2-abrmd status ● tpm2-abrmd.service - TPM2 Access Broker and Resource Management Daemon Loaded: loaded (/lib/systemd/system/tpm2-abrmd.service; enabled; vendor preset: enabled) Active: activating (auto-restart) (Result: exit-code) si...
No, Linux doesn’t need a TPM (of any version). Some programs which run on Linux do need a TPM; that’s the case of tpm2-abrmd which is the source of your error. If you don’t have a TPM (version 2) there’s no point in keeping that package installed, you should remove it. (tpm2-abrmd implements the TCG access broker and ...
Is TPM2 mandatory on Linux?
1,485,910,569,000
I have enabled TPM 2.0 using bios. $ [ -c /dev/tpmrm0 ] && echo "TPM 2.0" TPM 2.0 When I am trying to install tpm-tools, it is giving the following error: % sudo apt install tpm-tools Reading package lists... Done Building dependency tree Reading state information... Done tpm-tools is already the newest version (1.3....
Addressing the comment made by the OP here, in which they want to take the code here and rewrite it into a neater form. I'm repeating the code here just in case it would disappear from the external site: if [ ! -e /dev/tpmrm ] then log_warning_msg "device driver not loaded, skipping." ...
can not start trousers service - giving error 'TrouSerS ioctl: (25) Inappropriate ioctl for device'
1,485,910,569,000
System: Fedora 37, Gnome 43 I enabled LUKS encryption on setup and enabled auto-decrypt via TPM 2 with following an article from Fedora Magazine. Auto-decrypt works but while it decrypts, it shows the passphrase screen until system boots. How can I hide this screen?
This worked for me, after reading up and working out what was asking for the password I tried a sleep for the ask password. I tried a few values 8 seconds the boot screen showed then switched to the password before continuing, 15 didn't show up. It means that if the TPM decrypt fails the password will eventually show ...
I Have LUKS Enabled And Integrated With TPM 2. How To Hide Passphrase Screen?
1,485,910,569,000
At reboot, with USB sticks inserted, the TPM will not allow passphraseless booting of the server. With a USB HDD inserted passphraseless booting of the server is possible. Our servers are running Centos 8.3 with Linux kernel version 4.18.0-240. TPM2 modules are used with LUKS version 1 encryption of an LVM group consi...
We have figured out which PCR value changes after a USB stick gets inserted and the system reboots. By not binding to that PCR value we managed to boot off the TPM with a USB stick inserted. In our case PCR 1 (BIOS config) kept changing when a USB stick was inserted and the system rebooted. The command we used to quer...
Not booting off TPM with USB disk inserted
1,485,910,569,000
I have this issue with latest fedora 35 beta. Clevis encrypt does not work, although I can find the TPM being active in the logs. Tried the enable operation from bios with no luck. Please, see details here: dmesg | grep -i tpm [ 0.000000] efi: ACPI=0x45bfe000 ACPI 2.0=0x45bfe014 TPMFinalLog=0x45ac5000 SMBIOS=0x439e...
Fixed with latest Fedora 35 Update from 04.11.2021
TPM support does not work on Fedora 35
1,590,065,378,000
I recently needed a single webcam to be shared simultaneously by 3 applications (a web browser, a videoconferencing app, and ffmpeg to save the stream). It's not possible to simply share the /dev/video* stream because as soon as one application is using it, the others cannot, and anything else will get a "device or re...
It's by design. First, let it be said that multiple processes can open the /dev/video0 device, but only one of them will be able to issue certain controls (ioctl()) until streaming starts. Those V4L2 controls define things like bitrate. After you start streaming, the kernel will not let you change them and returns EBU...
Why can multiple consumers access a *single* v4l2-loopback stream from a webcam
1,590,065,378,000
I would like to join some videoconference, but I don't own a webcam and the conference software requires one. So my question is, can I create a dummy one? I don't care what the cam will cast, I just need to appear to have one.
There is loopback device for that: https://github.com/umlaeute/v4l2loopback Just add device with modprobe and stream to it with ffmpeg or gstreamer whatever video you want, or anything else for that matter: https://github.com/umlaeute/v4l2loopback/wiki
How to create dummy webcam?
1,590,065,378,000
I have a Logitech Webcam C930e on /dev/video0. I can use this for doing video conferences (e.g. jitsi). However, the video from this webcam is too high and too broad. I would like to have a "cropped" version of /dev/video0 that does not show the seaside picture on the wall. First, I tried to set v4l2 options to achie...
Lines below create a loopback video device /dev/video5. After that ffmpeg is used to connect /dev/video0 to /dev/video5, but crop and hflip the stream on its way. sudo apt-get install v4l2loopback-dkms sudo modprobe v4l2loopback video_nr=5 ffmpeg -i /dev/video0 -f v4l2 -pix_fmt yuv420p -filter:v "hflip,crop=400:400:0...
How to create a v4l2 device that is a cropped version of a webcam?
1,590,065,378,000
I am trying to create a virtual webcam from OBS(26.1.1) so I can feed it to Zoom. I am Linux Mint 20.1 Cinnamon, version 4.8.6, Kernel 5.4.0-64-generic. I did: sudo apt-get install v4l2loopback-dkms sudo apt-get install v4l2loopback-utils but v4l2loopback is not showing up as an option in zoom I went to the v4l2loop...
Installing v4l2loopback-dkms will install the modules on your system (at least: if all goes well), but it will not load the modules for you. So, you need to manually load the module with something like modprobe v4l2loopback In order for zoom to use the device, you will first have to attach OBS Studio to it. You proba...
How to best install v4l2loopback on Linux Mint?
1,590,065,378,000
I run a debian 10 with kernel 5.9.0.0 I installed v4l2loopback from the official repo, as in sudo apt install v4l2*, which installed sudo apt install v4l2* Reading package lists... Done Building dependency tree Reading state information... Done Note, selecting 'v4l2loopback-source' for glob 'v4l2*' Note, select...
I'll answer my own question. Since my kernel is 5.9.0.0, which I installed from buster-backports, while v4l2 was installed from buster repo, it was off. I solved it by just installing that too from buster-backports and it works fine
modprobe: FATAL: Module v4l2loopback not found in directory
1,590,065,378,000
Im using OBS with v4l2sink and v4l2loopback to edit my video for a remote trainig. The preview in obs looks fine, but the video has some serious color shifts in any tool I try to display the v4l2loopack I'm directing the sink to. View from OBS: View from Browser: You can see that all colors have a green shadow about...
After reinstalling everything, it works fine for me now. So I have no idea which setting I fiddled with to create this problem :/
Why are my colors separated/shifted when using obs/v4l2sink/v4l2loopback?
1,590,065,378,000
I've created a couple of v4l2loopback devices for use as virtual webcams, and have been able to get Chrome to recognize them via navigator.mediaDevices.enumerateDevices(). I've also been able to construct gstreamer pipelines to send video and image data to these virtual webcams. what I haven't been able to do is des...
The generic v4l2 standard doesn't know anything about "front-facing" and "back-facing" or "side-facing" cameras. Such an attribute mostly (only?) makes sense when it comes to smartphones. It doesn't make sense for my good old analog camera nor my USB Webcam nor my builtin laptop webcam, all of which I've used with v4l...
how do I set properties of a v4l2loopback device and make them visible to my web browser?
1,590,065,378,000
I'm trying to switch from one advertised resolution/framerate to a different one on the fly, preferably while other applications are consuming the v4l2loopback feed. As an example, I feed a 1920x1080 black screen video into /dev/video2, and then open it in vlc. This works fine: $ ffmpeg -f lavfi -i color=c=black:s=192...
as long as the device is opened, it's resolution (and format) are fixed. so the answer to your question is: no, you can't change these settings on the fly. (unless you quit all consumers (in your case: VLC) before starting the new ffmpeg; but that's not what i would call "on the fly") this is a limitation of the V4L2 ...
How do I change the resolution/capabilities of a v4l2loopback device on the fly?
1,590,065,378,000
Running: Arch Linux, using package "v4l2loopback-dkms" Software I'm trying to get running: https://github.com/fangfufu/Linux-Fake-Background-Webcam This software uses v4l2loopback, which I've setup a few times successfully. I have two files to load v4l2loopback on boot, with these contents: The first file simply loads...
After installing a kernel update to 5.18.2, everything was suddenly working. I'm assuming it was something with that version.
v4l2loopback /dev/video2 Not being created
1,590,065,378,000
I'm trying to build v4l2loopback by simply entering: make Building v4l2-loopback driver... make -C /lib/modules/`uname -r`/build M=/home/user/dev/labs/v4l2loopback modules make[1]: Entering directory '/usr/lib/modules/5.13.0-22-generic/build' make[1]: *** No rule to make target 'modules'. Stop. make[1]: Leaving dir...
/lib/modules/$(uname -r)/build isn’t supposed to be a directory, it’s supposed to be a symbolic link to /usr/src/linux-headers-$(uname -r). If you fix that with sudo rmdir "/lib/modules/$(uname -r)/build" sudo ln -s "/usr/src/linux-headers-$(uname -r)" "/lib/modules/$(uname -r)/build" your build should work.
Problem with make when building v4l2loopback
1,590,065,378,000
I installed the v4l2loopback kernel module on my machine and enabled it with sudo modprobe v4l2loopback exclusive_caps=1. I created a camera on /dev/video0 with the rust bindings and started piping a static image to the camera (command from the wiki): sudo ffmpeg -loop 1 -re -i 60828015.jpg -f v4l2 -vcodec rawvideo -p...
From https://github.com/umlaeute/v4l2loopback/wiki/Faq Depending on the color encoding, odd-sized frames can be problematic (eg YUV420p requires that the U and V planes are downsampled by a factor of 2, which works best if the width and height can be divided by 2). See also Issue #561 I changed the image size and th...
Chromium cannot read camera: Dequeued v4l2 buffer contains invalid length #561
1,590,065,378,000
I'm trying to replicate the following command in OSX: sudo modprobe v4l2loopback video_nr=3 card_label="TestVideo" So far I've tested the following advice here but I keep getting an error erroneous pipeline: no element "videotestsrc" My first question is are the two commands v4l2loopback=gst-launch-1.0 equal? My sec...
My first question is are the two commands v4l2loopback=gst-launch-1.0 equal? no. they are not. gst-launch-1.0 is a command that launches a GStreamer pipeline (as specified by its arguments). GStreamer is a generic, cross-platform media framework v4l2loopback is not a command at all. My second question is whether ...
Replicating v4l2loopback command in OSX Big Sur?
1,364,380,590,000
On Linux, the openat syscall can be used to create files and to test for their existence. Speaking in terms of the C/C++ memory model, creating a file and verifying its existence creates a synchronizes-with relationship. What I need to know is whether these synchronizations are all sequentially-consistent with each ot...
Only for files in the same directory. There are 6 rules: read access. Locking rules: caller locks directory we are accessing. The lock is taken shared. object creation. Locking rules: same as above, but the lock is taken exclusive. object removal. Locking rules: caller locks parent, finds victim, locks vict...
Is file creation totally ordered?
1,364,380,590,000
I followed the steps here and compiled the kernel successfully in usermode: https://btrfs.wiki.kernel.org/index.php/Debugging_Btrfs_with_GDB But when I start ./linux in various ways it always gives me a very similar error: pc@linux-94q0:~/linux-4.11-rc4> ./linux root=/mnt Core dump limits : soft - 0 hard - NO...
From https://www.linux.com/news/how-run-linux-inside-linux-user-mode-linux : ./linux-2.6.19-rc5 ubda=FedoraCore5-x86-root_fs mem=128M The ubda parameter in this command is giving the UML kernel the name of a file to use to create the virtual machine's /dev/ubda virtual block device, which will be its root filesystem....
How do I run the usermode linux kernel?
1,364,380,590,000
I study with details the structure of the VFS superblock and I noticed the field struct hlist_head s_pins; Even though I made an extensive search it was not possible to find info about this. I only found that this is defined and used in fs_pins.c and in functions as pin_insert & etc cetera, but there is no informatio...
These pins are used by the accounting subsystem: they ensure that acct_pin_kill is called when file systems are unmounted or remounted, so that accounting can take appropriate action. (Accounting writes information to a file, so it needs to know when that file will no longer be writable.) Pins were intended as a more ...
Usage and role of s_pins field in the VFS superblock
1,364,380,590,000
I have: $ find 1 2 -printf '%i %p\n' 40011805 1 40011450 1/t 40011923 1/a 40014006 1/a/e 40011217 1/a/q 40011806 2 40011458 2/y 40011924 2/a 40013989 2/a/e 40013945 2/a/w I want: <inode> <path> any 2 40011450 2/t 40011458 2/y any 2/a 40014006 2/a/e 40011217 2/a/q 40013945 2/a/w How do do it?
Already answered. Here is version adapted to this task: D=$(readlink -f "2"); (cd "1" && find . -type f -print0 | cpio --pass-through --null --link --make-directories "$D") && rm -Rf 1 After this command I have exactly what I wanted: $ find 1 2 -printf '%i %p\n' find: `1': No such file or directory 40011806 2 4001145...
How do I merge (without copying) two directories? [duplicate]
1,364,380,590,000
I'm attempting to help out a roommate who has installed Kubuntu on his Chromebook using Crouton (it's basically just a fancy chroot run within ChromeOS). I helped him get the Docker daemon running, using some advice from this issue on the Docker github: https://github.com/docker/docker/issues/1863. That involved usin...
I'm working through this same issue now. This happens because vfs is not a true union file system (like aufs), so every incremental image in the image you restore is restored to its full size. See this issue for more details: https://github.com/docker/docker/issues/14040
Docker in Crouton - VFS consuming astronomical amounts of space
1,364,380,590,000
[~]$ stat -c %i / 2 As you can see in above, the inode for / is 2. But the First inode of /dev/sda2 is 11. [~]$ df -h Filesystem Size Used Avail Use% Mounted on /dev/sda2 350G 67G 266G 21% / tmpfs 12G 44M 12G 1% /dev/shm [~]$ sudo tune2fs -l /dev/sda2 | grep 'First...
The value in the superblock shown by tune2fs is the first inode number usable for new files, while the root directory must always exist when the file system is created. The kernel’s Ext4 documentation lists the inode numbers which are used internally by file systems features.
Why are the first inode of the `/` mounted partition and inode of `/` different?
1,364,380,590,000
Today, I have read through some documents about file system (http://tekrants.me/2014/07/14/linux-file-system-write/). And the term kernel page is mentioned several times in this article. I am now quite confused about the memory usage of kernel and of user. I understand that the address space for kernel and user and b...
The kernel manages the memory, so kernel code has access to both kernel and user space. When talking about "kernel space" one usually means pages which are used exclusively by the kernel. "User space" is not a single entity. Each process has its own address space, possibly partially overlapping with other processes. ...
What is kernel memory and user memory? (question about the term kernel page and the page cache)
1,364,380,590,000
In my GFS clusters I use the CDPN feature to have separate chrooted /dev/log directories on separate cluster nodes: /home/ftpuser/foo: lrwxrwxrwx 1 root root 18 Sep 26 2010 dev -> .sys/@hostname/dev /home/ftpuser/foo/.sys: drwx--x--x 3 root root 3864 Sep 26 2010 server1.example.com drwx--x--x 3 root root 3864 ...
I don't think CDPN exists for NFS, but you can achieve something roughly equivalent with basic tools. The limitation is that you have to put all your node-specific files in the same location (or at least you have to keep a list of locations), you can't use the @hostname feature anywhere you like. Mount a local filesys...
Is there a way to achieve context-dependent path names (CDPN) on NFS?
1,364,380,590,000
I have an eMMC backed Linux 3.10 development device (Android) and I am trying to better understand when Linux is actually reading from the eMMC as opposed to the page cache. Specifically, I am interested in the ELF loading process and I cannot explain the following results. I have placed an ELF file on the filesystem...
The problem appears to be timing between init restarting the process and the page cache being dropped. Instead of issuing kill -9 <pid> && echo 3 > /proc/sys/vm/drop_caches, the proper sequence appears to be the following. stop <service> echo 3 > /proc/sys/vm/drop_caches start <service> Once the service is stopped, ...
Reading ELF file after dropping caches
1,364,380,590,000
I'm learning Linux procfs, which utilizes a virtual file system where operations like open, read, write, and release are processed by functions registered to it. I've left the open and release to null pointer by mistake, and when I try to read the content of the file, with Python codes like: with open("/proc/testfile"...
You can use strace to see what system call some command is making: $ strace cat /proc/version [...] openat(AT_FDCWD, "/proc/version", O_RDONLY) = 3 [...] read(3, "Linux version 5.16.0-5-amd64 (de"..., 131072) = 181 write(1, "Linux version 5.16.0-5-amd64 (de"..., 181) = 181 [...] $ strace python3 -c 'open("/proc/ver...
How can `cat` read a file without a file descriptor?
1,364,380,590,000
While studying VFS, this question popped into my head. Is it okay to think of VFS as a module? The reason why I thought like that is because VFS has the characteristic of simplifying actual file management to kernel/user space. This seemed something like a device driver would do and it got me thinking. But then again,...
You don't specify which operating system you are asking about, but the answer is likely to be the same for all of the mainstream general purpose ones. TL;DR: The VFS is not a module. In general, the VFS is too much integral to the basic functionality of the kernel to be able to be configured as a (optional) module. Ev...
is VFS a module?
1,364,380,590,000
Using debugfs -R 'stat <inode_nr> ' /dev/sda1 returns a result where there is a field crtime which i believe represents the creation date of a file pointed to by inode numbered inode_nr. I use this on an ext4 fs. I know that the inode stores access_time, modification_time and change_time but not birth of a file So m...
If the filesystem records file creation time (Not all do), it's stored in the inode along with the rest of the file metadata like modification and change times. It can be retrieved with the fairly recently added statx(2) system call in the stx_btime field of the struct statx that it populates. Note that there's no eas...
Where is the file creation time (birth) stored in linux?
1,364,380,590,000
As per my understanding kernel maintains 4 tables. Per process FD table. System wide open file table struct file Inode (in-memory) table struct vnode Inode (on-disk) table. struct file have one field named struct file_operations f_ops; which contains FS specific operations like ext2_read(), ext2_write(); struct vnod...
Okay, I have found the answer. In previous versions of Unix like SVR4, struct file does not contain file_operations field and all operations e.g. read, write etc. contained by vnode->v_op. However, in case of Linux struct file will contain file_operations field which will have functions like open, read, write etc. and...
struct file_operations vs struct vnodeops
1,364,380,590,000
Yesterday I did a kernel update on a virtual machine. When I restarted the machine unfortunately I got the error Kernel panic - not syncing VFS After some searching I found out I should go to GRUB and just select the old kernel and everything would be fine. Wel I selected the old kernel but came to the following error...
Well I did "solve" it. Still don't know how. I contacted a system friend of mine which pointed me to this answer. I followed it but did not got past the second command. I reset the system and somehow we got a third option in the GRUB which did work (magic) so now the system is running again. So boys and girls don't fo...
Centos VFS cannot open root device
1,447,153,121,000
I have script including multiple commands. How can I group commands to run together ( I want to make several groups of commands. Within each group, the commands should run in parallel (at the same time). The groups should run sequentially, waiting for one group to finish before starting the next group) ... i.e. #!/bin...
The commands within each group run in parallel, and the groups run sequentially, each group of parallel commands waiting for the previous group to finish before starting execution. The following is a working example: Assume 3 groups of commands as in the code below. In each group the three commands are started in the...
Run commands in parallel and wait for one group of commands to finish before starting the next
1,447,153,121,000
Doesn't the bash shell already run the commands one by one and wait for the executed command to finish? So when and why do we need the wait command?
You use wait if you have launched tasks in background, e.g. #!/bin/bash task1 & task2 & task3 & wait echo done In this example the script starts three background tasks. These will run concurrently in the background and the wait will wait for all three tasks to finish. Once wait returns, the script continues with pr...
When and why do we need the `wait` command on bash?
1,447,153,121,000
I know this question has been already asked & answered, but the solution I found listens for space and enter: while [ "$key" != '' ]; do read -n1 -s -r key done Is there a way (in bash) to make a script that will wait only for the space bar?
I suggest to use only read -d ' ' key. -d delim: continue until the first character of DELIM is read, rather than newline See: help read
Press SPACE to continue (not ENTER)
1,447,153,121,000
If I have the following shell script sleep 30s And I hit Ctrl+C when the shell script is running, the sleep dies with it. If I have the following shell script sleep 30s & wait And I hit Ctrl+C when the shell script is running, the sleep continues on, and now has a parent of 1. Why is that? Doesn't bash propagate Ctr...
tl;dr; the Xvfb process sets a signal handler for SIGINT and exits when it receives such a signal, but the sleep process doesn't, so it inherits the "ignore" state for SIGINT as it was set by the shell running the script before executing the sleep binary. When a shell script is run, the job control is turned off, and ...
sleep, wait and Ctrl+C propagation
1,447,153,121,000
In this script, that pulls all git repositories: #!/bin/bash find / -type d -name .git 2>/dev/null | while read gitFolder; do if [[ $gitFolder == *"/Temp/"* ]]; then continue; fi if [[ $gitFolder == *"/Trash/"* ]]; then continue; fi if [[ $gitFolder == *"/opt/"* ]]; then c...
The issue is that the wait is run by the wrong shell process. In bash, each part of a pipeline is running in a separate subshell. The background tasks belong to the subshell executing the while loop. Moving the wait into that subshell would make it work as expected: find ... | { while ...; do ... (...
Why wait in this script is not executed after all subshells?
1,447,153,121,000
I can't find any documentation that explains my observations in sufficiently enough terms. After I run the below code, I perform a kill -SIGINT $my_pid from a different shell. I will correctly see #### received trap 2 the first two times. However, the wait command gets interrupted on each signal. Why? #!/bin/bash for...
3.7.6 Signals When Bash is waiting for an asynchronous command via the wait builtin, the reception of a signal for which a trap has been set will cause the wait builtin to return immediately with an exit status greater than 128, immediately after which the trap is executed.
Why is the wait $pid command interrupted by any signal to the waiting process?
1,447,153,121,000
#!/usr/bin/env bash sleep 3 && echo '123' & sleep 3 && echo '456' & sleep 3 && echo '999' & If I run this, and send SIGINT by pressing control-c via terminal, it seems to still echo the 123... output. I assumed this is because it's somehow detached? However if I add a wait < <(jobs -p) (wait for all background jobs ...
Signal interception? propagation? No wait does not intercept the signal. The shell does not pass it. The signal is neither intercepted nor propagated. The subshells running your three "background" commands either get the signal directly or not. You can test with the following script: #!/usr/bin/env bash printf 'My PI...
What determines whether a script's background processes get a terminal's SIGINT signal?
1,447,153,121,000
I know if a subprocess does not get reaped properly, it will become a zombie and you can see it by ps command. Also the "wait [pid]" command will wait for subshell running on the background until it finishes and reap it. I have a script like this: #!/bin/bash sleep 5 & tail -f /dev/null My question is, I don't use w...
This is one of the pitfalls with having a shell mimic the OS API. It does create confusion. In this case you are confusing wait() (linux API) with wait (bash function). Simply enough, Bash takes care of reaping processes for you, you don't generally need to think about this. The wait bash command has no effect on r...
zombie process reap without "wait"
1,447,153,121,000
Bash 5.0 includes a new -f option for wait:[1] j. The `wait' builtin now has a `-f' option, which signfies to wait until the specified job or process terminates, instead of waiting until it changes state. What does wait -f $pid do as opposed to the default wait $pid? Under what conditions is the -f option neede...
The change description is accurate, but somewhat obscure since wait is generally thought of as waiting for a process to finish. Try this: sleep 60& wait %1 then in another terminal, kill -STOP ${pid} replacing ${pid} with sleep’s pid (as output when it was put in the background). wait will exit, because the job’s st...
What does the `-f' option do for `wait' versus the default behaviour?
1,447,153,121,000
I've got an old Mac with 24 cores, and I'd like to run several hundred/thousands one-core jobs automatically. I've made a bash script that runs the processes in the background, but if I set too many going at once the computer freezes (apparently 300 is okay, 400 too much...). Ideally, what I'd like to do is run 24...
I encountered a similar problem recently. As far as I know you have two options: xargs -0 -P 24 -L 1 and Gnu Parallel For example, to convert every flac file found by the find command to ogg I tried running: find -name "*.flac" -print0 | xargs -0 -P 24 -L 1 oggenc This runs up to -P 24 processes at a time using -L ...
queue-like behaviour for multiple one-core jobs on single machine? [duplicate]
1,447,153,121,000
I'm currently reading M. Bach's "THE DESIGN OF THE UNIX® OPERATING SYSTEM". I read about the main shell loop. Look at the if (/* piping */) block. If I understood correctly, piping allows treating the 1st command output as the 2nd command input. If so, why isn't there a code that makes the 2nd command wait for the 1st...
the 2nd command can start executing without its input being ready. It does. There's nothing wrong with that. In a pipeline producer | consumer, the two sides run concurrently¹. The consumer does not wait for the producer to finish. It doesn't even care if the producer has started. All the consumer needs is a place t...
Why doesn't the 2nd command wait for the output of the 1st (piping)?
1,447,153,121,000
I'm running a script which automates snapraid for my NAS server. It's a script I found online and it was working without issue on Debian 9. I updated to Debian 10 last week and the script now hangs in places it wasn't on Debian 9. I think I've narrowed the issue down to the tee and wait commands. I've shortened the sc...
The tee inside the process substitution will not exit until it gets an eof on its stdin or some error happens. And, since its stdin is a pipe, it will only get an EOF on its stdin when all the handles to its writing end are closed. So, you'll have to save the original stdout and stderr, and then, before the wait, redi...
Script hanging when using tee and wait, why?
1,447,153,121,000
I'd like to create a function that will wait until a job is completed before starting a new process. I'm aware of the wait command that is built into bash, but it only works for child processes. It will fail if I start in a different bash session. I wrote a bash function using kill -0 that takes a pid and waits until ...
You are creating a function in your script but never using it. You could source that script and then call pidwait 4569 (no ./) or add a call to the function inside the script: #!/usr/bin/env bash function pidwait() { while kill -0 "$1"; do echo "Process $1 still running..." sleep 1 done e...
Bash function that will wait for a process to be finished before starting a new one
1,447,153,121,000
I wonder if I can get some help with a project I'm working on. I have a Synology NAS. I found a Community Package that autoruns a script of my creation anytime a USB drive is plugged in to one of the drives. My script copies images and movie files to a given folder from all USB drives/Sandisk cards listed in the scrip...
You wrote today=$(date +%m-%d-%Y-%s) ... It appears the answer could be as simple as today=$(date +%m-%d-%Y-%s) sleep 15 ... Consider putting those rsyncs inside a bash function named sync_all. Then you could run everything twice -- immediately, and after a delay. sync_all sleep 15 sync_all The cool thing about rs...
How to add file markers to check if script is already running
1,447,153,121,000
In my tests, I always get the correct result so far with this: [fabian@manjaro ~]$ sleep 10 & echo $! [1] 302657 302657 But sleep and echo are getting executed simultaneously here, so I would expect that it can sometimes happen that echo executes before the value of $! is set properly. Can this happen? Why doesn't it...
So sleep 10 & echo $! is two commands sleep 10 & echo $! That they're on the same line doesn't change this. So the shell will fork() a new process and put the process ID of the new process into $!. Then the new process will run the sleep and the other process will run the echo. So you can be sure $! will always ho...
Will "$!" reliably return the correct ID with "&"?
1,447,153,121,000
My question is about signals and handling them inside the operating system kernel. I know that every process has it own signal_handler() table: a 31 bit array for signals (pending_signals), and when a signal arrives, do_signal() is invoke, and it calls to the relevant signal_handler() routine, which is running in the...
While reading your question. I think you said that the signal handle of B is run in the context of A. This does not sound correct. This would lead to a security loop hole. Signal handlers are always called in the context of the owning process. This then answers your 2nd part about SIG_CHILD. You also ask why run signa...
how signals are handled in linux kernel [closed]
1,447,153,121,000
I'm facing an unexpected behaviour of the wait builtin. ~ ❯ sleep 1 & [1] 72009 ~ ❯ [1] + 72009 done sleep 1 ~ ❯ wait 72009 ~ ❯ echo $? 0 Although the PID doesn't exist anymore wait still exits with zero exit status. Questions What is the reason for this behaviour? How does wait works? What does it do beh...
Bash’s wait returns 0 in this case because it “remembers” that process 72009 was one of its children, and it remembers its children’s exit codes, and that exit code was 0. (The documentation is somewhat misleading here since it mentions “active” processes explicitly.) Behind the scenes, wait determines whether a given...
Wait command works when pid doesn't exists
1,447,153,121,000
I searched a lot but didn't find a solution. So it can be silly question. The format of waitpid is pid_t waitpid (pid_t pid, int *status, int options) The pid parameter specifies exactly which process or processes to wait for. Its values fall into four camps: < -1 Wait for any child process whose process group ID i...
You can only wait for children from your process. If the child changes it's process group id, the new process group id can be used as a negative number with waitpid(). BTW: the function waitpid() is deprecated since 1989. The modern function is: waitid() and it supports what you like: waitid(idtype, id, infop, opts) ...
Use waitpid for child having groupid 1
1,628,980,198,000
I already have a /boot partition on a USB stick and a LUKS partition on my computer, which correspond to a fulldisk encryption scheme with Ubuntu 21 I want to put the header of my LUKS partition onto the USB (either on the /boot partition or on another new partition on my USB) I have put the header (with cryptsetup lu...
As pointed out in the comments by @A.B the solution is a raw partition that contains the header instead of the header file inside a partition (which is a hassle due to the need to mount the filesystem first) To copy the header (around 16MB for LUKS2) to a partition (/dev/sdb larger than the header size) two options. ...
Detached LUKS header (on USB) for an existing full-disk encryption device with Ubuntu
1,628,980,198,000
I recently installed Antergos (which is basically Arch) and set it to use full disk encryption. Now, I want to migrate from encrypt to sd-encrypt because I want to be able to hibernate and I couldn't put swap partition in the same LUKS volume.. Background During the setup: I used LUKS for / partition and swap partiti...
I don't use Grub myself (but Arch and sd-encrypt) but from my kernel options I guess you would have to transform your configuration to look like (don't forget to backup your old configuration before switching). HOOKS="base systemd autodetect modconf block keyboard sd-vconsole sd-encrypt resume filesystems fsck" GRUB_...
Migrate Arch from encrypt to sd-encrypt
1,628,980,198,000
Are there any full-disk encryption schemes that can be done without an initramfs, rather getting the encryption key from the kernel cmdline? I know this sounds insecure, as an attacker could just read the bootloader files; but due this device's boot process, I have to manually enter the cmdline at every boot. I alread...
No. Well, normally F.D.E. has to be in hardware (not Linux) else where does the kernel come from. Assuming you've resolved that (perhaps related to your suggestion of a less typical boot process)... It is not possible to mount the root fs from a block device decrypted by a command-line option. Nor is it possible to ...
Linux full-disk encryption without initramfs