SOLVED Issued mv command and now server won't work

Status
Not open for further replies.

rwhite2366

Dabbler
Joined
Jul 4, 2016
Messages
16
tl;dr: Tried to move all the files of a directory up one level to the parent directory using mv tv_show/*. Now, server shows init: can't exec /bin/sh for single user: No such file or directory.

I use FreeNAS to host my media. I had a folder that contained several episodes of a tv show, and this folder resided inside my renamer folder for sonarr. Usually, sonarr would scan the folder and rename and move any media files to Plex. However, sonarr wasn't recognizing the single folder that contained the tv episodes. So, I decided to move all of the tv episode files up a directory into the renamer folder, so that sonarr could scan them individually, rename, and move. I used the following command in the FreeNAS shell:

mv tv_show/*

where "tv_show" was the directory that contained all of the tv show episodes.

I don't remember what happened exactly next, but either FreeNAS or I closed the shell window. Immediately after this, the web gui for FreeNAS was displaying some odd text. On every tab of the gui, instead of displaying the information as normal, it displayed this message:

Code:

Environment:


Software Version: FreeNAS-9.10.1-U4 (ec9a7d3)

Request Method: GET

Request URL: http://192.168.127.141/system/info/?dojo.preventCache=1483771131558

Traceback:

File "/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response

  105.  response = middleware_method(request, callback, callback_args, callback_kwargs)

File "/usr/local/www/freenasUI/../freenasUI/freeadmin/middleware.py" in process_view

  156.  return login_required(view_func)(request, *view_args, **view_kwargs)

File "/usr/local/lib/python2.7/site-packages/django/contrib/auth/decorators.py" in _wrapped_view

  22.  return view_func(request, *args, **kwargs)

File "/usr/local/www/freenasUI/../freenasUI/system/views.py" in system_info

  139.  sysinfo = _system_info(request)

File "/usr/local/www/freenasUI/../freenasUI/system/views.py" in _system_info

  118.  shell=True

File "/usr/local/lib/python2.7/subprocess.py" in check_output

  566.  process = Popen(stdout=PIPE, *popenargs, **kwargs)

File "/usr/local/lib/python2.7/subprocess.py" in __init__

  710.  errread, errwrite)

File "/usr/local/lib/python2.7/subprocess.py" in _execute_child

  1335.  raise child_exception


Exception Type: OSError at /system/info/

Exception Value: [Errno 2] No such file or directory


The strange thing, though, is that the server continued to host the media, and I could watch anything as I normally would.

Then, I restarted the server, and everything stopped working. FreeNAS won't come on line. I get the following message:

Code:
init: can't exec /bin/sh for single user: No such file or directory
Enter full pathname of shell or RETURN for /bin/sh:


And then, repeatedly:

Code:
ugen0.6: <Logitech> at usbus0
ugen0.6: <Logitech> at usbus0 (disconnected)


Thanks for your time

Edit: So I was able to solve the problem with the help of a redditer. You can see the process at my post here:
https://www.reddit.com/r/freenas/comments/5o2at9/issued_mv_command_and_now_server_wont_work/dcggw5m/

In a nutshell, I think I issued mv tv_show /* instead of mv tv_show/* and it attempted to move everything by starting with /bin and it quickly filled up /var, and when I restarted it wiped /var. I was able to direct path to /rescue/sh to get shell commands, and then found snapshots. I copied /bin to the root directory and restarted and everything is running well again *so far*.
 
Last edited:
D

dlavigne

Guest
What happens if you install to a new stick, boot with that, and restore your config?
 

Robert Trevellyan

Pony Wrangler
Joined
May 16, 2014
Messages
3,778
mv tv_show/*
Are you 100% sure? The only result you would have seen from that command is a usage guide for mv, because it's not syntactically correct. Both source and destination are required.
Code:
robs-air:~ rob$ mv Downloads/*
usage: mv [-f | -i | -n] [-v] source target
	  mv [-f | -i | -n] [-v] source ... directory
robs-air:~ rob$ 

Therefore, if that really is the command you issued, it was coincidental with the failure you saw next, and did not cause it.
 

Robert Trevellyan

Pony Wrangler
Joined
May 16, 2014
Messages
3,778
Shell expansion happens before command execution. The actual "mv" command would have got lots of arguments from the expansion of the '*'.
Can you explain how that might have led to /bin/sh getting trashed?
 

wblock

Documentation Engineer
Joined
Nov 14, 2014
Messages
1,506
The very last argument to mv being used as the destination?
 

Robert Trevellyan

Pony Wrangler
Joined
May 16, 2014
Messages
3,778
But how could something that matches the pattern tv_show/* be interpreted as a destination in /bin?
 

wblock

Documentation Engineer
Joined
Nov 14, 2014
Messages
1,506
Well, there's quoting, and . and .. and possibly other things. I don't know exactly what happened, but it certainly messed with operating system files or directories.
 

Robert Trevellyan

Pony Wrangler
Joined
May 16, 2014
Messages
3,778
I don't buy it. I think either it's a coincidental failure, e.g. the boot device (note the "ugen0.6: <Logitech> at usbus0 (disconnected)" message), or the command issued was something other than the one reported. Anyway, unless the OP responds, it will remain a mystery.
 
Status
Not open for further replies.
Top