date
int64
1,220B
1,719B
question_description
stringlengths
28
29.9k
accepted_answer
stringlengths
12
26.4k
question_title
stringlengths
14
159
1,370,621,290,000
I tried installing atftpd today. The package installed successfully: # zypper se atftp Loading repository data... Reading installed packages... S | Name | Summary | Type --+-------+---------------------------------+-------- i | atftp | Advanced TFTP Server and Client | package But the ser...
Why does the service refuse to start? What can I do to fix it? Because you're starting the wrong thing. Start the right thing. ☺ The giveaway here isStandardInput=socket in the service unit file. This indicates that the dæmon is expecting a socket as its standard input, and systemd is expected to supply it when s...
atftpd won't start on opensuse tumbleweed under systemd
1,370,621,290,000
We have 3 instances of redis running on a test server. For some reason, our start script which starts redis can write the wrong pid to a file. Here is what it's doing: su redis -c "redis-server /redis.conf & echo \$! > /var/run/redis_6379" If I chain together redis_6379 start && redis_6380 start && redis_6381 start ...
Is it possible that redis-server forks, and that the PID you get from $! is the parent PID, but you're actually interested in the child PID?
Startscript: using $! to create pidfile - returning wrong pid (off by one) occasionally
1,370,621,290,000
I use Debian Lenny (I know lenny is old and other bla bla) and would like to place a program on the start-up. I use update-rc.d by adding an executable file on /etc/init.d. By referring to http://wiki.debian.org/LSBInitScripts , I need to add a LSB on /etc/init.d/myprogram ### BEGIN INIT INFO # Provides: mypr...
As far as it's concerned in this context, they're the same thing. The LSB information is just metadata in the form of shell comments added to the init beginning of the script. Just combine those two chunks. It should contain: The interpreter line (e.g., #!/bin/sh) The LSB information, edited to your application's nee...
adding a program on start-up by using LSBInitScripts
1,370,621,290,000
I've installed mysql through $ sudo apt-get install mysql-server-core-5.1 $ sudo apt-get install mysql-client-core-5.1 This is my current conf file And the service won't start, at first the socket and var folders did not exist, I created the mysql user and mysql group as system accounts and gave ownership and full c...
Are you sure it's not already started? Check ps -ef | grep mysql. You should be able to use most Debian or Ubuntu guides on MySQL, since Mint is based on Ubuntu. You probably don't need to start the server yourself. Try restarting and see if it doesn't start automatically then. Also, you probably need more than just t...
Can't start mysqld
1,370,621,290,000
I have a home NAS server with OpenVPN daemon installed, however I want to keep my harddrives in idle mode (so they last longer) when nobody actively uses the VPN or files on the NAS. OpenVPN daemon prevents that because it keep writing its PID to the file: root@NAS:~# iotop Total DISK READ: 0.00 B/s | Tota...
The --writepid /run/openvpn/server.pid option writes the PID just once, at process startup. On the other hand, the --status /run/openvpn/server.status 10 option writes the status file every 10 seconds. However, both of these are being written to a RAM-based filesyste, /run. It might be that the logging is what's catch...
OpenVPN daemon keeps my harddrives spinning on NAS home server
1,370,621,290,000
I have a script that backs up a directory to AWS S3 every night. (The script is run via a systemd timer.) I would like to create a dedicated user for this service. Ordinarily, I would not create a home directory for this user. Where, then, should I put the AWS credentials file?
Save it wherever you like, typically somewhere in /etc. In your backup script set AWS_CONFIG_FILE=... pointing to that location. Check out https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html for more info. Hope that helps :)
Where to put AWS credentials for daemon user?
1,577,406,648,000
I want to turn on / enable the auditd daemon to record system events in Slackware 14.2. I could not see the daemon auditd, when I run the code below: ls /etc/rc*.d | grep "auditd" It means it was not existing. How will I enable auditd in Slackware? I know how to start, stop and restart services but if it is not exist...
The distribution does not provide auditd, but one can find the build script SlackBuild. (The URLs will change in the future.) Create a working directory and acquire the required files. mkdir /usr/local/src/audit && cd /usr/local/src/audit wget http://people.redhat.com/sgrubb/audit/audit-2.3.6.tar.gz wget https://slack...
Slackware 14.2 - Turn on the auditd daemon
1,577,406,648,000
I have a bash script that is written in a debian-based distribution (System-V) and I want to run it under CentOS 7. There is a part of the script that runs a command as a daemon like this: start-stop-daemon --start --pidfile $PIDFILE \ --chdir "$DIR" --startas $PROGRAM --name foo --chuid "$USER" -- $ARGS And stops t...
The daemon() shell function from /etc/rc.d/init.d/functions on RHEL/CentOS 6 is not an exact equivalent of Debian's start-stop-daemon. The fact that all of these van Smoorenburg rc tool libraries have subtly different helper command sets is one of the well-known problems with van Smoorenburg rc. You're using CentOS 7...
Debian start-stop-daemon equivalent in CentOS
1,577,406,648,000
I'm a bit riddled by the convention in creation of linux daemons. People mostly agree that what makes a daemon is no associated terminal. Also, in sample codes usually the processe's parent gets killed and the daemon reparents to init. I have no problem understanding this is the way to do it, BUT WHY? How is it benefi...
ERROR: type should be string, got "\nhttps://en.wikipedia.org/wiki/SIGHUP\n1. How is it beneficient that the process has no associated terminal?\n\nOn POSIX-compliant platforms, SIGHUP (\"signal hang up\") is a signal sent to a process when its controlling terminal is closed. (It was originally designed to notify the process of a serial line drop.)\n[...]\nThe default action [of SIGHUP] on POSIX-compliant systems is an abnormal termination.\n\n\nIf I understand the situation correctly, there are two different cases.\nThe obvious case is that if you close e.g. a terminal emulator like GNOME Terminal or mc, that closes the master end of a pseudo-terminal device. And this closure generates a hangup on the pseudo-terminal. This affects the slave device. All the processes which are controlled by this terminal will receive SIGHUP. This is not the case described above.\n@JDePB points out the second case: if you close all the file descriptors referencing a terminal device, it will also generate a hangup. That is, if your daemon closes its FD for its tty (which it should), and later on the other processes which have open FDs of the tty exit, your daemon will receive SIGHUP, even if your terminal emulator doesn't respond and leaves the master end of the pseudo-terminal open. This functionality can be disabled for the whole terminal device by clearing HUPCL.\nThere's also vhangup(). It seems login calls this to try and make sure the previous session can't interfere with it. Or something. I'm not entirely clear, since this call is Linux-specific and the manual page is very very short. \n2. and is a direct child to init?\n\nIf the process receiving SIGHUP is a Unix shell, then as part of job control it will often intercept the signal and ensure that all stopped processes are continued before sending the signal to child processes (more precisely, process groups, represented internally by the shell as a \"job\"), which by default terminates them.\n\n"
Why does a daemon have no associated terminal?
1,577,406,648,000
I have tftpd-hpa installed(Ubuntu 16.04 LTS). Recently, maybe after getting some updates (or uninstalling some application with vaste dependencies) the tftpd-hpa doesn't start anymore. The tftpd-hpa settings are: TFTP_USERNAME="tftp" TFTP_DIRECTORY="/var/lib/tftpboot" TFTP_ADDRESS=":69" TFTP_OPTIONS="--secure --create...
Combining the two parts of information: Recently, after some updates received And the following error: Apr 18 01:47:32 Amtek in.tftpd[4777]: cannot bind to local IPv4 socket: Address already in use It seems like the problem is that the tftp port (69) is already in use, when you start the tftp server. This might ...
The tftpd-hpa doesn't start after update
1,577,406,648,000
The clients are Linux Mint 18 Cinnamon 64-bit and the server is Debian Stretch 64-bit. Having TeamViewer 11 Free installed both on the server and all clients. But I don't want for it to silently run on the background for more than one reason. I wish to be able for it to: Disable Enable Start the client without having...
You may define the following aliases if you do this on every day basis: Disabling the daemon is easy: alias tv-disable='sudo teamviewer daemon disable' Enabling the daemon is as easy: alias tv-enable='sudo teamviewer daemon enable' But to start the client without having the terminal flooded, you need to elaborate a...
TeamViewer enable / disable / start
1,577,406,648,000
I have a Ubuntu server which is collecting incoming SNMP traps. Currently these traps are handled and logged using a PHP script. file /etc/snmp/snmptrapd.conf traphandle default /home/svr/00-VHOSTS/nagios/scripts/snmpTrap.php This script is quite long and it contains many database operations. Usually the server recei...
While your question actually confused me, I believe you should move away from using a php script to handle the snmptrapd service. That file (/etc/snmp/snmptrapd.conf), is used by the snmptrapd service which can be enabled at whatever run level you wish (3, 4, 5) and can be configured to log traps to MySQL, so there is...
Pass SNMP trap packet to a php daemon on Ubuntu
1,577,406,648,000
I have a Corsair K65 RGB Keyboard. To start it working, I had to clone https://github.com/ccMSC/ckb , compile and run the [clonedir]/ckb/bin/ckb-daemon . Every time I boot, I have to pull out my old keyboard and type in "sudo [clonedir]/ckb/bin/ckb-daemon". Is there a way to automate this?
If you install the package from the AUR (and you really should use a PKGBUILD to install applications so they can be tracked by pacman), then you will be able to use the systemd service file provided with the package. If you don't wish to go down that path, the service file is included in the git repo. Once you have c...
CKB Arch - Daemon run on startup
1,577,406,648,000
When I start/stop/restart a daemon (eg. apache2), no message appears. I am on Debian testing (jessie). On my old server (Debian testing too), messages are displayed: root@old-server # /etc/init.d/apache2 restart [ ok ] Restarting web server: apache2. But not on the new server: root@new-server # /etc/init.d/apache2 re...
Functions which provide the output are installed to the /lib/lsb/init-functions.d directory. Most likely you do not have anything there which provides the nice output. The lsb-base package provides the /lib/lsb/init-functions script which is sourced by your init script. This provides stubs for the functions that produ...
Daemon /etc/init.d message on Debian
1,577,406,648,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,577,406,648,000
Is it possible to prevent the memory being used by a daemon to be read by anything else? If not, is it possible to detect an attempt to read? If so, is it possible to get in front of the actual read and execute commands that can act first?
On Unixy systems, root is all-powerful and can certainly read (and even write) into your daemons' memory without it even being able to find out. Ditto for the user as which the daemon runs. If you are trying to protect against non-root/non-daemon-user access, the system itself should provide protection (modulo bugs or...
Prevent or detect reading of daemon in memory
1,577,406,648,000
I have a Java program running as a daemon (thanks to YAJSW, a wrapper for java). The thing is that this java application writes several lines of console text, (simply imagine a Hello World App). If I run it from the console of course I can read those lines. But when it runs as a daemon, where do those lines of text go...
I've found how to do it in the Yajsw help, thanks @Gilles for the guiding It's enough just to specify in wrapper.conf wrapper.logfile= <path and filename > Thanks anyway!
How to log the output of a daemon application?
1,577,406,648,000
I'm setting up Debian so that it works in kiosk mode. To do this, I created a service that performs the watchdog function: [Unit] Description=Watchdog for myapp [email protected] After=polkit.service After=udisks2.service [Service] ExecStartPre=systemctl stop dm ExecStart=su user -c "startx /opt/myapp-watchdog....
Figured it out. It is impossible to solve this problem by means of startx (proof: Link to the xserver error on gitlab). I had to invent bicycles and use crutches. The solution is for the service to run a script in which the software is run in a loop. After that, the software exit code is checked. If the code is 0, the...
Getting the exit code of an application launched via startx
1,577,406,648,000
I have some music files in ~/Music: sunqingyao@sunqingyao-MacBookAir:~/.ncmpcpp$ ls ~/Music Bastion Original Soundtrack This War of Mine OST Beholder OST Titan Souls Special Edition Content Hyper Light Drifter soundtrack Transistor Soundtrack Stellaris soundtrack After successfully doing sudo ...
I've figured it out myself: you should use mpd_music_dir = "/home/sunqingyao/Music" instead of mpd_music_dir = /home/sunqingyao/Music The quotation marks mustn't be omitted.
mpd cannot find music files on Ubuntu 16.04
1,577,406,648,000
Linux Mint 18.1 ships with pulseaudio version 8.0 as sound system. On linuxmint 17.3 I have version 4.0 and /etc/init/pulseaudio.conf file where pulseadio is configure to get started with line start on runlevel [2345] Copying file to /etc/init did not work. I need this because of multiseat configuration.
Problem was in system.pa. I found in manual that in system wide daemon configuration should not use automatic detection. from pulseaudio manual pages: --disallow-module-loading[=BOOL] Disallow module loading after startup. This is a security feature since it disallows additional module loading during runt...
Start pulseaudio as daemon in Linux Mint 18.1
1,577,406,648,000
I have the following problem. I have a machine learning process that runs in the background. Even better, I have plenty (let's say 5) that I want to run them. Each of them is CPU and GPU power consuming and therefore would like to run only one of them at the time for a specific period of time (i.e. 1h, actually the sc...
It depends how robust you want this to be. A simple-minded solution that runs the "next" program in a circular list might look like this: #! /usr/bin/env bash programs=(program1 program2 program3 program4 program5) state=$HOME/.${0#*/}_state if [ -f "$state" ]; then read idx <"$state" if expr "$idx" : '[0-9...
Daemon service that runs a sequence of processes (balanced distribution)
1,464,346,089,000
This is a sleeping service, import time bufsize = 0 f = open("/home/user/sleep-log", "w", bufsize) try: f.write("going for a deep sleep......") time.sleep( 1000000000) except: import traceback; f.write(traceback.format_exc()) finally: f.write("that is surprising.. final block just ran") And i have a ubuntu up...
When Upstart stops a job it sends the SIGTERM signal. By default SIGTERM causes the program to immediately exit. This means the execution does not flow through the rest of your code, it simply stops. A signal handler can be implemented using the signal module, you can find details on it's usage here. This will allow y...
service stop doesn't run the exit/cleanup part
1,464,346,089,000
In my raspberry pi when I go to http://localhost/ I see a Apache2 debian default page, So I went to /var/www/html/index.html and changed the source code to see if there were any changes in the page, and there aren't. So, there's some other server running and sharing the same folder maybe? sudo netstat | grep apache...
If wget -O - http://localhost fails, then it must be coming from the browser cache.
Apache default page shows but Apache not found
1,464,346,089,000
I have 7 services enabled, 6 of them depend 1 the first one starting and it runs fine. 3 start fine and the other 3 won't start on boot but if I run sudo systemctl start service it runs fine. Can you please help? daemon [Unit] Description=SABnzbd Client After=network.target [email protected] [Service] Type=simple Use...
The problem is with your install section: [Install] WantedBy=multi-default.target multi-default.target isn't a thing. systemd.special(7) lists the targets you can depend on. You should either use default.target if this is part of the --user bus, or multi-user.target if this is part of the system bus. It looks like...
enabled systemd service won't start on boot
1,464,346,089,000
In sysvinit, telinit is a symlink to init. init is run as a daemon. Is telinit run as a daemon? I don't have sysvinit installed on my Lubuntu. For comparison, systemctl plays similar role to systemd as telinit to init, and systemctl has a controlling terminal so is not running as a daemon, while systemd is run as ...
Whether a file is a symlink to another one has no bearing on how it runs. telinit, like systemctl, runs as a “normal” process.
Is telinit run as a daemon?
1,464,346,089,000
Does the Ubuntu Linux 16.04 daemon function execute a double fork? If so, why is a double fork necessary? [EDIT May 30 2016 8:11 AM] This is the official Linux Foundation source code for the daemon function I am referring to in this question. 92 int daemon(int nochdir, int noclose) 93 { 94 int status = 0; 95 ...
We appear to be referencing the daemon(3) library call, source code for which may be at #1 https://github.com/lattera/glibc/blob/master/misc/daemon.c or at #2 https://github.com/bmc/daemonize/blob/master/daemon.c. Both versions are documented in this single man page. The source code for #1 shows a single fork(2). The ...
Does the Ubuntu Linux 16.04 daemon function execute a double fork? [closed]
1,464,346,089,000
I am trying to register my daemon program that I wrote with C with systemd. I use the following script, [Unit] Description=App After=network-target [Service] Type=simple ExecStart=/usr/local/bin/daemon Restart=on-failure RestartSec=10 KillMode=process [Install] WantedBy=multi-user.target I use the following command...
code=exited, status=1/FAILURE Your program exited with status 1. What this might mean, only you know. When does your program returns code 1? That is, you do terminate the main program returning success, don't you? int main(...) { ... return EXIT_SUCCESS; } Because otherwise what might happen is that systemd...
Trouble Starting up a Daemon written in C with systemctl
1,464,346,089,000
I'm just trying to see if this is possible before I start working on it. Here's the scenario, I want the server to be constantly listening for SSH requests (which I'm sure it already does, I just don't know where) and depending on the IP address of the incoming machine either do nothing or take an action before the SS...
To serve up a service over TCP, some program has to call listen() to get a listening socket, and that same program or one related to it has to call accept() to accept the individual incoming TCP connections as further connected sockets. OpenSSH's server dæmon operates in two basic modes in this regard. It is started ...
Create a background daemon to listen for incoming SSH requests
1,464,346,089,000
I'm trying to run my program as a daemon but the way I am doing it currently requires root access. I was wondering if I could use the nohup command with & to push it to the background instead of running my program as a service. I know that a similar question has been asked before here: What's the difference between ru...
There is a difference between running a daemon and running a program in the background -- in fact it is possible to run a daemon in the foreground. Daemon mode is a different functioning of the software, running in an infinite loop without the user interaction component. Using & doesn't guarantee that the software wo...
Is there a difference between running a program as a daemon and using nohup with & to run the program?
1,464,346,089,000
What are step to make the process detach from the terminal? For that I found man page of daemon() In the description, they mentioned If nochdir is zero, daemon() changes the process's current working directory to the root directory ("/"); otherwise, the current working directory is left unchanged. ...
There's actually more there than what you quoted, but I think that manual page could be clearer. If nochdir is zero, daemon() changes the process's current working directory to the root directory (/) The assumption here is that the program is started from an administrators command line, and the idea is to d...
How does DAEMON(3) work? Run as background process
1,464,346,089,000
I'm using Ubuntu Server 16.04. I want to run specific command every time when the server starts. I mean that this command should be executed when the server runs (continually working). This command is connected to PHP framework and starts a web application. Normally I can run this command by going to the folder where ...
Some programs are not designed to be run with continuous user input and disconnect from the terminal at the first opportunity. For example, a web server responds to web requests, rather than user input. Mail servers are another example of this type of application. These types of programs are known as daemons. The term...
How to run command every time when the server is running
1,464,346,089,000
I made a daemon that it is started by systemd, and inside my daemon I have a python function to get the time. The problem is that the time is wrong, I have 8 hours of difference. This is my service script: [Unit] Description=auto-sync daemon [Service] ExecStart=/bin/bash -c "/usr/bin/auto-sync -s" [Install] WantedBy...
Is your timezone 8 hours off from GMT? It sounds like your python call to datetime.now() is not using your current timezone and is instead returning you the time it is in the GMT timezone. Internally this time is just a long integer containing the number of seconds since Jan 1, 1970 GMT. Your python is running in...
systemd daemon & python getting the wrong time
1,464,346,089,000
I need a program that would be running as a daemon, connecting to mail server and reading inbox of a specified e-mail address (provided with password, of course =) ). If certain conditions are met, it'd execute a script - and there could be many different conditions with many different scripts =) Conditions could incl...
Sounds like you're looking for fetchmail in conjunction with procmail. Between the two of them, you should be able to solve all your automated mail-reading needs.
What program constantly reads e-mails and could execute actions under certain conditions?
1,464,346,089,000
Below is an init script which starts/stops a daemon. The daemon is unfortunately printing the parsed packet data (from /home/nuthan/program/server), a socket server written in perl, listening to a socket for tcp packets from a client. As soon as I start the service, the parsed data (print statements from /home/nuthan...
You are mixing three commands: deamon, perl and /home/nuthan/program/server without any quotes. Think about the following: How does each of them know, which of the parameters it should interpret? The syntax you used could probably only be correctly interpreted, if: deamon would treat everything after -18 to be the co...
Prevent init daemon echoing on TTY
1,464,346,089,000
There is a script (on dash) that runs at system startup (as a daemon). The script is run under root. From under a user I create a file with the right parameter, and the script checks once a second if the file exists and reads the parameters. That is, I pass the parameters to the script (running as root) through the fi...
If the need is just an privilege elevation, sudo may be a better than a daemon. If you really want a background process which wait for a user input, you can create a named pipe with mkfifo. Your background process read a line from this named pipe (read line < the_named_pipe), and the user has just to write something i...
What is the best way to pass a parameter to a running script?
1,464,346,089,000
This code should be a daemon that keeps alive nc command. If nc instance is dead then the daemon should respawn it. #!/bin/sh if [ "$1" != "__forked__" ]; then setsid "$0" __forked__ "$@" & exit else shift fi trap 'echo "Clean up and exit"; kill $nc_pid; exit' TERM exec > outfile exec 2> errfile exec 0< /...
This won't work in /bin/sh, switch to /bin/bash and it should.
Infinite number of process spawns despite wait and kill (bash)
1,464,346,089,000
I keep asking myself how to get familiar with the software (mostly a daemon) and its configuration. When running man <program name> I am very overwhelmed by the options available. How do you or other professional system administrators learn what they need from the manual? Which steps are made by you/them to get a cl...
Unix/Linux systems are complex beasts. Welcome to a wonderful world. Check out the site of your favorite distribution, they should have some "introduction to system administration" pages. Look for the various "introduction to Unix/Linux command line" tutorials. The various GNU tools (workalikes of much of the traditio...
How to handle information overflow of man and the documentation?
1,464,346,089,000
I just got everything set and done with my python flask project and I would like to make a service out of it. In order to get started, I've made a bash file which is supposed to start the server and can be located in /home/pi #!/bin/bash cd /home/pi/Desktop/secure-pi-tensorflow python3 /home/pi/Desktop/secure-pi-tenso...
All I had to do was to add User=pi to fix this.
Unable to power up systemd service
1,464,346,089,000
When I run a service from a terminal it shows many logs/errors/successes in output. But if I run it with same command options as a service (under systemd on Debian Linux) it does not show any terminal window or any output. So where does that logs go? Is it redirected to /dev/null?
Issue the systemctl show --property=StandardOutput your.service command to see where the standard output of your service goes. The usual default is the systemd journal. You can dump the journal with the journalctl command (which has the --unit option to filter the output by service, but which is unreliable for short l...
What happens to the output of a service?
1,464,346,089,000
I had observe on the same OS (ubuntu 16.04), different machines, that if I run sudo systemctl status docker, then I have different results concerning the location of docker.service, more exactly on one machine I have: docker.service - Docker Application Container Engine Loaded: loaded (/lib/systemd/system/doc...
The default configuration file for the docker daemon is located in /lib/systemd/system/docker.service, while custom configuration can be placed in /etc/systemd/system/docker.service or in /etc/systemd/system/docker.service.d/ folder, which overrides the default. Also see this and this. From the docs: There are a numb...
Control docker daemon
1,464,346,089,000
I use Ubuntu 17.04, though this problem was persistent in many previous versions. Long ago (a year or two, I think) I started to spot it. Immediately (no more than a couple of minutes) after the system start up the system load indicator is starting to report writing to the disk, as it is shown on the next screen shot ...
Your system is under heavy load (99.24%) from: fstrim (8) - discard unused blocks on a mounted filesystem which is an obvious source of writes to the disk. On the other side, the fact that a rate goes very high doesn't mean that there is a lot of writting. If you write 100 bytes in 1 nanosecond, you will ge...
Why is the write rate to the disk being up to several GB/s, while no process reports any writing?
1,464,346,089,000
My shell script knowledge is a little shaky, but I want to run a daemon (Ubuntu 14.04) defined in /etc/init.d/unicorn, like so case "$1" in start) check_config check_app_root log_daemon_msg "Starting $DESC" $NAME || true if start-stop-daemon --start --quiet --oknodo --pidfile $PID --...
It looks like there are a few problem with what you are doing. --exec only takes one argument, however arguments can be passed at the end of start-stop-daemon following a --. The argument of --exec is also used as an identifier: start-stop-daemon checks to see if there is an instance running (this would make /bin/sh,...
When running a daemon, how do I execute a command from a given directory?
1,464,346,089,000
This is kind of a canonical question about the Unix/Linux filesystem. I am working on a little daemon that generates output like this every five minutes: Data1: 100 Data2: 201 Data3: 102 This data needs to be accessed by another system, so I am going to store it in a little file that the other system can access. In ...
Historically small transient files go to /var or /var/run but lately some distros dropped /var/run and started using just /run, thats the reason most if not all linux programs write their logs to /var/log, usually there is a directory inside with the name of the application leaving you with /var/your_app/data_file.txt...
Where should daemon status files go in the *nix hierarchy?
1,464,346,089,000
I'm trying to set up a lightweight, custom filesync system for myself. I'd like the server to watch for changes to a given folder (with inotify -m), and when it detects any, to propagate them to clients connected to it. My first thought was for the client computers to initiate an SSH tunnel (with ssh -R 2222:127.0.0....
To begin with, note that any self made "signaling solution" may have non-obvious race conditions. Watch out that you don't miss a signal while processing the last signal! One simple idea could be your server would append lines to a local file. So each inotify would cause: date +"%s" >> /path/to/sync-signals.log On yo...
Can a server signal a client to run a script WITHOUT SSH reverse tunneling?
1,454,857,655,000
On a headless RaspberryPi, I would like to automatically start radio on boot, without any human action. I have written this file as /etc/systemd/system/radio.service : [Unit] Description=Radio Wants=network-online.target After=network.target network-online.target [Service] Type=oneshot ExecStart=/usr/bin/mplayer http...
Alright, being able to start the service manually sounds good. You also have to enable the service with systemctl enable radio? From the systemctl status radio it looks like the service is not enabled and thus doesn't start.
Start radio with systemd service
1,454,857,655,000
I have some ‍upload/download ruby scripts; I want to run those scripts in daemon process. When I run ruby script on terminal, it ask for some input after that script start to execute. So now I want to run this scripts using daemon process. But the problem is that how can I give input to scripts, so that it executes. I...
A daemon normally runs without interaction. Given that there is the problem of how to provide a password that you don't want to keep in a configuration or startup file for the daemon. What I have done in these kind of situation is: Have the daemon look for a file under /root/ as long as it doesn't have the password e...
Can we input or send any text to the daemon?
1,454,857,655,000
Background When a SIGHUP is sent to a running nginx master process to reconfigure, if there're password encrypted certificate key, nginx(specifically the openssl library) will ask for input, as in the log: Enter PEM pass phrase: since there are no input handle, this immediately fails and causing failed reload. Questi...
There is a directive meant for that : You can configure NGINX to use a list of passwords separated by lines stored in a file by using ssl_password_file. . http { server { server_name <fqdn|ip>; ssl_certificate_key <pem_key>; ssl_password_file <path_to_passphrase> } Then reload the configuration : sudo ...
Get output and input into daemon processes
1,454,857,655,000
I have Rpi4 with Volumio 2.729 installed. I use Triggerhappy to run a node.js script when keyboard button is pressed - the script will play corresponding internet radio station: module.paths.push('/lib/node_modules'); var io=require('socket.io-client'); var socket= io.connect('http://127.0.0.1:3000'); socket.on('conn...
By default triggerhappy should run as nobody. One workaround is to grant nobody the right to invoke a specific command by editing your sudo file. But it should not be necessary to use root, your regular user should suffice if it can run the script. In your triggerhappy configuration, verify that you have a fully quali...
How to use Triggerhappy deamon to overwrite files
1,454,857,655,000
I have developed and published a web application on dotnet core for linux arm machine. To do this, the command has been launched: dotnet publish --runtime linux-arm -p:PublishSingleFile=true And as a result gives the directory: Mode LastWriteTime Length Name ---- ------------- ...
This is fixed by directly entering the execution path in the ExecStart parameter. The system will launch the executable from its own relative path: [Unit] Description=Data Logger Monitor Daemon [Service] ExecStart=/root/dataloggermonitor/linux-arm/coremonitor User=dotnetuser Group=dotnetuser Restart=on-failure Syslog...
launch a dotnet core executable through daemon systemd in relative path
1,454,857,655,000
When using a systemd user instance (systemd --user), every user-created daemons are owned by this instance. For example: Let's create a daemon: nohup sleep 100 0<&- &>/dev/null &. It has PID 12549. Kill the parent terminal process (or directly the shell) so that it becomes a daemon The new parent of the process is th...
Kill the parent […] so that it becomes a daemon No it doesn't. A dæmon is not associated with a controlling terminal or a login session. A process running via nohup most definitely still is. After all, if it were not, there would be no point to the gynmastics of ignoring controlling terminal hangup. When a proce...
How do user-created daemons get caught by the systemd user instance?
1,454,857,655,000
With a new installation of docker (v17.04.0-ce), I have a quite strange error : After starting the daemon with $sudo service docker start (or the systemctl command, it leads to the same), I've got a Job for docker.service failed. See "systemctl status docker.service" and "journalctl -xn" for details. Ok. But here is...
Okay, that was incredibly tricky. To solve this, rename /var/lib/docker in something else (for backup, who knows ...), create a new /var/lib/docker directory, and ... it should start !
Docker daemon not starting without error
1,371,822,060,000
I accidentally deleted a file from my laptop. I'm using Fedora. Is it possible to recover the file?
I would advise against immediately installing some utility. Basically your biggest enemy here are disk writes. You want to avoid them at all costs right now. Your best bet is an auto-backup created by your editor--if it exists. If not, I would try the following trick using grep if you remember some unique string in ...
Recovering accidentally deleted files
1,371,822,060,000
I am not talking about recovering deleted files, but overwritten files. Namely by the following methods: # move mv new_file old_file # copy cp new_file old_file # edit vi existing_file > D > i new_content > :x Is it possible to retrieve anything if any of the above three actions is performed assuming no special pro...
The answer is "Probably yes, but it depends on the filesystem type, and timing." None of those three examples will overwrite the physical data blocks of old_file or existing_file, except by chance. mv new_file old_file. This will unlink old_file. If there are additional hard links to old_file, the blocks will remain ...
Can overwritten files be recovered?
1,371,822,060,000
Recently, my external hard drive enclosure failed (the hard drive itself powers up in another enclosure). However, as a result, it appears its EXT4 file system is corrupt. The drive has a single partition and uses a GPT partition table (with the label ears). fdisk -l /dev/sdb shows: Device Boot Start E...
Unfortunately, I was unable to recover the file system and had to resort to lower-level data recovery techniques (nicely summarised in Ubuntu's Data Recovery wiki entry), of which Sleuth Kit proved most useful. Marking as answered for cleanliness' sake.
Recovering ext4 superblocks
1,371,822,060,000
I have (well, I had) a directory: /media/admin/my_data It was approximately 49GB in size and had tens of thousands of files in it. The directory is the mount point of an active LUKS partition. I wanted to rename the directory to: /media/admin/my_data_on_60GB_partition I didn't realise at the time, but I issued the c...
When moving files between filesystems, mv doesn't delete a file before it's finished copying it, and it processes files sequentially (I initially said it copies then deletes each file in turn, but that's not guaranteed — at least GNU mv copies then deletes each command-line argument in turn, and POSIX specifies this b...
I've just "mv"ed a 49GB directory to a bad file path, is it possible to restore the original state of the files?
1,371,822,060,000
I feel like a kid in the principal's office explaining that the dog ate my homework the night before it was due, but I'm staring some crazy data loss bug in the face and I can't figure out how it happened. I would like to know how git could eat my repository whole! I've put git through the wringer many times and it's ...
Yes, git ate my homework. All of it. I made a dd image of this disk after the incident and messed around with it later. Reconstructing the series of events from system logs, I deduce what happened was something like this: A system update command (pacman -Syu) had been issued days before this incident. An extended net...
How did `git pull` eat my homework?
1,371,822,060,000
Our system crashed and we're trying to recover our data. The disc is fine, but the OS is gone, so I'm trying to get at the actual MySQL database files. Does anybody know where to look for them in a Debian Linux server?
MySQL stores DB files in /var/lib/mysql by default, but you can override this in the configuration file, typically called /etc/my.cnf, although Debian calls it /etc/mysql/my.cnf.
Where does MySQL store its databases on Debian?
1,371,822,060,000
I used the command mv folder_name .... I thought by using .. twice, it would move it back two folders. Unfortunately my files disappeared. I need to recover them.
Your directory is still there :) You have renamed it .... Because files whose names start with . are hidden, you cannot see the directory unless you display hidden files run ls -A and there it is! Revert the change: mv .... original_folder_name and do the move correctly mv original_folder_name ../..
Wrong mv command. Where did my files go? [duplicate]
1,371,822,060,000
Classical situation: I ran a bad rm and realized immediately afterwards that I had removed the wrong files. (Nothing critical and I had tolerably recent backups, but still annoying.) Knowing that further disk activity was my enemy if I wanted to recover the files with extundelete or such tools, I immediately powered t...
It sounds like you've got a decent grasp on what happened. Yes, because you hard-powered-off the system before your changes were committed to disk, they were there when you booted back up. The system caches all writes before flushing them out to disk. There are several options which control this behavior, all located ...
Why did powering down my machine after a bad `rm` save my files?
1,371,822,060,000
I made a recording with ffmpeg -f alsa -ac 2 -i plughw:0,0 /tmp/audio.mp4 I then moved /tmp/audio.mp4 to another directory (/root/audio.mp4) without stopping ffmpeg leading to a broken .mp4 file: ffplay /root/audio.mp4 [...] [mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f3524000b80] moov atom not found audio.mp4: Invalid data foun...
You can try and use Untrunc to fix the file. Restore a damaged (truncated) mp4, m4v, mov, 3gp video. Provided you have a similar not broken video. you may need to compile it from source, but there is another option to use a Docker container and bind the folder with the file into the container and fix it that way. ...
How to recover a broken mp4 file: moov atom not found
1,371,822,060,000
I have a 4GB SD card with some family pictures on it that I need to recover. When I insert the card into my card reader, it shows up as an unknown 32MB device (as /dev/sde) and cannot be mounted. When inserting back into the camera (a Nikon D60), it says the cards needs to be formatted (as does inserting it into a Win...
First, from your experience with the second card, it seems that your reader is damaged and now damages the cards you insert into it. Stop using that reader immediately, and try to recover the card with another reader. If your data is at all valuable, try to get a brand-name reader with better quality than a bottom-pri...
How to recover data from a bad SD card?
1,371,822,060,000
I accidentally overwrote the /bin/bash file with a dumb script that I intented to put inside the /bin folder. How do I get the contents of that file back? Is there a way I can find the contents on the web, and just copy them back in? What are my options here, considering that terminal gives an error talking about "To...
bash is a shell, probably your system shell, so now weird things happen, while parts of the shell are still in memory. Once you log out or reboot, you,ll be in deeper trouble. So the first thing should be to change your shell to something safe. See what shells you have installed cat /etc/shells Then change your shell...
What are the contents of /bin/bash, and what do I do if I accidentally overwrote them
1,371,822,060,000
I tried dd, dd_rescue and ddrescue, all failed. I thought these tools bypass the filesystem and make a bitwise copy. dd is fooled, it finishes but just produces a small file and states it's finished. dd_rescuse and ddrescue are complaining about read errors and are intolerably slow. These tools can copy only a few MB ...
I think that the simplest answer is that dd, dd_rescue and ddrescue are not designed to defeat copy protection schemes. They make no assumptions about the format of the data and try to maintain the integrity of the whole of the original on disk data. In the case of dd I suspect that it is terminating due to an intenti...
Why can't I copy my DVD with dd?
1,371,822,060,000
Usually when I find a command I want to alias, I echo it to my .bashrc like so: [up button pressed to last command, then line edited so that it reads] $echo "command-i-just-did" >> ~/.bashrc There may be a better way to do this. But anyway, just now I overwrote the entire .rc file by using a single chevron. However, ...
alias without parameter outputs the definitions of currently defined aliases. declare -f outputs the definitions of currently defined functions. export -p outputs the definitions of currently defined variables. All those commands output definitions ready to be reused, you can redirect their outputs directly to a new...
.bashrc overwritten but still sourced -- how can it be recovered?
1,371,822,060,000
I use Kate for coding and note-taking. Sometimes it crashes - often when I've got a lot open. Unsaved 'real' documents (eg, ones backed by files, that have been saved at some point) usually have a backup/autosave type recovery file, that more-or-less works. Unfortunately, I've gotten in the habit of using untitled...
Being one of the Kate Developers, I can explain the workflow like this: When Kate or the system crashes, you loose all text buffers that were never saved. However, if you are working on a text file (that exists as file on disk), a swap file is created next to the file, called .filename.kate-swp. Now, if Kate starts ag...
How can I recover after Kate crashes?
1,371,822,060,000
I booted Ubuntu in recovery mode to try and fix a disk error. However, when I run: fsck I just get: fsck from util-linux 2.31.1 And nothing else happens. Any fsck command is simply printing 'fsck from util-linux 2.31.1' and exiting, regardless of options and arguments. This is preventing me from fixing the disk erro...
The command I needed was fsck.ext4, e.g. fsck.ext4 -F This let me fix the disk issues and recover the system.
Ubuntu recovery says "fsck from util-linux" and exits
1,371,822,060,000
Some time ago I had a RAID5 system at home. One of the 4 disks failed but after removing and putting it back it seemed to be OK so I started a resync. When it finished I realized, to my horror, that 3 out of 4 disks failed. However I don't belive that's possible. There are multiple partitions on the disks each part of...
First check the disks, try running smart selftest for i in a b c d; do smartctl -s on -t long /dev/sd$i done It might take a few hours to finish, but check each drive's test status every few minutes, i.e. smartctl -l selftest /dev/sda If the status of a disk reports not completed because of read errors, then thi...
How to recover a crashed Linux md RAID5 array?
1,371,822,060,000
I had a directory containing some 2000 files. I ran the following command to move those 2000 files into a target directory: find /opt/alfresco \ -type f \( -iname \*.pdf -o -iname \*.xml \) \ -exec mv {} /opt/alfresco/archived/2020-01-07 \; > /opt/alfresco/scripts/move.log But, I forgot to append a /...
Adding a slash at the end of the destination path /opt/alfresco/archived/2020-01-07 would have made the mv command error out, as the 2020-01-07 directory evidently does not exist. This would have saved your files. They would also have been saved if /opt/alfresco/archived/2020-01-07 had been an existing directory (reg...
How can I change a file to a directory? Files lost after find+mv
1,371,822,060,000
I have a computer that I need to boot into, but the passwords seem to be bogus. Additionally I can't mount the drive for writing, and it is a mips processor, so I can't stick it in another machine to run it. Anyhow, they passwd file has some users that look like this, with a star after the user-name. does that mean b...
You have to check man passwd: If the encrypted password is set to an asterisk (*), the user will be unable to login using login(1), but may still login using rlogin(1), run existing processes and initiate new ones through rsh(1), cron(8), at(1), or mail filters, etc. Trying to lock an acco...
what does star in passwd file mean?
1,371,822,060,000
I am in the process of salvaging data from a 1 TB failing drive (asked about it in Procedure to replace a hard disk?). I have done ddrescue from a system rescue USB with a resulting error size of 557568 B in 191 errors, probably all in /home (I assume what it calls "errors" are not bad sectors, but consecutive sequenc...
You'll need the block numbers of all encountered bad blocks (ddrescue should have given you a list, I hope you saved it), and then you'll need to find out which files make use of these blocks (see e.g. here). You may want to script this if there are a lot of bad blocks. e2fsck doesn't help, it just checks consistency ...
How can I find out which files are lost through a ddrescue recovery atempt?
1,371,822,060,000
I used the terminal to copy files from one drive to another. sudo mv -vi /location/to/drive1/ /location/to/drive2/ However that suddenly stopped, while some hours into it, and without an error, after creating a directory. My own solution to that is often a mix of hashing and comparing which is mostly a time consuming...
Forget about trying to reinvent rsync, and use rsync. sudo rsync -av /location/to/drive1/ /location/to/drive2/ Make sure you use a trailing slash on the source, otherwise it would copy to /location/to/drive2/drive1. Double-check that the command succeeded, then run rm -rf /location/to/drive1/. The command above will ...
Best practice to continue mv
1,371,822,060,000
I have a failing hard drive that is unable to write or read the first sectors of the disk. It just gives I/O errors and that is all there is. There are other areas on the disk that seem (mostly) fine. I am trying to mount a partition (ext4) and see if I can access some files I would like to recover. Since the mount co...
There isn't a standard offset per-se, as of course you can start the partition wherever you want. But let's assume for a moment that you're looking for the first partition, and it was created more or less accepting defaults. There are then two places you may find it, assuming you were using a traditional DOS partition...
How do I find the offset of an ext4 filesystem?
1,371,822,060,000
I accidentally deleted /etc/redhat-release file. How can I restore or create a new one? I have CentOS Linux release 7.0.1406 (Core).
You can use RPM to see what RPM that file belongs to: $ rpm -qf /etc/redhat-release centos-release-7-0.1406.el7.centos.2.5.x86_64 You can then fix it using yum: $ yum reinstall centos-release Might not work If the RPM that was used to do this install is no longer available then the above will not work: $ yum reinsta...
Accidentally deleted /etc/redhat-release file
1,371,822,060,000
I accidentally wrote a 512 bytes binary to the wrong USB disk with dd and the device doesn't show any partitions with fdisk anymore. I thought all the data was gone, but dd if=/dev/sdx | strings shows that the data seems to be still there, since dd fortunately limited itself to the first 512 bytes. Is there any way to...
To restore the ext4 partition and its data, I thought about creating one, disk-wide ext4 partition. This allowed me to get access to the data and retrieve information about the partition with tune2fs -l, as suggested by @thkala. This information looks very feasible and, so, unaltered. Very interestingly, gparted is s...
Deleted first 512 bytes of disk; how can I recover my data?
1,371,822,060,000
I've been using tar with its "--use-compress-prog=pbzip2" function to archive my files then compress them with pbzip2 to get an "*.tar.bz" archive. Afterwards I checked the resulting file with pbzip2's "-t" switch, and it passed the test. However, to great surprise, I got "file incomplete" or other integrity errors wh...
First test bzip2 compression, It should output OK. bzip2 -tv FILE.tar.bz2 Next uncompress the tarball, to get just the tar. bunzip2 FILE.tar.bz2 Finally verify the tar file, tar -tvWf FILE.tar Truthfully the best indicator of a problem, is a failed extraction. Hopefully you can narrow down the cause. I should also...
How to check/test .tar.bz archives?
1,371,822,060,000
A very old .swp file reverted a file I was editing, so it is now significantly shorter. I haven't done anything in that directory since, so the bytes immediately following the end of the file should still have my data. What function can I use to read N bytes from a given memory address? dd and read stop at file bounda...
Usually when editors save files, they delete or truncate to 0, thus freeing allocated space, and then write, which allocates new space. This results in the filesystem putting the data in a completely different physical location. So your idea might not work. You can get the physical location of a file using filefrag or...
Read past end of file to recover data
1,371,822,060,000
I accidentally executed rm /* while logged in as root in a remote Ubuntu Server and deleted pretty much all binaries and currently I can neither log in via ssh or ftp to restore the files (and hope for the best). Is there a way to somehow fix this mess, or should I call the datacenter and ask for a format?
rm /* should delete very little. There is no -r flag in there that would recursively delete anything, and without it directories will not be deleted (and even if directories were deleted, only empty ones can be deleted). This answer is predicated on the assumption that you did not run rm -rf /*. The only files in the ...
Accidentally executed sudo rm /* on a remote server
1,371,822,060,000
OS: Debian Bullseye, uname -a: Linux backup-server 5.10.0-5-amd64 #1 SMP Debian 5.10.24-1 (2021-03-19) x86_64 GNU/Linux I am looking for a way of undoing this wipefs command: wipefs --all --force /dev/sda? /dev/sda while the former structure was: fdisk -l /dev/sda Disk /dev/sda: 223.57 GiB, 240057409536 bytes, 468...
You're lucky that wipefs actually prints out the parts it wipes. These, wipefs -a /dev/sda /dev/sda: 8 bytes were erased at offset 0x00000200 (gpt): 45 46 49 20 50 41 52 54 /dev/sda: 8 bytes were erased at offset 0x3b9e655e00 (gpt): 45 46 49 20 50 41 52 54 /dev/sda: 2 bytes were erased at offset 0x000001fe (PMBR): 55 ...
Undoing wipefs --all --force /dev/sda? /dev/sda
1,371,822,060,000
Magnetic drive has failed. I used ddrescue to recover ~85% of it, with a map file, but the rest is borked and continuing to scrub it would take years. I can return it for a replacement. I'd like to shred my data first. When I try to write to it, it works for the first few hundred MB but then starts pouring input/outp...
The manual gives you an example which is almost exactly what you want: When ddrescue is invoked with the option --fill-mode it operates in "fill mode", which is different from the default "rescue mode". That is, in "fill mode" ddrescue does not rescue anything. It only fills with data read from infile the blocks of o...
Using ddrescue to shred only rescued portions of disk
1,371,822,060,000
In what I now know feel was a stupid decision, I attempted to dual boot Windows and linux by using the windows installer, After booting into the windows installer I chose one of a 2 cloned hard drives about 500GB in size to erase, as they were cloned it wouldn't matter if I picked one over the other. After doing so, t...
cryptsetup repair, Part Two — Full Header Recovery See also: cryptsetup repair, Part One — Magic Bytes Recovery In order to recover a partially overwritten LUKS2 header, you need at minimum two things: One, the key material of at least one of your keyslots. Two, the metadata describing how that key material is to be...
Overwritten LUKS with a partition table
1,371,822,060,000
There was a problem on an EXT4 FS/memorycard and after and fsck all the files were put in the lost+found. Question: how can I restore the old filename/hierarchy from the lost+found? Or it is impossible? Not counting a restore from backup.
Last time I had to do that - many years ago - you had to guess based on file content. I doubt there is a better way today. The 'file' program can help here since it will give you an idea of the type of data, so you can use this to view the files appropriately for a start.
Restore from lost+found
1,371,822,060,000
I installed Linux on another computer and I want to move my /home directory to that computer. I want to back up that directory with any file permission, symlinks etc. How should I do it? Are there any parameters for tar gzip?
If you mean you want to include the files that the symlinks point to, use -h. tar -chzf foo.tar.gz directory/ Permissions and ownership are preserved by default. If you just want to include the symlinks as symlinks, leave out -h. Small -z is for gzip. This is all spelled out in man tar; you can search for terms (suc...
Symlinks and permissions in backup archives
1,371,822,060,000
Suppose an apache log file gets deleted but it's held open by apache; then this is what I am doing: pid=$(lsof | grep text.txt | awk '/deleted/ {print $2}') fd=$(lsof | grep text.txt | awk '/deleted/ {print $4}' | grep -oE "[[:digit:]]{1,}") cp /proc/$pid/fd/$fd directorytobecopied/testfile.txt This is what I am doi...
If a file has been deleted but is still open, that means the file still exists in the filesystem (it has an inode) but has a hard link count of 0. Since there is no link to the file, you cannot open it by name. There is no facility to open a file by inode either. There is no way to discover the file through its filesy...
recovering deleted file held open by apache?
1,371,822,060,000
This event actually took place a few years ago, but I still have the unchanged USB flash drive in my possession. I may be out of luck, but I thought I would ask all you smart people here for your suggestions. Short Story: A few years back, my wife wanted to store all of her photos from her iPhone onto a USB flash driv...
Are there any secure UNIX tools to recover data, that was removed with rm, from a USB flash drive? Yes and, by the way, recovery of photos is one of the most common scenarios. The conditions you described are actually optimal because: you directly deleted the files the file system is not damaged you did not use the...
How can I safely recover deleted data from a USB flash drive?
1,371,822,060,000
Is it possible to recover files that have been rm'ed from an XFS filesystem? How can I recover any files assuming they haven't been overwritten? Edit: The existing questions regarding this topic are all assuming an ext{2,3,4} file system. I am looking for an XFS solution.
I deleted a python file that I knew had a specific fairly unique string in it. So I did the following: $ sudo strings -td /dev/mapper/vg01-lv_opt | grep "class Team(" 8648365228 class Team(object): 26133651864 class Team(Account): 26134147482 class Team(Account): I now had the offsets in the lvol where that string w...
How to recover xfs data after rm?
1,371,094,890,000
Somehow my partition on /dev/sdb has gotten all buggered up. This hard drive contains a lot of data that I need to recover and haven't been able to backup yet. When I attempt to mount it: # mount -t ext4 /dev/sdb /world mount: wrong fs type, bad option, bad superblock on /dev/sdb, missing codepage or helper pro...
Mount a partition, not the whole disk Your initial command was #mount -t ext4 /dev/sdb /world instead of #mount -t ext4 /dev/sdb3 /world (notice the use of the partition name instead of the disk name: /dev/sdb3 vs /dev/sdb). I have been bitten by this before, so I thought I might point it out. Use recovery tools In ...
mount: wrong fs type, bad option, bad superblock on /dev/sdb on CentOS 6.0
1,371,094,890,000
I am running a small uClibc and busybox based embedded system on an x86 device. I am using an initramfs but I also mounting a custom ext3 directory on a compact flash device in IDE mode that I am using to store persistent measurement logging data created by a custom written c++ application. I chose the ext3 file syste...
As with all things pertaining to security, there aren't any guarantees, but you also need to balance risk (and cost) against probability. From experience (and I've been running dozens of *nix boxen since the dark ages), I've never really had significant power-caused filesystem corruption. Some of these machines were e...
What filesystem offers best protection for securing data against corruption due to power loss?
1,371,094,890,000
I have an hourly hour-long crontab job running with some mtr (traceroute) output every 10 minutes (that is going to go for over an hour prior to it being emailed back to me), and I want to see the current progress thus far. On Linux, I have used lsof -n | fgrep cron (lsof is similar to BSD's fstat), and it seems like ...
The file can be access through the /proc filesystem: you already know the PID and the FD from the lsof output. cat /proc/21742/fd/5
How can I access a deleted open file on Linux (output of a running crontab task)?
1,371,094,890,000
I started downloading a big file and accidently deleted it a while ago. I know how to get its current contents by cping /proc/<pid>/fd/<fd> but since the download is still in progress it'll be incomplete at the time I copy it someplace else. Can I somehow salvage the file right at the moment the download finishes but ...
Using tail in follow mode should allow you to do what you want. tail -n +0 -f /proc/<pid>/fd/<fd> > abc.deleted I just did a quick test and it seems to work here. You did not mention whether your file was a binary file or not. My main concern is that it may not copy from the start of file but the -n +0 argument shoul...
Recover deleted file that is currently being written to
1,371,094,890,000
I am learning the value of having good backups. I have a 500GB hard drive which is failing. I started running ddrescue /dev/sdb1 backup.img mapfile and it was going to take 40 to 70 DAYS, depending on which moment you looked at it. I read this post which shows how to speed up the ddrescue with a -c 1Ki option. Now ...
ddrescue has this option: -a, --min-read-rate=<bytes> minimum read rate of good areas in bytes/s If you specify it on your command line with a decent size like 10M, with any luck, areas that are still able to read but extremely slow will be skipped first, and continue with other areas the drive is still ...
Faster disk recovery (ddrescue running slow)
1,371,094,890,000
Debian on external USB SSD drive. There was some error in dmesg log file: ...[ 3.320718] EXT4-fs (sdb2): INFO: recovery required on readonly filesystem [ 3.320721] EXT4-fs (sdb2): write access will be enabled during recovery [ 5.366367] EXT4-fs (sdb2): orphan cleanup on readonly fs [ 5.366375] EXT4-fs (sdb...
You can instruct the filesystem to perform an immediate fsck upon being mounted like so: Method #1: Using /forcefsck You can usually schedule a check at the next reboot like so: $ sudo touch /forcefsck $ sudo reboot Method #2: Using shutdown You can also tell the shutdown command to do so as well, via the -F switch: ...
How to repair a file system corruption?
1,371,094,890,000
Consider you've been informed about a bad sector like this: [48792.329933] Add. Sense: Unrecovered read error - auto reallocate failed [48792.329936] sd 0:0:0:0: [sda] CDB: [48792.329938] Read(10): ... [48792.329949] end_request: I/O error, dev sda, sector 1545882485 [48792.329968] md/raid1:md126: sda: unrecoverable I...
The traditional way is to copy all files elsewhere and see which one triggers a read error. Of course, this does not answer the question at all if the error is hidden by the redundancy of the RAID layer. Apart from that I only know the manual approach. Which is way too bothersome to actually go through with, and if th...
How to find out which file is affected by a bad sector?
1,371,094,890,000
I've recently suffered a maddeningly small but quite important amount of damage to a hard drive on a ESXi host affecting a couple VMs. There's a file that I would very much like to recover, and of course it was somehow left off of my regular backup. The most recent copies are 6 months old. Turns out I need that... oop...
A few notes from my experience: (the cause) If you hear an unusual sound during hd access attempts, and problems don't occur at (more or less) just random disk locations, then the root cause is most probably on the disk surface (not the electronics) - unfortunately, that's the sad scenario. If it were "just" the elec...
Advanced NTFS partition file recovery techniques for damaged drives (IO errors)?
1,371,094,890,000
I'm trying to recover my files from a now broken Antergos install, and have run into trouble because the user/non-boot partition is encrypted with LUKS encryption. I'm booting from an Ubuntu 18.04 bootable USB drive so I can backup the directories where I had data I wanted, and didn't realize it was encrypted until ...
To recover your files you will first need to open your LUKS container. This will make your LVM logical volumes accessible. Then, you can mount the appropriate logical volume to gain access to the files. I'll assume that once you have access to the files you'll know what to do. Opening the LUKS container To open the LU...
How to mount and de-encrypt a LUKS encrypted partition to recover files [closed]
1,371,094,890,000
This question addresses the first pass of ddrescue on the device to be rescued. I had to rescue a 1.5TB hard disk. The command I used is: # ddrescue /dev/sdc1 my-part-img my-part-map When the rescue is started (with no optional parameters) on a good area of the disk, the read rate ("current rate") stays around 18 MB/...
I have been wondering whether this can be dealt with with the option -a or --min-read-rate= ... but the manual is so terse that I was not sure. Besides, I do not understand on what basis one should choose a read rate for this option. Should it be the above 18 MB/s? The --min-read-rate= option should help. Modern dri...
Why is ddrescue slow when it could be faster on error free areas?
1,371,094,890,000
I've wiped my NTFS (windows) partition table using gparted by clicking on "Device->Create Partition Table... and then apply", is there a way to recover my NTFS partition? I tried using this command gpart /dev/sda I get the following out put: Begin scan... End scan. Checking partitions... Ok. Guessed primary partitio...
You might try using testdisk to recover the partition table. Testdisk will read the surface of the disk and attempt to determine where partitions start and end.
I've wiped my partition table using gparted, is there a way to recover my partition?
1,371,094,890,000
I accidently ran an rm -r on my .git directory. Luckly rm stopped when it got to a write-protected file, but I've still lost several things in my .git. Files I still have: FETCH_HEAD ORIG_HEAD config gitk.cache logs/ objects/ Files I've lost: HEAD description hooks/ index info/ packed-refs refs/ From what I can tell...
All of the commits and the files that they reference would be stored as objects in the objects directory. Git creates those as read-only, so they should all still be present. To recover, I'd advise creating a new, empty repository and copying the contents of your broken repository's objects directory into that of ...
How to recover broken/partially deleted git repository
1,371,094,890,000
I deleted a file I meant to shred first. $ rm somefile instead of $ shred somefile $ rm somefile Is there a way to shred a file after 'rm'-ing it?
There is no way to properly securely erase a file with modern filesystems anymore, because the journal can still contain data and there is no reliable way to overwrite the journal. You can try to disable journalling on the filesystem before deletion, but it won't do anything about data that may already be in the journ...
How to securely delete data after rm
1,371,094,890,000
Given a single raid1 drive in degraded/rebuilding state, can it be force mounted? I'd like to recover all the files before undertaking the dangerous operation of pairing it and rebuilding. As far as I can tell the drive is in perfectly good shape, fully intact. The pair drive is partly failed. If the drive was not i...
If it's RAID 1, and if you know the data offset (e.g. 2048 sectors, you can usually find out the exact data offset by mdadm --examine /dev/sdb1), then you can create a read-only (to be safe) loop device like so: # losetup --find --show --read-only --offset $((2048*512)) /dev/sdb1 /dev/loop7 And then try to check the...
How do I recover files from a single degraded mdadm raid1 drive? "not enough to start the array"
1,371,094,890,000
Let's say I have two identical disks, and I set one LVM logical volume on them (no mirroring). Question: What will happen when one of the disks fails? I will lose all the data from all the disks I will lose the data from broken disk, but I get data from still working one something else (what) ? Thank you in advance ...
The worst and most likely case is that you will lose everything. If you have a single logical volume spanning both drives, and you lose one drive with no mirroring, you've essentially wiped out half the file system. From this point, it gets mildly better depending on what file system you are running on your volume. A...
Does LVM increase the risk of data loss?