# can't exec /bin/sh for /etc/rc: no such file or directory



## SirFulgeruL (Jun 30, 2014)

Hello guys,

I own a VPS and *I* had a problem with it*.* I type in `ee /etc/rc.conf`" and it said 
	
	



```
command ee doesn't exist
```
 or something like that. Even the command to start mysql didn't work. I typed `reboot` and after that I waited like 10 minutes and saw that my VPS didn't start. I logged into my control panel and I saw the error 
	
	



```
can't exec /bin/sh for /etc/rc: no such file or directory
```
.







P.S: I sent a ticket to my hosting company and they said that they don't offer support for FreeBSD.


----------



## wblock@ (Jun 30, 2014)

*Re: can't exec /bin/sh for /etc/rc: no such file or director*

Is there anything in /etc/?  Maybe it is not mounted, or even deleted.


----------



## SirFulgeruL (Jun 30, 2014)

*Re: can't exec /bin/sh for /etc/rc: no such file or director*

I don't know, how should I check?


----------



## wblock@ (Jun 30, 2014)

*Re: can't exec /bin/sh for /etc/rc: no such file or director*

Try to boot in single user mode.


----------



## SirFulgeruL (Jun 30, 2014)

*Re: can't exec /bin/sh for /etc/rc: no such file or director*

I booted it with single user , and i got in my console :
`Enter full pathname of shell or RETURN for /bin/sh:`


----------



## phoenix (Jun 30, 2014)

*Re: can't exec /bin/sh for /etc/rc: no such file or director*

Is it mounting the correct root filesystem?  Are you sure it's /dev/vtbd0p2?

