How to pass "-o readonly=on" to ZFS root pool at startup?

I made a FreeBSD Installation USB memory stick. It uses ZFS as root instead of UFS2. I used zfs set readonly=on to the filesystem mounted as root, but I think that isn't sufficient. I want to make sure it does not perform any unnecessary writes to USB, not even ZFS' history logs. How to do this? I can't find the solution anywhere.
 
Re: How to pass "-o readonly=on" to ZFS root pool at startup

jyhpsycho said:
I used zfs set readonly=on to filesystem mounted as root, but I think that isn't sufficient.
Why do you think it's not sufficient?
 
Re: How to pass "-o readonly=on" to ZFS root pool at startup

SirDice said:
jyhpsycho said:
I used zfs set readonly=on to filesystem mounted as root, but I think that isn't sufficient.
Why do you think it's not sufficient?

It prevents writes to individual filesystems, not to the whole pool. It seems that ZFS writes some pool metadata when mounting that to another system, thus zpool says
Code:
This pool seems to be used on another system
when I import that pool later (for maintenance) on a system which I used to make installation media. It requires the -f option to import.
 
Re: How to pass "-o readonly=on" to ZFS root pool at startup

ZFS wasn't really built for USB sticks that move around. You have to zpool export the pool each time before you unplug it. Then you won't get that message.
 
Re: How to pass "-o readonly=on" to ZFS root pool at startup

SirDice said:
You have to zpool export the pool each time before you unplug it. Then you won't get that message.

Is it really possible to export a zpool that contains a filesystem mounted as /? I used that USB to installation media like CD.

EDITED: And, it still writes some data means "it not cleanly unmounted before". I want to prevent that.
 
Re: How to pass "-o readonly=on" to ZFS root pool at startup

Tricky. It should be possible, the filesystem is mounted read-only. But you would be pulling the rug from under the running system. I don't think it's going to like that. Although ZFS is great it's not built for this.

Maybe you can add a zpool export somewhere in the shutdown routines. So when you shutdown, after it did all it's business, the last thing it does is the export. Perhaps that can be made to work.
 
Re: How to pass "-o readonly=on" to ZFS root pool at startup

Hmm, that does not suffice for me, either. ZFS still writes some pool metadata, and the USB stick goes wrong. It's not a good idea to use ZFS on a USB stick unless that supports a device-level read-only switch. Thanks for your attention :)
 
This is a three years old topic and it match my case now.

In a embedded development task we need to use a zfs pool on compressed md_image (so the compressed image is readonly) as rootfs.
But the kernel always try to mount the zfs in read-write and failed because the underlyer device(md_image) is readonly.

vfs.root.mountfrom.options=ro in loader.conf only change the log text.
 
Back
Top