# How to make FreeBSD 8.0 filesystem read-only?



## Magnesik (May 8, 2010)

Do any of you know any tutorial about making FreeBSD 8.0 filesystem readonly with /var and /temp in ramdisk?


----------



## aragon (May 8, 2010)

NanoBSD


----------



## Magnesik (May 10, 2010)

NanoBSD is perfect but is it possible to save it into hard disk not only into compact flash? If yes can you tell me how do it?


----------



## sasha (May 10, 2010)

AFAIK, there is no principal differences between CF cards and hard disks, only in their device names (ad* for HDD and da* for USB-CF; if CF card is connected via CF-IDE adapter, then it will be like usual hard disk). But note: CF card connected via CF-IDE adapter usually can't use DMA, so it is disabled in loader.conf. If you transfer NanoBSD from CF to hard disk, DMA should be enabled (or system will be very slow).


----------



## ChrisStone (May 12, 2010)

I just symlink /tmp to /var/tmp, then edit /etc/fstab to something like:

```
/dev/da0s1a     /     ufs     ro     0     0
md              /var  mfs     -s=64m,rw  0 0
```

The system doesn't freak out when var is empty, though there's ways to have the boot process auto populate the memory disk. Obviously add other entries similar to the first line if you separated /usr or other mountpoints (which wouldn't make any sense anyway, as it's all read-only in the first place). You can also duplicate the second line for /tmp if you really want to, though the symlink works fine too.

If you're doing testing on the system you can change the root filesystem between read-only and read-write by *mount -o ro /* or *mount -o rw /* (respectively).


----------



## Beastie (May 12, 2010)

ChrisStone said:
			
		

> there's ways to have the boot process auto populate the memory disk


Such as /etc/rc.d/var.

And check the /etc/defaults/rc.conf "var" entries: *varmfs*, *varsize*, *varmfs_flags*, *populate_var*, and *cleanvar_enable*.


----------



## Magnesik (May 12, 2010)

Do you think that changes (I mean / mounted in read-only and /var in ram ) will let me spin disk down in my FreeBSD router?


----------

