# Unable to create file /etc/rc.conf



## dalpets (Dec 11, 2019)

I had occasion to make an additional entry in /etc/rc.conf, but due to an unterminated syntax error Fbsd would not save the file throwing up the error 'unable to create file'. When I rebooted (@ root) and corrected the error I still received the same error message & still could not reboot the system.
Is there a workaround to fix the problem ie., without reinstalling the whole system?

Thank You for any help.


----------



## Alexander88207 (Dec 11, 2019)

Hello *dalpets,*

how do you edit the file? Also, i think you should describe your problem more precise.


----------



## dalpets (Dec 11, 2019)

Alexander88207 said:


> Hello *dalpets,*
> 
> how do you edit the file? Also, i think you should describe your problem more precise.


Editing has been done with ee editing software. The reason for the attempted editing is that I have a problem whereby the 'startup', 'restart' & 'shutdown' widgets on the Plasma desktop are grayed out, so shutdown can only be achieved via the terminal or the 3 finger shutdown salute.
*malavon *in the kde desktop forum suggested a fix might be to add sysrc hald_enable="YES" to /etc/rc.conf. Unfortunately when editing the file I made a syntax error  & that resulted in the 'unable to create file "/etc/rc.conf" ' message, .
This has happened  a few times with other versions of Fbsd requiring complete reinstallation. Hopefully someone knows how to fix the problem without the need to do so now or in future.


----------



## ljboiler (Dec 11, 2019)

If editing using the ee editor, only add
	
	



```
hald_enable="YES"
```

The suggestion by malavon is how to make the change to /etc/rc.conf from the command line, without using any editor.


----------



## dalpets (Dec 11, 2019)

ljboiler said:


> If editing using the ee editor, only add
> 
> 
> 
> ...


OK, but how do I get over this dreaded problem now that it has happened?


----------



## Barney (Dec 11, 2019)

Learn vi


----------



## SirDice (Dec 11, 2019)

dalpets said:


> Unfortunately I caused a syntax error when doing so that resulted in the 'unable to create file "/etc/rc.conf" ' failure message when trying to reboot or save the file.


I suspect you're stuck in single user mode due to the error. In single user mode the root filesystem is mounted but is read-only. You need to remount it before you can make changes.

For UFS:

```
fsck -y
mount -u /
mount -a -t ufs
swapon -a
```

For ZFS it's a little easier:

```
zfs set readonly=no zroot/ROOT/default
```


----------



## Sevendogsbsd (Dec 11, 2019)

Barney said:


> Learn vi



Not a helpful suggestion since the editor is not the OPs issue.


----------



## Deleted member 30996 (Dec 11, 2019)

dalpets said:


> I had occasion to make an additional entry in /etc/rc.conf, but due to an unterminated syntax error Fbsd would not save the file throwing up the error 'unable to create file'. When I rebooted (@ root) and corrected the error I still received the same error message & still could not reboot the system.



The same thing happened to me last night, after I had "carefully" looked to make sure I had not missed commenting a line. I became root and tried to edit it from there but got the same "unable to create file" error and had to mount it first as SirDice outlined for the UFS filesystem.


----------



## malavon (Dec 11, 2019)

As others have said, it's probably because you're in single user mode. There might have a way to prevent that from happening in the future though.


dalpets said:


> Unfortunately I caused a syntax error when doing so that resulted in the 'unable to create file "/etc/rc.conf" ' failure message when trying to reboot or save the file.


`sysrc hald_enable=YES`
This does the same as editing /etc/rc.conf, but the chances of making a syntax mistake are smaller. The most important thing is that only that single line is added or modified.


----------



## dalpets (Dec 12, 2019)

I boot automatically to the desktop & then log in as user with my password.
Would it be easier to just delete the file as root (in the bootup domain) then reinstall it there with all correct lines with ee?


----------



## tingo (Dec 12, 2019)

If you are able to boot your machine normally, you can use tools like su(1) or sudo(8) to get root access, and edit any files with any editor you are comfortable with.


----------



## dalpets (Dec 12, 2019)

tingo said:


> If you are able to boot your machine normally, you can use tools like su(1) or sudo(8) to get root access, and edit any files with any editor you are comfortable with.


My point is that I can get to the root prompt in the failing bootup process & then access the file, whilst  in the same failed circumstance I can't fully boot to the single user desktop mode.  Single user issues aside, being able to access root there does not allow the error to be fixed. It seems an intractible error, hence my question about whether or not in the bootup mode it is practical to delete & reinstall the full file without other repercussions.


----------



## ljboiler (Dec 12, 2019)

The system should boot up in a fully functional multi-user console mode without a /etc/rc.conf file.
I would rename (not delete) the existing file to give you something to work from when re-creating it.


----------



## Deleted member 30996 (Dec 12, 2019)

dalpets said:


> My point is that I can get to the root prompt in the failing bootup process & then access the file, whilst  in the same failed circumstance I can't fully boot to the single user desktop mode.  Single user issues aside, being able to access root there does not allow the error to be fixed.



When you get to the initial point of failure, where it stops the normal boot process, then you need to enter the commands laid out by SirDice for the file system you use to mount it. Then you will be able to use `ee /etc/rc.conf` to fix it from there:


----------



## dalpets (Dec 13, 2019)

Trihexagonal said:


> When you get to the initial point of failure, where it stops the normal boot process, then you need to enter the commands laid out by SirDice for the file system you use to mount it. Then you will be able to use `ee /etc/rc.conf` to fix it from there:


Sir Dice's fix works.Hurray! That will save a lot of work.


----------



## dalpets (Dec 13, 2019)

Barney said:


> Learn vi


So tell me, how would vi successfully deal with the problem to make it the ideal approach?


----------



## dalpets (Dec 13, 2019)

malavon said:


> As others have said, it's probably because you're in single user mode. There might have a way to prevent that from happening in the future though.
> 
> `sysrc hald_enable=YES`
> This does the same as editing /etc/rc.conf, but the chances of making a syntax mistake are smaller. The most important thing is that only that single line is added or modified.


Why does the system stop access to multi user mode when there is a file error?


----------



## ljboiler (Dec 13, 2019)

Better safe than sorry...
Would you rather want the system just plow ahead and hope that the "error" doesn't totally corrupt things?


----------