Try dropping to the loader prompt and getting a listing of devices (I think *?* will show the list of commands, and there's a list devices command in there).  Then set the *mountroot* option to a different device.  Guessing there will be at least a /dev/vtbd0p1 that you can try.


----------



## SirFulgeruL (Jun 30, 2014)

*Re: can't exec /bin/sh for /etc/rc: no such file or director*

Sorry, but how I do that? 
P.S: You mean booting in loader prompter mode, and then `lsdev` and `set currdev=device`?


----------



## wblock@ (Jun 30, 2014)

*Re: can't exec /bin/sh for /etc/rc: no such file or director*

That's a good sign.  Now look in /etc with `ls /etc`.  If there are files in there, does /etc/rc exist?


----------



## wblock@ (Jun 30, 2014)

*Re: can't exec /bin/sh for /etc/rc: no such file or director*



			
				phoenix said:
			
		

> Is it mounting the correct root filesystem?  Are you sure it's /dev/vtbd0p2?
> 
> Try dropping to the loader prompt and getting a listing of devices (I think *?* will show the list of commands, and there's a list devices command in there).  Then set the *mountroot* option to a different device.  Guessing there will be at least a /dev/vtbd0p1 that you can try.



p1 is usually the bootcode partition.


----------



## SirFulgeruL (Jun 30, 2014)

*Re: can't exec /bin/sh for /etc/rc: no such file or director*



			
				wblock@ said:
			
		

> That's a good sign.  Now look in /etc with `ls /etc`.  If there are files in there, does /etc/rc exist?



I typed `ls /etc` and I got a*n* error*:*

```
can't exec ls /etc for single user: No such file or directory
can't exec /bin/sh for single user: No such file or directory
```

That's the same e*r*ror when *I* type for example `cd /etc` in normal booting mode .


----------



## wblock@ (Jul 1, 2014)

*Re: can't exec /bin/sh for /etc/rc: no such file or director*

That's an odd error message.  Wait, when it said Enter full pathname of shell or RETURN for /bin/sh:, did you press Enter?  Do that first, then it should go into a root shell.  Then try `ls`.


----------



## SirFulgeruL (Jul 1, 2014)

*Re: can't exec /bin/sh for /etc/rc: no such file or director*



			
				wblock@ said:
			
		

> That's an odd error message.  Wait, when it said Enter full pathname of shell or RETURN for /bin/sh:, did you press Enter?  Do that first, then it should go into a root shell.  Then try `ls`.


I pressed returned and typed `ls` and after 40 seconds it said

```
can't exec /bin.sh for /etc/rc: No such file or directory
```
and after another 30 seconds it said 

```
Enter full pathname of shell or RETURN for /bin/sh:
```


----------



## wblock@ (Jul 1, 2014)

*Re: can't exec /bin/sh for /etc/rc: no such file or director*

That's not good.  Any chance you have backups?


----------



## SirFulgeruL (Jul 1, 2014)

*Re: can't exec /bin/sh for /etc/rc: no such file or director*

No .. I want backup on my MySQL but *I* think no chance to get it. And how did this problem happen? From what?

P.S: Do *I* have a chance to get a backup from my MySQL?


----------



## wblock@ (Jul 1, 2014)

*Re: can't exec /bin/sh for /etc/rc: no such file or director*

@phoenix's suggestion to look at the partition layout is worthwhile.  A physical machine could be booted from a CD or USB stick.  With a VPS, it probably depends on what the provider offers.


----------



## Crivens (Jul 1, 2014)

*Re: can't exec /bin/sh for /etc/rc: no such file or director*



			
				wblock@ said:
			
		

> Is there anything in /etc/?  Maybe it is not mounted, or even deleted.


Out of curiosity: how would you boot a system with a mount-on /etc anyway? Is that possible in _any_(sane) way?

And one possible solution for the OP: if the syetem is destroyed beyond repair, you *may* be able to reclaim your database by doing a new install and be *extra careful* not to format the partition that database was on, do not do a newfs on these. Simply extract the installation archives again, and you may be able to reboot the system to a point where you can reclaim the database. And back it up at once. I had to do something like this once, it worked then, but I do not know if it will today. So if you have reached the point that you want to give up and re-install, there is this (maybe slim) chance to get the machine going again, even when you cannot boot it from USB or DVD rescue mediums.

Or you can kindly ask the provider of the VPS if you can obtain a dd dump of the disk image on a drive you send them. Some do this, and I would wager that a add-on in beverages may help you in this (as - send some SD cards for storage and some nice scotch. That would work on me.


----------



## Crivens (Jul 1, 2014)

*Re: can't exec /bin/sh for /etc/rc: no such file or director*



			
				SirFulgeruL said:
			
		

> And how did this problem happend ? From what ?


Even the VPS servers can have faulty disk drives, and even failing mirrors. There were cases like this in the last month, one of my favorite podcasters had to restore _a lot_ of stuff because the mirror in distribution machine failed like that, and quietly too.

But that would maybe some add-on to the loader concept of FreeBSD. Browsing file systems from the loader is nice, now we need some netcat build in so a rescue of files can be done from the loader.


----------



## SirFulgeruL (Jul 1, 2014)

*Re: can't exec /bin/sh for /etc/rc: no such file or director*

My provider doesn't offer any support*.*


----------



## wblock@ (Jul 1, 2014)

*Re: can't exec /bin/sh for /etc/rc: no such file or director*

@Crivens: you're right, it's probably not possible to boot without /etc being present for fstab.

As far as adding to the loader, I'd rather just boot into mfsBSD.  When the original system is having major problems, best to use a separate system to check it.  Come to think of it, mfsBSD could be one of the best reasons to justify multiboot in the present era.  I have it on my PXE server for the same kind of availability.


----------



## jonfr (Jul 1, 2014)

*Re: can't exec /bin/sh for /etc/rc: no such file or director*

Can you get into root partition?


----------



## SirFulgeruL (Jul 1, 2014)

*Re: can't exec /bin/sh for /etc/rc: no such file or director*

Thanks guys for your help . I decided to reinstall my Dedicat server. .


----------



## Crivens (Jul 2, 2014)

*Re: can't exec /bin/sh for /etc/rc: no such file or director*

Remember, if you can skip the format operation, the file could be recovered.


----------

