Cannot edit /etc/rc.conf

Hello everyone. I'm new to freebsd and just got my box running and started installing stuff on it. I messed up rc.conf and now when I boot it tells me this.

Code:
Loading configuration files.
apache22_enable: not found
/etc/rc.conf: 17: Syntax error: Unterminated quoted string
Enter full pathname of shell or RETURN for /bin/sh:

I assume that is because I wrote this in rc.conf

Code:
apache22_enable = "YES"

instead of this

Code:
apache22_enable="YES"

or maybe because I forgot a quote on

Code:
webmin_enable="yes

Either way I need to go and edit /etc/rc.conf. I login as root and try to use vim to edit it and I get these errors.

Code:
W10: Warning: Changing a readonly file
E303: Unable to open swap file for "etc/rc.conf", recovery impossible
Press ENTER or type command to continue.

Code:
"/etc/rc.conf" E212: Can't open file for writing
Press ENTER or type command to continue.

How can I edit /etc/rc.conf? Thanks in advance.
 
IIjkII said:
Code:
W10: Warning: Changing a readonly file
E303: Unable to open swap file for "etc/rc.conf", recovery impossible
Press ENTER or type command to continue.

Code:
"/etc/rc.conf" E212: Can't open file for writing
Press ENTER or type command to continue.

Is your root filesystem mounted read-only? I believe that can/does happen when you have an error in rc.conf. I also remember seeing a similar thread to this not too long ago.
 
Thanks for the quick reply. It might be, it's all in grey txt now and I don't know what that meant. I assumed it was some sort of emergency shell. I also tried mounting the disk to /mnt and I got the same errors.
 
With # fsck you check the filesystems, # mount -u / mounts the root partition read/write, # mount -a -t ufs mounts all UFS partitions, so you can use vi and other tools in /usr.
 
Newbie here, might be a stupid question but..

What caused / partition to be mounted read only in this case? I resolved similar issue by doing what SirDice said but I still don't know what's really going on.

FYI, my issue was that I needed to comment out some lines in loader.conf that causes kernel panic on boot, so I entered single user mode, then I could only edit loader.conf by following SirDice's suggestion.
 
Newbie here, might be a stupid question but..

What caused / partition to be mounted read only in this case? I resolved similar issue by doing what SirDice said but I still don't know what's really going on.

FYI, my issue was that I needed to comment out some lines in loader.conf that causes kernel panic on boot, so I entered single user mode, then I could only edit loader.conf by following SirDice's suggestion.
When the OS detect problems during the boot sequence (i.e. a mispelled rc.conf entry) or when you boot in single-user mode, your partitions are always in read-only mode. This prevents possible damages to your data.
 
Seven Hong, it's a standard Unix feature that booting into single user mode starts with just the root filesystem mounted, and the filesystem will be mounted read only. That behaviour is needed to allow some maintenance tasks on the root filesystem which would not be possible if it defaulted to read+write.

It should never normally be mounted read only on a system which has fully booted to multi user mode.
 
soamz , if you leave off the -t ufs, does it work? Seems to me that I've run into something on a ZFS install, and just ran mount -a without the -t option and all was well. My memory could be off.

Heh, and just saw that this thread started in the mid double oughts, but the fix (generally speaking) should still work.
 
soamz , if you leave off the -t ufs, does it work? (Seems to me that I've run into something on a ZFS install, and just ran mount -a without the -t option and all was well. My memory could be off.

Heh, and just saw that this thread started in the mid double oughts, but the fix (generally speaking) should still work.
mount -a will mount all the filesystems described in /etc/fstab, with the exception of those already mounted or with late and noauto options. Specifing the filesystem type too, only those of that type (always of the ones defined in /etc/fstab) will be mounted.
 
Thank you very much. That worked great. Just out of curosity though, what did that do?

well before doing the mount -a i did the fix errors on drive then
when i looked at rc.conf it had a mess of double "" after the commands
so after i cleaned it up it ran fine.

UPDATE: Ignore below LMA Error please

The LMA Error went away soon as i unplugged some usb drives before boot

But now i run into a new problem when booting up i got boot loader error and it may have to do with just installing mate i am not sure if it went into the .xinitrc i have to check but it is a LUA error
 
For those who have zfs, don't worry, just had the same problem. The command is the same except for the argument value for -t:

Code:
# mount -u /
# mount -a -t zfs

I must say, this is quite bizarre - such a small error in a config file should not prompt people to remount filesystems. I wonder why it happens and what is the reasoning behind loading the filesystem in read-only mode due to a mistake in a config file that actually caused it.
 
I must say, this is quite bizarre - such a small error in a config file should not prompt people to remount filesystems. I wonder why it happens and what is the reasoning behind loading the filesystem in read-only mode due to a mistake in a config file that actually caused it.
When the system boots it starts off in single user mode. Only the root filesystem is mounted, and is read-only. If there are any issues with any of the boot configuration files the system cannot do anything else but stop, and you're then stuck in that single user mode. With a read-only filesystem. Not bizarre, it's all very much explainable if you know how UNIX, and in particular FreeBSD, boots.
 
Nothing, except it doesn't run zfs share -a (/etc/rc.d/zfs does). Which you may not want to do in single user mode.
 
Back
Top