date
int64
1,220B
1,719B
question_description
stringlengths
28
29.9k
accepted_answer
stringlengths
12
26.4k
question_title
stringlengths
14
159
1,294,207,772,000
I'm observing a high load average on a certain machine (about 9) in all three load fields. I understand load as the number of processes in state "run" / currently desiring CPU time. Am I correct at reasoning that if N processes are running on my machine this cannot produce a load greater than N? Also, does the load c...
Load average is usually described as "average length of run queue". So few CPU-consuming processes or threads can raise LA above 1. There is no problem if LA is less than total number of CPU cores. But if it gets higher than number of CPUs, this means some threads/processes will stay in queue, ready to run, but waitin...
Understanding top and load average
1,294,207,772,000
By running top, htop, uptime, etc. we can see the load average as three values indicating the average load for the last 1/5/15 minutes (well not really, but that isn't the question here). Sometimes I'll notice that I have a fairly high load average for the last 15 minutes, but the current load is very low. Is there a ...
I suggest to use atop. It's a daemon gathering all 'top' information every 10 minutes by default and you can just go back in time viewing these 'top' snapshots. Adjust the default interval setting to your needs (consumes more disk space if set more frequently). Just yesterday, I answered a similar question, in which I...
Any utility to find source of system load / load average for a certain period?
1,294,207,772,000
I have an rsync cron job which is pushing the server load and triggering monitor alerts. If I set the job to be run with a high nice level, would that effectively reduce the impact it has on system load values?
It will not reduce your load. It will only let other processes use CPU time more often if there is a possible resource contention (several processes "competing" for not enough available CPU time).
Is setting a higher nice level for a process an effective way to reduce its impact on system load/CPU time?
1,294,207,772,000
man ksoftirqd indicates that: If ksoftirqd is taking more than a tiny percentage of CPU time, this indicates the machine is under heavy soft interrupt load. I'm working with a Debian Wheezy system under generally high system utilization in which ksoftirqd processes utilizes excessive cpu and disk resources for a ...
Check /proc/interrupts to find if one of or more interrupts occur excessively. Hint: Several thousand interrupts per second are no cause for alarm. Excessive interrupts (aka interrupt storms) can have multiple reasons, one of them even being hardware issues (noisy interrupt line). To further answer your question we ne...
How to debug causes of excessive ksoftirqd resource usage?
1,294,207,772,000
I am looking for a way to profile a single process including time spent for CPU, I/O, memory usage over time and optionally system calls. I already know callgrind offering some basic profiling features but only with debugging information and lacking most of the other mentioned information. I know strace -c providing a...
Meanwhile I wrote my own program - audria - capable of monitoring the resource usage of one or more processes, including current/average CPU usage, virtual memory usage, IO load and other information.
Detailed Per-Process Profiling
1,294,207,772,000
My website is being DoS'ed by Google webspiders. Google is welcome to index my site, but sometimes it is querying a tagcloud on my site faster than my webserver can produce the results, making my webserver run out of resources. How can I limit access to my webserver in such a way that normal visitors are not affected?...
Try the mod_qos Apache module. The current version has the following control mechanisms. The maximum number of concurrent requests to a location/resource (URL) or virtual host. Limitation of the bandwidth such as the maximum allowed number of requests per second to an URL or the maximum/minimum of downloaded kbytes p...
Throttling web crawlers
1,294,207,772,000
My understanding of load average lead me to be quite shocked with my current system. The CPU in my workstation is an i7 with hyperthreading enabled, and cat /proc/cpuinfo produces 4 'cpu's. That all given, my PC can generate over a 16 in all the load average slots from 1 minute to 15 minutes while compiling packages f...
1.0 is an average of one job waiting over the given time period, not 1 core at 100% utilisation. An idle computer has a load number of 0 and each process using or waiting for CPU (the ready queue or run queue) increments the load number by 1. Most UNIX systems count only processes in the running (on CPU) or runnable ...
How does load average work with modern CPU's?
1,294,207,772,000
I am launching non interactive jobs using batch, and I would like to increase the load limiting factor in order to use all 8 of my cores. I am on Ubuntu 16.04 LTS. From what I understand, batch uses atd to do the jobs. Jobs start when the load factor goes under a threshold, called the load limiting factor. It is said ...
Found a solution: Create a file: /etc/init/atd.override Add a line exec atd -l 7.2 Then sudo service atd restart It has to do with how the 'Upstart init daemon' works. Explanations there: http://linux.die.net/man/5/init If the file /etc/init/atd.override already exists with an line starting with exec, edit this line...
atd, batch // Setting the load limiting factor
1,294,207,772,000
$ file /lib/ld-linux.so.2 /lib/ld-linux.so.2: symbolic link to i386-linux-gnu/ld-2.27.so $ readlink -f /lib/ld-linux.so.2 /lib/i386-linux-gnu/ld-2.27.so $ file /lib/i386-linux-gnu/ld-2.27.so /lib/i386-linux-gnu/ld-2.27.so: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, BuildID[sha1]=7...
It is both, which is perfectly valid. The ld.so-style naming scheme is largely historical; the first dynamic linker in this style was SunOS 4’s, which was named ld.so (I have its history somewhere, I’ll clarify this once I’ve found it). But there are valid reasons for it to be named like a shared library rather than a...
Is ld.so an executable?
1,294,207,772,000
Is there a way to return the load averages, excluding any load caused by nice'd processes? We have a load balancing mechanism in place that checks the load of multiple Linux servers, and submits a job to the server having the lowest load. We had a scenario where all servers had too high a load and so no server could ...
You can write up your own script that uses ps to list all processes in the run/runnable state without a nice value greater than 0. The specific syntax you need to use will differ based on your version of ps. Something like this may work: ps -eo state,nice | awk 'BEGIN {c=0} $2<=0 && $1 ~ /R/ { c++ } END {print c-2}' ...
Get load average excluding niced processes
1,294,207,772,000
I am attempting to stress a server as much as I can before it goes into production. I’m using Jmeter and have been able to add a little more stress by modifying scripts. I’ve also modified JVM options but still not enough. What are some of the best ways to increase server load?
Several ways to do that. You can simply use dd, like : dd if=/dev/zero of=/dev/null Or there are other tools like stress : stress --cpu 2 --timeout 60 The above will stress two cores for 60 seconds. Or you can also use an endless while loop : while true; do true; done Another possibility is this fork bomb - car...
How to increase server load?
1,294,207,772,000
I'm using tar to backup my server once every day. Even though CPU usage (of the tar command and the system overall) doesn't go over 10%, my system load is like 3.98 3.71 3.82 when the script is running. (on a 2 core 4 thread system) Why does tar show so little CPU in practice, while producing such a high system load i...
You see a high system load because tar spends a lot of time waiting for I/O. You see a low CPU usage because tar uses very little CPU time: it's mostly just copying some bytes when the disk delivers them. Linux includes time waiting for I/O in the load average (unlike many other Unix variants), but not in a process's ...
Why does tar have a low CPU usage but high system load?
1,294,207,772,000
I just compiled the qcserial module which is a driver module for a Gobi USB modem. Now I have a couple of questions. Now I have two files: drivers/usb/serial/qcserial.ko and drivers/usb/serial/qcserial.o which one is the correct driver? Also, as I understand, it will need to go into /lib/modules/3.11.6/kernel/drivers...
You'll need to create a kernel package (make tar-pkg). Then copy it to your ARM system, for example to /tmp and extract to /. You'll get all driver modules installed into correct folders including proper modules.dep and other files needed to automatically resolve module dependencies. modprobe qcserial should be workin...
How can I load a module at runtime?
1,294,207,772,000
I'm doing some load testing on a new dedicated web server, and after a certain amount of strain is put on the server I have to wait a minute for the one-minute load average to climb back down so that my testing remains fairly accurate. Is there any way to set the load averages back to 0, or whatever they are normally ...
There is not. It's a rolling average.
Reset Load Averages?
1,294,207,772,000
I am using emacs24, and I started using elpa to download the packages to ~/.emacs.d/elpa folder. How can I load these packages? For instance, I have tried (see below) for rainbow-delimiter but it doesn't work. I have tried commenting out a few lines and keeping others but nothing sticks. ;; Paren checking ...
If you're using the default elpa settings, the .el files will be installed in subdirectories of ~/.emacs.d/elpa. When you use require, it doesn't recursively search the directories in your load path. To get this effect, you can use the following snippet: (let ((default-directory "~/.emacs.d/elpa")) (normal-top-lev...
emacs elpa load packages
1,294,207,772,000
I am running some test on Amazon EC2 instances and we want to make the CPU always busy at above 80%. What I have is a program main that needs to run in high priority and I want to launch another program, preferably some math C code or a bash script that loads the CPU to over 80%. What programs are there to use for suc...
Occupying one CPU at 100% (minus overhead) is easy in the shell: while true; do :; done If you want to reduce the load, introduce sleeps. i=0; while [ $i -ne 0 ] || sleep 0.001; do i=$(( (i+1) % 10000 )); done Tune 10000 up or down to get the desired load. The scheduling priority is set by nice. You'll need to be ro...
Program to test CPU load and process priority
1,294,207,772,000
I am using my local workstation to run applications stored on our local cluster. To load and run an application, I normally use: module load xxx However, there is a an application on my computer that already has the same name as a module I am trying to load. I am afraid there might be a conflict when I load such a m...
Modules is a very handy package for switching your environment from being setup for one group of tools, transforming the $PATH, $LD_LIBRARY_PATH, etc. so that it's configured for an entirely different set of tools. I'm familiar with it from working in the CAD/CAM industry where we used a in house product that did esse...
Load application with module load and specify a different name from the default [closed]
1,294,207,772,000
In case I have 8 powerful machines, what is the proper way to distribute and balance the load from user applications and scientific experiments? Is virtualization right way to go, or is there any kind of load manager software to implement this?
Look into batch queueing software like TORQUE, PBS, Slurm etc. It lets you create a queue where users submit their tasks, and the software runs that on the machines available. Please note that this approach works well only with non-interactive stuff.
Proper way distribute several scientific experiments across multiple servers?
1,294,207,772,000
The output of top command shows that CPU load is about 82!. The system has 32 cores. Normally, each core increment the load by one. How can I find out what is exactly happening? top - 11:20:43 up 88 days, 17:03, 1 user, load average: 81.82, 82.88, 83.36 Tasks: 755 total, 6 running, 748 sleeping, 0 stopped, 1 z...
About the system load, as it can be seen from vmstatit is mostly CPU time from the application processes. From the column cpu - us - Time spent running non-kernel code. (user time, including nice time), as you see is 92%, 100%,100%,99% (of 100%). iostat also confirms the system use is (almost) entirely CPU-bound, as t...
finding the root of high CPU load
1,294,207,772,000
I'm using iostat to get the current disk load each second with iostat -dx 1 (specially, %util column). However, I'd like to put this in a bash script and control the interval with the watch command such as: watch -n 1 ./script.sh. Running the following in script.sh won't print a thing: io_load=`iostat -dx 1` echo $io_...
The man page of iostat says: The interval parameter specifies the amount of time in seconds between each report. The first report contains statistics for the time since system startup (boot), unless the -y option is used (in this case, this report is omitted). Each subsequent report contains statis...
Current disk load
1,294,207,772,000
I found that my "PCI Adapter" overheats when load is above 4.0 (having 4 cores). It does NOT overheat when the load is below 4.0 (but I had an overclocked memory that was causing trouble as I explain at the end), so my focus is on lowering the system load. What overheats is just the k10temp-pci-00c3 PCI Adapter (accor...
You're asking the wrong question: you've got an overheating system which should be solved by cooling the system. Playing games with process load is going to yield an unsatisfying hack. And since you've got hardware running at its thermal limits, you can fairly expect that problem to worsen. If you cannot remedy the ha...
Should I care for applications that increase the system Load in order to prevent overheating?
1,294,207,772,000
When my top shows a load of 19/20 and my ps shows root@server:/home/nohup# ps -eo pcpu,pid,user,args | sort -k 1 -r | head -5 %CPU PID USER COMMAND 122131 18695 mysql /usr/sbin/mysqld xxxxx 0.1 961 root [kdmflush] 0.1 937 root [kdmflush] 0.1 1025 root [jbd2/dm-2-8] But mpstat shows root@serve...
Debian Squeeze is running procps 3.2.8 which was a very old version of the library. mpstat shows numbers similar to top, so it is basically the numbers of the last few seconds. ps shows the stats from when the process started. The numbers are unusual though which points to something overflowing or wrapping. If you wan...
top/ps/mpstat showing different output
1,545,373,188,000
I have noticed that a logoff (log out) from my X user session will kill any tmux session I have initiated, even sessions I had run with sudo tmux and similar commands. I am sure that this formerly did not happen, but some recent change has effected this behavior. How do I maintain these tmux (or screen) sessions, even...
This "feature" has existed in systemd previously, but the systemd developers decided to effect a change in the default, to enable the setting for termination of child processes upon log out of a session. You can revert this setting in your logind.conf (/etc/systemd/logind.conf): KillUserProcesses=no You can also run ...
Prevent Logoff from Killing tmux Session
1,545,373,188,000
I want to run a script before I log out of my GNOME session, to warn myself if I have forgotten a pendrive plugged into the machine. However, all solutions I have found have not been enough for me: This similar question suggests editing the /etc/gdm/PostSession/Default file, but I don't have the permissions to do tha...
I finally managed to actually test the Python script I mentioned as the second option in my question. It turns out that it does work when asking to shut down as well, not just on reboot.
How can I run a script during GNOME logout if I don't have admin privileges?
1,545,373,188,000
I'm logging in to a system via SSH and I'd like to be able to force a command to be run on logout, whether that's an intentional logout (exiting the shell) or because my SSH connection has dropped/been terminated. Is there any way to set this up? My best guess right now is to change the login shell to a program that...
The best way to do this would be to use pam. In /etc/pam.d you will have several files, one of them will be called sshd. If you only want to affect ssh, and not other logins (such as a GUI, or real TTY), you want this file. If you want to affect all logins, you'll want a 'common' file. The name of this other 'common' ...
Force command to be run on logout or disconnect?
1,545,373,188,000
On multiple computers running Ubuntu 14.XX, I ran the command "killall init" as user, and was immediately logged out. I could log back in again without a problem. Why is this? What's going on behind the scenes?
On newer Upstart systems, a session init process is started when you login using the GUI. Since Ubuntu uses Upstart, there's an init process for your session. Test it out using pstree -ps $$ in a terminal: $ pstree -ps $$ init(1)───lightdm(1741)───lightdm(9511)───init(9526)───/usr/bin/termin(9570)─┬─gnome-pty-helpe(97...
Why does running `killall init` as user log me out?
1,545,373,188,000
I have a system service that is executed for selected users. Name is serv@<uid> (<uid> is UID of the user). I want to share user's resource limits with the service (place it into user-<uid>.slice) and I also want to use his permissions. /etc/systemd/system/[email protected] [Unit] Description=My service for user %i [...
You can change logind configuration: /etc/systemd/logind.conf [Login] … KillUserProcesses=no … This also changes behavior for other services and background processes (like screen, tmux). See issue #3483; Run systemctl restart systemd-logind after that.
System service running as user is terminated on logout
1,545,373,188,000
I would like to do that using the command-line, because sometimes my computer freezes and I need to force a shutdown (I know it's not good to the hardware). And: What is the difference between Halt and Shutdown commands?
Using the commands shutdown and reboot respectively. To log off from a terminal you can press Ctrl-D or type exit.
How do I shutdown, reboot and logout the system from the command-line?
1,545,373,188,000
I know I've tracked this down before but can't find the answer. When I start a bash shell on CentOS 7 (from X Windows GNOME or KDE), the variable TMOUT is set which causes the shell to timeout after the specified period of inactivity. The variable is readonly so I can't unset it or change it! unset TMOUT # prints bash...
To disable the time out I changed the file /etc/profile.d/local.sh. I commented out lines that were setting the timeout variable and making it readonly. vi /etc/profile.d/local.sh #export TMOUT=43200 #readonly TMOUT An alternative would be to set TMOUT=0 which means to disable the timeout. Man page for bash TMOUT is...
Where is TMOUT being set in CentOS 7? How can I disable it?
1,545,373,188,000
Possible Duplicate: How can I close a terminal without killing the command running in it? I have a very low-end "server" running Debian Squeeze that I occasionally ssh to. The system tends to be slow, e.g. running apt-cache search might take half a minute. Occasionally I find that I can't wait for a process to com...
On the assumption that you are using bash, ksh, zsh, or another similar shell, you can background the process, then run disown. Specifically, in bash you probably want disown -h. From bash's help page on disown: disown: disown [-h] [-ar] [jobspec ...] Remove jobs from current shell. Removes each JOBSPEC argum...
How can I tell a running process to disregard SIGHUP? [duplicate]
1,545,373,188,000
In my gnome GUI desktop of Ubuntu 12.04, Ctrl+Alt+Delete will log out instead of rebooting. But I was told that Switching to a text-based virtual console and pressing Ctrl+Alt+Delete will reboot the machine. It will shut down cleanly and reboot, which is much better than Alt+SysRq+REISUB. So I wonder if the abo...
Ctrl+Alt+Delete is actually a "magic" keystroke for the IBM PC-compatible hardware architecture that would call a BIOS reset. Since this kind of thing is dangerous for a system like Linux the decision was made to hook those keystrokes and do something else instead. This is controlled by init and you can see what it do...
What is the meaning and command executed on Ctrl+Alt+Del in Linux?
1,545,373,188,000
I have a debian 8.5 computer. In order to create new session I run command startx. With this command a new session is created. How can I via command close this session and to return to previous one?
Kill the master process of the X session. The master process is the one that started out in life as the child of xinit, i.e. ~/.xinitrc (which is typically a shell script). Usually the last thing .xinitrc does is to call a window manager or a session manager (e.g. twm, fvwm, gnome-session, …). To remember the process ...
How to close XServer session via command
1,545,373,188,000
How to get logout from Gnome session via command line ? Also Is there any way in GNOME to do "switch user" from command line ?
In Ubuntu 12.10... gnome-session-quit --logout Logs me out. dm-tool switch-to-greeter Lets me switch user.
Gnome Logout from command
1,545,373,188,000
I'm trying to write a shell script that does a lengthy batch job on a remote server. I'll be running the script over SSH. The thing is, I intend to start the script in the evening and collect the results the next morning; I'd prefer not to have my local computer have to run all night, as it's not needed as part of t...
Yes, if you start the script to run in the background, it will continue to run. Alternately, you can start the script by using the command on command-line. For example, you can say: ssh hostname -l loginname command and that will work.
Can a shell script running in a ssh continue to run if the SSH instance closes? [duplicate]
1,545,373,188,000
I have worked yesterday with my collegue on his computer and I logged in to my cluster account (with ssh) but I left the session open and I am home now. I don´t know if he closed the session after me. I need to log off (exit) all open sessions of my cluster from my computer. How can I log off all open sessions? Note: ...
First you'll need to connect to the machine(s) where you have left processes running. Use SSH. You can kill a process by sending a signal to it. In your case, the right signal for the job is SIGHUP. This signal is sent automatically when a terminal disappears (etymologically, it was sent when the modem hung up). If yo...
Log off remotely
1,545,373,188,000
I want to execute bash in subshell and when user exits from subshell, I want to execute some other commands (like for saving logs to file). Something like this: run.sh: #!/bin/bash function save_information_to_file() { echo "${date} ${time} new bash subshell ended !" } # Some commands etc. env PS1='SubShell:' b...
My first thought was .bash_logout too, but that only works for login shells. The most straightforward method, which works for both login and non-login shells, is setting a trap on exit. It works like this: trap "your_commands_go_here" EXIT For example, $ bash $ trap "echo goodbye cruel world!" EXIT $ exit exit good...
How to execute bash (in script) with own .bash_logout file?
1,545,373,188,000
I have some script on .bash_logout file. That script is running when a user is logging out using Ctrl+d or using exit command. If someone directly close putty application instead of logging out from the system, then .bash_logout is not running. Can anyone help me how to run .bash_logout even if someone close putty ap...
Added below function and a trap in .bashrc. The trap will trigger the function exit_session when the shell will get SIGHUP signal. exit_session() { . "$HOME/.bash_logout" } trap exit_session SIGHUP
.bash_logout is not running on exit of putty
1,545,373,188,000
I have a .bash_logout script that I've put in the home directories of the vagrant and root users of a VM (created, as you have already guessed, with Vagrant) that I'm using for development. The script copies all my important dot files into a directory that is shared between the host OS and the guest OS, so that I can ...
You can create a login shell with su like so: su - [user] If you do not wish to create a login shell, you can use an exit trap. trap_exit() { . "$HOME/.bash_logout" } trap trap_exit EXIT Put the above code in the users' .bashrc files.
Run "logout script" for non-login shells
1,545,373,188,000
I'm doing some stress testing of a piece of software that can run shell commands. Periodically, the system logs me out during stress testing. My record of the commands that triggered this always yields commands that run just fine on their own and do not log out. How can I tell what triggered an unexpected logout? Ed...
It depends on, what type of stress test you are doing. When the kernel doesn't have enough resources to continue, random process are killed. This happens only on realy high loads, for example when you don't have a pagefile and all your memory is used in some processes.
What killed tty main process suddenly?
1,545,373,188,000
I have been trying to run a command to clean up some of my temporary files every time I exit a shell. I initially thought that this would be the job of .zlogout but it doesn't seem to be executed if I, for example, have multiple shells open in my terminal emulator (kitty). From what I have found in the doc, .zlogin an...
There's an example in this zsh guide which sources ~/.zlogout for non-login shells using the TRAPEXIT function. This seems to be exactly what you want. TRAPEXIT() { # commands to run here, e.g. if you # always want to run .zlogout: if [[ ! -o login ]]; then # don't do this in a login shell # b...
How to run a command every time that I exit a zsh shell (including non-login shells)
1,545,373,188,000
Based on this thread I modified my /etc/acpi/powerbtn.sh script to account for LXDE sessions: # getXuser gets the X user belonging to the display in $displaynum. # If you want the foreground X user, use getXconsole! getXuser() { user=`pinky -fw | awk '{ if ($2 == ":'$displaynum'" || $(NF) == ":'$displaynum'" )...
So after some debugging work I was finally able to trace the problem back to the user detection by pinky. For some odd reason pinky -fw won't list the user display under normal circumstances. Only after starting a root session it's able to detect the correct display: # DEBUG OUTPUT WITHOUT ROOT SESSION ##############...
Why won't this shutdown script work when executed by ACPID?
1,545,373,188,000
Since I switched to Wayland on Debian11/KDE starting the computer from standby in around 90% of cases shows a black screen and one needs to use ctrl+alt+f{id} and run loginctl unlock-session {id2} to be able to switch back to the running session by pressing ctrl+alt+F1. This is a security issue because one can resume ...
TMOUT causes idle interactive shells to exit, it doesn’t close desktop sessions. If you don’t want to have to remember to log out from your “rescue” VTs, it seems like a good solution to me: your rescue VT will automatically log out after however many seconds you specify in TMOUT (e.g. 120 — note that this will affect...
How to log out all inactive terminal sessions in GNU/Linux?
1,545,373,188,000
I have Linux Mint 14 Xfce (4.10) and have also installed LXDE desktop, so I can choose between these sessions if I want. Normally I would set one as default and at startup I am not asked for username&password and am logged in automatically as intended. (Under Settings/Login Window/Security - "Enable automatic login" i...
Trying many possible combinations of settings I solved it but the conclusion is that there is something amiss with Xfce's session manager settings or GUI. What I have verified is: As stated in the question, when this problem happens, under Settings/Login Window/Security - "Enable automatic login" is checked, like so:...
How to enter/choose session after logout without password in (Linux Mint) Xfce?
1,545,373,188,000
I am having a situation where I logged in to a RHEL 5.6 system and started VirtualBox. After closing the VirtualBox, I am having a situation where the menu bar which has the option to shutdown or lock screen or log off the system is not present. I believe the reason might be due to network load or something. I can sh...
Possible ways to get logged out: You kill the X server with a key combination: Ctrl-Alt-Backspace, if it is enabled, You kill the process of the X server from any terminal (you have to be root, but you can do this through SSH remotely as well), You ask the window or session manager to quit (how that can be achieved u...
Log off user using terminal
1,545,373,188,000
I am trying to execute two commands one on logon and one on logoff. For the log on one, I put my script into /etc/X11/xinit/xinitrc.d and this works. I'd like it to be system-wide so I can use any WM.
Have a look at your display manager (lightdm, gdm, kdm, xdm, wdm). Newer lightdm versions can have a session-cleanup-script entry in the [SeatDefaults] section of /etc/lightdm/lightdm.conf. For gdm, you can put a script in the PostSession directory. For kdm, xdm and wdm have a look at this answer at SuperUser.
Is there a way to execute a command when a user logs off from X?
1,545,373,188,000
Connected to a remote server via SSH. On occasion, I run a specific bash script. When certain conditions are met (it's work completed successfully), I wish to be automatically logged out of the SSH tunnel. In the normal login shell, I simply type logout to logout. I am unable to do this from a bash script. If I put l...
If you want to logout after the successful completion of /path/to/shell-script.sh, use: /path/to/shell-script.sh && logout A ruder way to do it would be to have the script kill the parent: kill -HUP "$PPID" (PPID is a variable that is set by the bash shell, for one).
How to log myself out of ssh, from a bash script?
1,545,373,188,000
I want to be able to logout inactive sessions on my webserver. I have done this like so: 13. Restrict idle users. Timeout after a certain pre-defined amount of time. a. In the directory /etc/profile.d: i. Create a file called autologout.sh and add the following lines: TMOUT=300 readonly TMOUT export TMOUT This sets ...
Many years ago, I used to use a program called timeoutd to do exactly this. It seems to have vanished from debian since I last used it (or maybe it was never in debian and I compiled it myself - I can't remember, I last used it in the mid-1990s). Anyway, I found a copy of it at: https://launchpad.net/ubuntu/+source/t...
Inactivity-based auto logout from all sessions
1,545,373,188,000
There is a process 'vmtoolsd' /usr/bin/vmtoolsd -n vmusr left when a user logs out. I have to type root password to shutdown or restart because of this. How to prevent this from happening? And what package provide this command? I will remove the package to get rid of the problem as a last resort. I don't need to run v...
This is an existing bug that was discussed here on the ArchLinux forums. You can determine which package an executable is a member of with this command: $ rpm -qf /usr/bin/vmtoolsd I believe this executable is part of the open-vm-tools package which is a package that's part of VMware. It's the opensource project that...
vmtoolsd doesn't end after logout
1,564,654,118,000
My goal is to get the disks greater than 100G from lsblk. I have it working, but it's awkward. I'm pretty sure it can be shortened. Either by using something totally different than lsblk, or maybe I can filter human readable numbers directly with awk. Here's what I put together: lsblk | grep disk | awk '{print$1,$4}' ...
You can specify the form of output you want from lsblk: % lsblk -nblo NAME,SIZE mmcblk0 15931539456 mmcblk0p1 268435456 mmcblk0p2 15662038528 Options used: -b, --bytes Print the SIZE column in bytes rather than in human-readable format. -l, --list Use the list output format. -n, --noheadings D...
Can I shorten this filter, that finds disk sizes over 100G?
1,564,654,118,000
Prior to running the dd command, the command lsblk returned the output below: NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 931.5G 0 disk The command dd if=/dev/urandom of=/dev/sda conv=fsync status=progress is run. The device however loses power and shuts down. When...
Several possibilities: Linux supports a lot of different partition table types, some of which use very few magic bytes, and then it's easy to mis-identify random data (*) [so it's possible to randomly generate a somewhat "valid" partition table]. Some partition table types have backups at the end of the disk as well ...
Why does writing random data using dd result in disk partitions?
1,564,654,118,000
Is there a way to know which partition you actually booted from? fdisk -l reveals a "Boot" column that I definitely don't have on my NVME. Is this just legacy information? Device Boot Start End Sectors Size Id Type /dev/sda1 * 2048 1126399 1124352 549M b W95 FAT32 /dev/sda2 11...
Since your system apparently boots in UEFI style, the answer to the titular question is: Run efibootmgr -v as root, see the four-digit ID on the BootCurrent: line (usually the first line of output), then look at the corresponding BootNNNN line to find both the PARTUUID of the partition to boot from, and the filename c...
How do I tell which partition I booted from?
1,564,654,118,000
I'm constantly having the situation where I want to correlate the output of lsblk which prints devices in a tree with their name in the scheme of /dev/sdXY with the drives /dev/disk/by-id/ names.
The by-id names consists of the drive model together with the serial something which lsblk can be instructed to list: lsblk -o name,model,serial The output of this command will look something like this: NAME MODEL SERIAL sda SAMSUNG HD203WI S1UYJ1VZ500792 ├─sda1...
Make lsblk list devices by-id
1,564,654,118,000
If I put a USB-drive in, it will automount. I can see it with lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sdb 8:16 1 7,5G 0 disk └─sdb1 8:17 1 7,5G 0 part /media/user/usb-drive If I unmount it with umount umount /media/user/sdb1 it will still be visible with lsblk, but not mounted any more: N...
Mounting just means "set up the operating system to actively use the some (part of) a block device". Often there is some "busy" or "dirty" on the superblock that gets changed when a file system is mounted, but otherwise the hardware is unaffected. OTOH, eject sends a SCSI "START STOP" command to the device, with optio...
Why is usb-drive not visible with `lsblk` after having been ejected from Thunar?
1,564,654,118,000
I've been searching around, and can't find a clear answer, or I find that the answer is 'no' when my system shows me otherwise. I'm running Arch Linux, and while attaching new HDD into a ZFS pool I noticed that my main SSD system drive has a LABEL attribute/property (not sure what the terminology is). NOTE: I'm talkin...
That depends on the contents of the device. More specifically, it depends on whether or not there is a known superblock that provides a label. This can be a filesystem superblock (like ext4, xfs, fat, iso9660, ...), a swap device, a raid superblock (mdadm), or even a crypt container (LUKS2). Accordingly you can specif...
How to set a disk's (not partition) LABEL?
1,564,654,118,000
I want to capture all disks that do not have a filesystem ( all disks that mkfs not runs on them ) I tried the below, but still gives the OS ( sda ). What is the best approach with lsblk or other command to capture all disks that are without filesystem? lsblk -f | egrep -v "xfs|ext3|ext4" NAME FSTYPE ...
lsblk -o NAME,FSTYPE -dsn This will print a list of block devices that are not themselves holders for partitions (they do not have a partition table). The detected file system type is in the second column. If its blank there is no recognized file system. So to get the output you want in one command lsblk -o NAME,FSTY...
How to capture all disks that don’t have a file system
1,564,654,118,000
I can capture the disk devices of my Linux machine with the following command: lsblk -lnb | numfmt --to=iec --field=4 | grep disk | awk '{print $1}' sda sdb sdc sdd In my bash script I used the line below to test if the script's argument matches one of the disks on my machine: if [[ ` lsblk -lnb | numfmt --to=iec --f...
You don't seem to be using most of the components of that command. All you need is: lsblk -lnb | awk '$NF=="disk"{print $1}' Then, to avoid the error message when no argument has been given, you need to quote it so grep is given something to search for even if that something is an empty string: if [[ "$(lsblk -lnb | ...
bash + how to compare arg to one of the disks in linux machine
1,564,654,118,000
I have a script where I want to list USB devices using the command lsblk. The command: $ lsblk -o NAME,TRAN,VENDOR,MODEL | grep usb which results in sdb usb Kingston DataTraveler 2.0 sdc usb Kingston DT 101 G2 I want to save the result in a variable to work later, so I write $ usbs=$(lsblk -o NAME,TRAN,VE...
Question: Is there a way in which, using the grep command, I can store the result of the command as two whole lines? Yes, and your assignment code was correct: usbs=$(lsblk -o NAME,TRAN,VENDOR,MODEL | grep usb) This does exactly as required; in a single variable, (not an array), it stores two lines from lsblk sep...
Iterate lines of string variable in bash
1,564,654,118,000
I want to capture only the disks from lsblk as showing here fd0 also appears in spite its not really disk for use in this case we can just do lsblk | grep disk | grep -v fd0 but maybe we missed some other devices that need to filter them by grep -v what other disk devices that could be appears from lsblk | grep disk a...
If you want only disks identified as SCSI by the device major number 8, without device partitions, you could search on device major rather than the string "disk": lsblk -d | awk '/ 8:/' where the -d (or --no-deps) option indicates to not include device partitions. For reasonably recent linux systems, the simpler lsbl...
lsblk + capture only the disks
1,564,654,118,000
On Linux, the command lsblk -o partlabel will display the partlabel for block devices. I have used gdisk to change a partlabel. After the change, lsblk is still reporting the old value of the partlabel. (Aside: The paths /dev/disk/by-partlabel/* are also still using the old partlabel values.) Is there some way to refr...
I found an answer: sudo udevadm trigger Source: http://ptspts.blogspot.com/2009/09/how-to-refresh-devdisk-on-linux.html Update #1: It appears the sudo may be unnecessary. So: udevadm trigger Update #2: It appears that sudo is necessary to propagate a changed Btrfs filesystem label. (While this is not the question ...
How to update/refresh changed partlabels as reported by lsblk?
1,564,654,118,000
I'm using Debian. When reading man lsblk I see mention of a udev db: The lsblk command reads the sysfs filesystem and udev db to gather information. If the udev db is not available or lsblk is compiled without udev support than it tries to read LABELs, UUIDs and filesystem types from the block device. In this case ro...
The UDev database is stored in /run/udev/data. It used to be stored in /dev/.udev* before /run was introduced and the location was configurable in udev.conf but it's no longer possible.
Where is the udev database stored and what sets the permission?
1,564,654,118,000
in my bash script I use the syntax lsblk | grep sd in order to capture all disk in my HW machines ( not include flash card or rom ) I just worry that some disk device name will be diff from sd , and I will missed these disks is it possible ? lsblk | grep sd sda 8:0 0 150G 0 disk ├─sda1 ...
Most disk drivers use the sd prefix, but not all. Historically sd stood for “SCSI disk”, but most disks use a protocol which is close to SCSI, and most of Linux's disk drivers use the generic sd layer plus a controller-specific part. However, this is not an obligation, so you need to check with your hardware. For exam...
Do all disks devices in my HW machines start with - sd?
1,564,654,118,000
I have recently started using Linux and would love to know how to interpret the output from the lsblk -f command. More specifically, I would like to know the different partitions and sizes. For instance, I understand that ext4 and xfs are different file systems in unix. But the entire picture has a tree structure. So...
You have two disks, sda and sdb. Your second disk, sdb doesn't have a partition table and is formatted directly to ext4. Your first disk has 3 partitions, sda1 (from its size, I assume it's a BIOS boot partition), sda2 used for /boot and sda3 which is used as LVM Physical Volume (or LVM2_member as shown by lsblk here)...
Meaning of the output from lsblk command
1,564,654,118,000
In the light of emmc wearout monitoring I'm wondering about the size as displayed inside a running Linux OS. An emmc chip has an internal manager which keeps track of the usage intensity of all the different byte registers. In theory, a flash device like SSD, USB stick or emmc chip should shrink in capacity when the e...
No. A device with internal wear leveling like eMMC and some flash drives will not advertise their full capacity in the first place. So, a device may have 1536 blocks but shows only 1024 to the system. The 1024 blocks that can be accessed by the OS are never guaranteed to be the same blocks, they can be re-allocated an...
Does Linux update the size of a block device?
1,564,654,118,000
My disk is sda. There is the size file /sys/dev/block/8:0/size. Its unit is sectors. When I run strace lsblk I can see it reading this file. But how does lsblk get the sector size to later show the total disk size in bytes? Because I cannot see lsblk reading the file hw_sector_size nor physical_block_size.
It doesn't because it doesn't need to, the sector size used in /sys/block/<device>/size is always 512 regardless of the actual physical sector size of the device. I wasn't able to find a documentation for this, so I'll refer to this answer which also has some links to the kernel code in the comments where it is stated...
How does lsblk obtain sector size?
1,564,654,118,000
On openSUSE Leap 42.3, lsblk output is like below which doesn't show anything about / i.e. root. Now my question is what about root file system? > lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 931.5G 0 disk ├─sda1 8:1 0 556M 0 part /boot/efi ├─sda2 8:2 0 333G 0 part /boot/grub2...
/dev/sda2 contains a btrfs filesystem (with the UUID blah-blah-1). This filesystem has many subvolumes. lsblk displays the mount point of one of the subvolumes. I don't know how it chooses. Since lsblk lists volumes but only has room for one mount point per volume, it can't list all mount points. An obvious omission i...
lsblk doesn't show anything about root file system
1,564,654,118,000
we want to create 2 partitions from each new disk by parted command as the following example: sdg 8:96 0 50G 0 disk ├─sdg1 8:97 0 25G 0 part └─sdg2 8:98 0 25G 0 part as example above disk size is 50G and we want to create 2 partitions from each disk we do...
As always, the first place to start should be the documentation available on your machine, man parted: mkpart [part-type name fs-type] start end Create a new partition. part-type may be specified only with msdos and dvh partition tables, it should be one of primary, logical, or extended. name is required for GPT part...
parted + is it correct to create disk partitions in Linux only by percentage
1,564,654,118,000
I need to filter the result of this command: lsblk -rno "name,size,mountpoint,fstype" | grep -v 'sda' Let me give a result of the above command on my computer: sdb 223,6G sdb1 179,8G /VMs/qemu ext4 sdb2 29,5G [SWAP] swap sdc 15G ntfs sdd 7,5G sdd1 7,5G ext4 The filtering I need is: Only the ones which are NOT moun...
If you simplify your requirement to being a list of partitions that are not mounted but that contain a filesystem, you can do this using awk lsblk -rno name,size,mountpoint,fstype | awk 'NF==3 {print $1, $3}' The awk filter considers lines from lsblk that have exactly three space-separated fields, and prints the firs...
filter lsblk command using awk or grep
1,564,654,118,000
I'm currently running Arch. I simply want to change lsblk to always display as if the-o model was selected in addition to the standard options. I suppose I could rename lsblk and put a copy in the folder that would call it with that option, but that would mess up passing other arguments as needed.
you don't need to rename, copy... just: alias lsblk='lsblk -o model' so every time you run lsblk you have the output of lsblk -o model [EDIT] I misunderstood the question, for which I propose the following solution. you can create a function, let's call it lsbk, to do what is required: lsbk() { lsblk $@ -o +model; }...
How can I change lsblk to show model by default?
1,564,654,118,000
I was flashing a new operating system to a device, but after the process was complete, I couldn't boot into it. I then checked the disk, and I noticed something strange. Different tools report different sizes for the disk, even though it should be approximately 120GB in size. So, I decided to: dd if=/dev/zero of=/dev/...
By "flashing a new operating system to a device", did you mean writing a complete disk image, including partition tables? Note that your dd if=/dev/zero of=/dev/sda should have certainly overwritten the DOS-type partition table, but if you did not trigger a rescan of the disk afterwards, the system will still be using...
Disk size is variable
1,564,654,118,000
we can print all disks by the following ( on our RHEL machine ) fdisk -lu | grep "Disk /dev" Disk /dev/sda: 247.0 GB, 246960619520 bytes, 482344960 sectors Disk /dev/sdb: 4294 MB, 4294967296 bytes, 8388608 sectors Disk /dev/sdc: 4294 MB, 4294967296 bytes, 8388608 sectors Disk /dev/sdd: 4294 MB, 4294967296 bytes, 83886...
From fdisk man page: In the case the size is specified in bytes than the number may be followed by the multiplicative suffixes KiB=1024, MiB=1024*1024, and so on for GiB, TiB, PiB, EiB, ZiB and YiB. The "iB" is optional, e.g., "K" has the same meaning as "KiB". For backward compatibility fdisk also accepts the suffix...
fdisk or sfdisk + how to show the disks size in GIB and not in GB
1,564,654,118,000
(Ubuntu 20.04) lsblk -f shows: NAME FSTYPE LABEL UUID FSAVAIL FSUSE% MOUNTPOINT --- nvme0n1 ├─nvme0n1p1 ntfs Recovery A6F8B146F8B11611 ...
I just found out: FSSIZE was the wrong flag. I needed just SIZE instead. lsblk --output NAME,FSTYPE,LABEL,UUID,SIZE,FSAVAIL,FSUSE%,MOUNTPOINT gives: NAME FSTYPE LABEL UUID SIZE FSAVAIL FSUSE% MOUNTPOINT ... nvme0n1 ...
lsblk doesn't show size on some partitions
1,564,654,118,000
In a script I'm working on, a variable UUID must be used in obtaining the current mountpoint a device is attached to. The solution I came up with is this one: UUID='fc70ae3d-65e7-4437-a371-b237c8ca3f56h' MNTPNT=$(lsblk -o +UUID | grep ${UUID} | tr -s ' ' | cut -d ' ' -f 7) Upon executing the command, variable MNTPNT ...
findmnt -noTARGET "/dev/disk/by-uuid/$UUID" grep "$(stat -Lc '%#t %#T' "/dev/disk/by-uuid/$UUID" | xargs printf '%d:%d')" /proc/self/mountinfo awk -v dev="$(stat -Lc '%#t %#T' "/dev/disk/by-uuid/$UUID" | xargs printf '%d:%d')" '$3~dev{print$5}' /proc/self/mountinfo In order to trim bind-mounts: awk -v dev="$(stat -...
Efficient way to obtain a device mountpoint from its UUID
1,564,654,118,000
I want to print all disks that are equal or more then 18G how to fit the following syntax in order to print only the disks that are => 18G lsblk -l | awk '/disk/' fd0 2:0 1 4K 0 disk sda 8:0 0 150G 0 disk sdb 8:16 0 20G 0 disk sdc 8:32 0 20G 0 di...
lsblk + awk + numfmt solution: lsblk -lnb | awk '$4>=19327352832' | numfmt --to=iec --field=4 lsblk options: -n - do not print a header line -b - print the SIZE column in bytes rather than in a human-readable format awk details: $4 - the 4th field value(SIZE column) 19327352832 - equivalent to 18G in byte units ...
lsblk + print only disks that with specific size
1,564,654,118,000
Dear friends and colleges we have servers with rhel 7.5 version , and each server include disks with filesystem and disks without filesystem usually sda - is the OS disk , and sdb is disk that already have filesystem, with the following lsblk syntax we can capture the disks list with filesystem type lsblk --fs -o NA...
If your lsblk supports the --json output format, and if you have jq installed, you could parse that for block devices that (a) have no children (i.e. are unpartitioned) and (b) have no defined filesystem themselves: lsblk --fs --json | jq -r '.blockdevices[] | select(.children == null and .fstype == null) | .name'
lsblk + how to capture the disks that are without filesystem
1,564,654,118,000
I'm using the following command to return a list of available disks and whether they're ssd or rotational (basically replacing 0 and 1 in lsblk's output with their actual meaning): lsblk -d -o name,ro | sed "s/RO/\ TYPE/; s/NAME/DISK/; s/0/SSD/g; s/1/ROT/g" sample output: DISK TYPE sda SSD sdb ROT Now I'd like ...
Awk approach: lsblk -d -o name,ro,rm \ | awk 'NR == 1{ print "DISK TYPE REMOVABLE"; split("SSD ROT", ro); split("NO YES", rm); next} { print $1, ro[$2+1], rm[$3+1] }' Sample output: DISK TYPE REMOVABLE sda SSD NO sr0 SSD YES
Replacing same keyword with different strings per line
1,564,654,118,000
I recently upgraded my home server and wanted to increase my cloud disk to 2TB from 600gb. After some research I found the dd command which can fully copy a disk, which in my case seemed like a good option since I'm having all data for the docker & databases for my nextcloud intstance on the same disk. I, successfully...
As far as I know, that just means that the filesystem in the partition itself still uses its old size. When resizing a disk on linux, you have to resize it twice, most of the time. First in the partition scheme (eg GPT or MBR) with commands like parted or fdisk, and then in the file system, with commands like resize2f...
'dd' command disk copy retains old size
1,564,654,118,000
I'm working on a tool for managing USB devices attached to my machine. At one point I need to match UUIDs to vendor and model, so I used the following command: # lsblk -o UUID,MODEL,VENDOR,TRAN 5A26-0601 USB3.0 CRW -SD Generic- usb Voyager 3.0 Cor...
I've managed to solve my problem with udevadm. MODEL and VENDOR can be obtained by querying properties and grepping relevant information: # udevadm info --query property /dev/disk/by-uuid/7936-E126 | grep "ID_VENDOR=\|ID_MODEL=" ID_MODEL=Voyager_3.0 ID_VENDOR=Corsair # udevadm info --query property /dev/disk/by-uuid/5...
How to match usb device UUID to MODEL and VENDOR?
1,564,654,118,000
So something strange is with my partitions. root@rescue ~ # mdadm -A --scan mdadm: WARNING /dev/sdb1 and /dev/sdb appear to have very similar superblocks. If they are really different, please --zero the superblock on one If they are the same or overlap, please remove one from the DEVICE list in mdadm...
This is a very common problem with old mdadm 0.90 metadata. This metadata is located somewhere at the end of the device, but not in the very last sector but at a 64K-aligned offset: The superblock is 4K long and is written into a 64K aligned block that starts at least 64K and less than 128K from the end of the device...
Getting an error "appear to have very similar superblocks". Ways to fix it?
1,564,654,118,000
I'm using RHEL7 and here is my partition: NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT fd0 2:0 1 4K 0 disk sda 8:0 0 100G 0 disk ├─sda1 8:1 0 1G 0 part /boot └─sda2 8:2 0 39G 0 part ├─rhel-root 253:0 0 35G 0 lvm / └─rhel-swap 253:1 0...
There are two approaches. The first, sticking closely to your suggestion, is to resize sda2 to include the extra space: use your favourite partitioning tool to change the end sector of the partition (see this answer for an example using sfdisk on an MBR-based partition table); run pvresize /dev/sda2 to resize the PV....
How to increase LVM partition
1,577,802,032,000
Contrary to this question, I would like to know which (physical) disks currently do not have any partitions or LVs mounted. This is for a script, which shall return disks where none of their partitions or LVs are currently mounted in the system. Is there a (fairly) simple way to find that out using command-line tools...
Found the solution, which works for me: aAllDisks=($(/usr/bin/lsblk --nodeps --noheadings --output NAME --paths)) aFreeDisks=() for sDisk in "${aAllDisks[@]}"; do sMounts="$(/usr/bin/lsblk --noheadings --output MOUNTPOINT "${sDisk}" | grep -vE "^$")" if [ "${sMounts}" == "" ]; then aFreeDisks+=("${sDis...
Find out disks, which do not have any partitions/LVs mounted
1,577,802,032,000
I noticed a strange issue when creating RAID array with mdadm. As far as I see, it creates additional devices of md type. According to the kernel.org documentation, the md device type is Metadisk (RAID) devices. The metadisk driver is used to span a filesystem across multiple physical disks. However, this starte...
When a block device is added to the system, the kernel attempts to parse any partition table that may exist on the device, and if successful, will add block devices for the partitions it thinks exists because of what it read in the partition table. Note that support for many partition table types can be configured int...
MDADM creates additional block devices
1,577,802,032,000
I have a giveaway usb stick and when I plug it into my computer and run lsblk it shows two block devices, i.e. sdb and sdc. sdb of them contains almost all the free space ( ~15G) and the sdc one is very small (32M) and contains stuff like images of the company who gave the usb stick away. I would like to get rid of t...
There are USB sticks that present itself as two drives: a CD-ROM (readonly) and a mass-storage device (read/write). This was invented to allow auto-starting an application when the USB stick is plugged in on a windows system. There may exist a removal tool from the manufacturer. Example: Sandisk U3. Search for keyw...
What is the deal with this usb drive with a second block device?
1,577,802,032,000
we erased the disk signature as the following ( this is after we performed umount ) wipefs -a /dev/sde /dev/sde: 2 bytes were erased at offset 0x00000438 (ext4): 53 ef then we check that disk is without file system as the following lsblk -f sde ext4 20eba791-c9c9-4462-aa23-74c40a41b8a0 ...
From the man page of wipefs (emphasis mine): DESCRIPTION wipefs can erase filesystem, raid or partition-table signatures (magic strings) from the specified device to make the signatures invisible for libblkid. wipefs does not erase the filesystem itself nor any other data from the device. So, the only thing it gu...
wipefs + disk not cleaned
1,577,802,032,000
I was trying to mount an encrypted SD card on Kubuntu 20.04. lsblk gives me this: NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT loop0 7:0 0 97,9M 1 loop /snap/core/10577 loop1 7:1 0 97,9M...
Device encryption is implemented using a kernel framework called device mapper (that's where the dm-3 comes from, it's a third device mapper device in your system). "Mounting" an encrypted device has two steps: Unlocking/opening the device (in your case the first partition on your SD card). You already did this step ...
Mounting encrypted SD card: where does /dev/dm-3 come from?
1,577,802,032,000
I attached a used virtual storage (backup) to a rescue instance because I need the files of the attached storage. [root@centos-1cpu-1gb-de-fra1 ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT vda 253:0 0 25G 0 disk └─vda1 253:1 0 25G 0 part / vdb 253:16 0 100G 0 disk Any help how I get the ...
From what you've shown above, your vdb disk is not partitioned, but is formatted as a whole with a "ext4" filesystem. (Not that it makes a difference). So, just make a mountpoint for it somewhere, and mount it (preferrably read-only?). Like... mkdir /tmp/vdb mount -r /dev/vdb /tmp/vdb cd /tmp/vdb ls -la ...and you s...
lsblk doesn't show attached virtual storage / partition
1,577,802,032,000
I am running a virtualbox VM and I can see that the size of /dev/sda2 is being shown differently in the two outputs. Also, in the output of fdisk, /dev/sda2 and /dev/sda5 seem to be overlapping ~$ lsblk /dev/sda NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 29.3G 0 disk ├─sda1 8:1 0 512M 0 part...
The sda2 partition is a container partition. Its format is very similar to the disk's Master Boot Record (MBR) and is known as Extended boot record (EBR), itself occupying one of the four possible primary partition slots. It exists to overcome this historical limitation of 4 partitions in the MBR. It includes inside i...
How can lsblk and fdisk show different sizes for the same partition?
1,577,802,032,000
sda |-sda1 ntfs Recovery F49E60439E5FFD0C |-sda2 vfat 0E62-991B 61.6M 36% /boot/efi |-sda3 ...
It's just a layout-thing. It makes it easier for the user to see that sda9 and sdb2 are the last ones in their respective lists. Nothing to worry about.
Output of lsblk includes both pipes and back ticks
1,577,802,032,000
I've partitioned an external drive with fdisk and this are the results: But when I run lsblk the partitions I created are not showing. What's the fault here?
Changes in fdisk remain in the memory of fdisk itself until you tell the tool to write them to the device. You do this with w. If you quit with q, the changes will be lost. After writing the changes fdisk notifies the OS. In modern "big" distros this should be enough. From now on lsblk should show the new state of par...
fdisk partitions don't show with lsblk
1,577,802,032,000
Is there any command to list all partition type codes recognizable by currently installed distribution (In my case Ubuntu 18.04.03 LTS) I know the following website exists Andries E. Brouwer 1995-2002 - homepages.cwi.nl yet there should be any command inbuilt in the linux console. I know that cgdisk shows all partitio...
Ok finally I found that it's mainly dependent of the filesystem and the volume identification hex code is/should be present in the filesystem documentation as seen below for NTFS and EXT4 Conclusion: There is not specific command or tool only for listing partitions hex code besides the function of cgdisk, gdisk, cfdi...
Command to list partition type codes in deb and rpm distributions for MBR and GPT
1,577,802,032,000
I have created RAMdisks of 60GB using modprove brd rd_size=62914560 on CentOS 7.5. Checking the results, fdisk -l /dev/ram* shows 16 ram block devices of 60GB size (/dev/ram0, /dev/ram1, ..., /dev/ram15). I want to run 16 jobs (threads) with random accesses on one ram block device to check the performance. I run such ...
You asked multiple questions in one go which reduces your chances of having them all answered :-( However, I get the following error: cache invalidation of /dev/ram1 failed: Device or resource busy Why this happens? Is there a limitation in the number of jobs (threads) accessing a single ram block device? The func...
Multiple Threads Cannot Access the Same RAMdisk Created by modprobe
1,577,802,032,000
we want to print only the disks that are without filesystem by command line from following example we can see that sde disk is without filesystem lsblk -o NAME,FSTYPE NAME FSTYPE sda ├─sda1 xfs └─sda2 LVM2_member ├─vg-LV_root xfs ├─vg-LV_swap swap ├─vg-LV_var xfs └─...
I suggest that we add fdisk (and some simple help tools) to lsblk in the method. The following shellscript works in my test case, #!/bin/bash for i in $(lsblk -dno name|grep -v sr) do LANG=C sudo fdisk -lu "/dev/$i" | tr '\n' ' ' | grep 'Disk ' | grep -v 'Disklabel type:' | grep -o "/dev/$i" done Thi...
lsblk + how to print only the disks that are without filesystem
1,577,802,032,000
I am using Ubuntu 20.04. when I do lsblk size is not adding up. root@UbunutuTemplate-001:/home/tca# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT loop0 7:0 0 4K 1 loop /snap/bare/5 loop1 7:1 0 54.2M 1 loop /snap/snap-store/558 loop2 7:2 0 219M 1 loop /snap/gnome-3-34-1804/72 loop3 7:...
The numbers don't add up because you have unclaimed space at the end of the disk. You could add another primary partition to this disk to use up the remaining 84G. Note: 209715200 sectors / 2 / 1024 / 1024 = 100G 33552383 is the end of the last partition 209715200 - 33552383 sectors = 84G sda2 is an "extended" partit...
lsblk size not adding up
1,577,802,032,000
we have rhel 7.2 server , server is VM server and we add new disk - sde with the following example we create ext file system with label - disk2 mkfs.ext4 -L disk2 /dev/sde mke2fs 1.42.9 (28-Dec-2013) /dev/sde is entire device, not just one partition! Proceed anyway? (y,n) y Discarding device blocks: done Filesystem la...
The labels shown by lsblk (or rather, blkid) in its LABEL column are the file system labels, which are only available on file systems capable of storing a label. A block device with no file system can’t have such a label. GPT partitions can also be labeled, and lsblk shows that with PARTLABEL. But that’s not an option...
how to create disk label without creation filesystem on new disk
1,577,802,032,000
in our bash scripts , we have many places in the code that need to capture only the disk that related to OS ( operation linux/RHEL system ) we are using Linux versions as 7.2/7.5/7.6/7.9 , and on most cases machines have additional disks that used to store data or DB servers that include disks with TB size etc usually...
You can look for the disk containing the partition mounted on a system mount point, e.g. /boot: lsblk -ls | awk '$NF == "/boot" { m = 1; next } m && $NF == "disk" { print $1 ; exit}' This also works for /: lsblk -ls | awk '$NF == "/" { m = 1; next } m && $NF == "disk" { print $1 ; exit}' This uses lsblk’s list mode ...
How do I find out what is the hard disk for OS in Linux
1,577,802,032,000
I am currently trying to parse the output of lsblk with jq and filters it based on some criteria. Given the following example output: { "blockdevices": [ { "name": "/dev/sda", "fstype": null, "size": "931.5G", "mountpoint": null, "children": [ { ...
To get the name of the block device and each of its non-null child mount-points as a tab-delimited list: jq -r ' .blockdevices[] | select(.fstype == "crypto_LUKS") as $dev | $dev.children[]? | select(.mountpoint | type == "string") as $mp | [ $dev.name, $mp.name ] | @tsv' Since a "null mount-point" is no...
Parse lsblk with jq
1,577,802,032,000
When we do the following on a RHEL lab machine: lsblk | grep sdd sdd 8:48 0 1.8T 0 disk we get the sdd disk, but when we do blkid as the following: blkid | grep sdd we do not get any output. We re-scan the disk as: echo 1>/sys/class/block/sdd/device/rescan but blkid still does not recognize the...
About blkid: When device is specified [… (irrelevant)]. If none is given, all partitions or unpartitioned devices which appear in /proc/partitions are shown, if they are recognized. While lsblk lists information about all available or the specified block devices. [Emphasis mine] Specify a device: blkid /dev/sdd E...
Disk doesn't appear in blkid but does appear in lsblk
1,577,802,032,000
I am creating an overview site of my hard drives (HDD) I have installed in a machine. That website requests the HDDs including the state through a lsblk command. I want to indicate the status (state) on the website by a traffic light system but the only status so far that I am aware of is "running". I did not have any...
Looking at the source code for lsblk, for the STATE column, the only states defined are running or suspended
lsblk - what are the possible values for the column "state"
1,388,861,790,000
I have hundreds of tested and tried commands and snipets saved in various text files. When I need to re-use one, I find and copy/paste to the command line. Though reliable this is a clumsy method. Compare this to the elegant way we can retrieve an old command from history file straight onto the command line and ready ...
It might be worth exploring xdotool to solve your problem. According to the man page: xdotool lets you programatically (or manually) simulate keyboard input and mouse activity,move and resize windows, etc. So what you could do is to define an alias that helps you find your favorite command and tells xdotool to place...
How to place my own code snippets on command line à la history?
1,388,861,790,000
I want to download a list of all videos of a youtube channel and sort it by duration. Here is what I tried with youtube-dl resp. yt-dlp: yt-dlp --skip-download "url_to_channel" --get-duration --get-title > list Then something like cat list | sed '$!N;s/\n/ /g' | sort. However this doesn't work since the duration is pr...
You could ask youtube-dl to output the json data, then process it with jq (you will have access to all the fields, not just the ones with get-... flags). This command: youtube-dl --dump-json "https://www.youtube.com/user/emacsrocks/videos" | jq -r '[.duration,.title]|@csv' will output this: 4005,"Parens of the Dead L...
Download and sort list of all videos from a youtube channel with youtube-dl
1,388,861,790,000
I hope the title explains this correctly. I am currently trying to print out an array after counting unique values from a spreadsheet. My awk command works correctly: awk -F"," 'NR>1{col[$1,$9]++} END {for (i in col) printf("%s: %d\n", i, col[i])}' my_file.csv | sort When printing though I get a special character tha...
Awk is treating [$1,$9] as a pseudo multi-dimensional array, and inserting its internal SUBSEP character. This is documented in The GNU Awk User's Guide for example: SUBSEP The subscript separator. It has the default value of "\034" and is used to separate the parts of the indices of a multidimensional array. Thus, t...
print awk array and replace special characters with comma