# run fsck on root file system



## sniper007 (Mar 16, 2010)

If i run fsck on one filesystem and fsck need to repair some things then this partition must be unmounted

correct ?

So running fsck on root file system isn't possible within same OS ? correct ?


What is the best way to do that, live cd ?


BR,

Jurif


----------



## graudeejs (Mar 16, 2010)

boot into single user mode, root will be mounted read only, then run fsck , and you will be able to fix everything


----------



## sniper007 (Mar 16, 2010)

Is it possible to fix filesystem which is mounted read only ?


----------



## mky (Mar 16, 2010)

If you don't want reboot your system (for any reasons) you can also remount file system as read-only. For example:

```
mount -fr /
```
and run fsck. After finish you can remount file system as read-write:

```
mount -fw /
```
This method may be unsafe if you have only one partition for system (without separate /var /usr /tmp etc.). Some processes may crash if they can't write on the file system.

If you have physical access to your machine, the safe method will be boot to single mode, then run fsck.


----------



## graudeejs (Mar 16, 2010)

sniper007 said:
			
		

> Is it possible to fix filesystem which is mounted read only ?



that's the way root should be fsck'ed


----------



## SirDice (Mar 16, 2010)

You cannot "fix" a read-only mounted filesystem:


> If the operator does not have write permission on the file system fsck_ffs will default to a -n action.


See fsck_ffs(8)


----------



## graudeejs (Mar 16, 2010)

ah sorry, haven't been using UFS for long time....
`# mount -uo rw /`
solves this


Thanks SirDice for fixing me


----------



## sniper007 (Mar 16, 2010)

Is it possible to *fix* filesystem which *is mounted* anyway ?


----------



## SirDice (Mar 16, 2010)

sniper007 said:
			
		

> Is it possible to *fix* filesystem which *is mounted* anyway ?



If I'm not mistaken only the errors that are fixable in "preen" mode.


----------



## laufdi (Feb 22, 2017)

In single user mode `fsck` does nothing if root is mounted rw, but fixes errors if mounted ro, what's the logic behind that? (11.0-STABLE)


----------



## ShelLuser (Feb 23, 2017)

laufdi said:


> In single user mode `fsck` does nothing if root is mounted rw, but fixes errors if mounted ro, what's the logic behind that? (11.0-STABLE)


First, keep in mind that you're replying to a thread which is almost 7 years old. Sometimes it might be easier to start a new one.

Anyway, the answer is simple: although you may be in single user mode, you're not in a single instance mode. In other words: it's perfectly possible that there are other processes running which could perform disk operations while fsck is also running, which is obviously not an optimal situation. So to rule out any risk for unwanted updates your file system needs to be readonly.


----------



## laufdi (Feb 23, 2017)

That makes sense, but it would be nice if somewhere in a man page or in the fsck output was a hint to this.


----------

