Hacker News new | past | comments | ask | show | jobs | submit login

Maybe this is a really dumb question but how does one use a read-only filesystem? Can you mount it as writable temporarily or something?

Or is it that you create a compressed 'file' that you can mount as a file system? Like a zip file kinda I guess?




You mount it as a read only file system to a mount point. It’s like putting in a CD (remember those?) into a drive.

The source data can be a raw block device or more likely a local file. It doesn’t matter as either way the kernel is just reading blocks of bytes.


> remember those?

Not really tbh. I haven't used a CD in my adult life. I remember "burning a CD" was a thing and that's about it.


How could you make us all feel so old. You monster.


I was born in the early 2000s and I've used CDs a lot.


As an adult? For what?

I was born in 1991 and I haven't used one since I was in 9th grade and made a girl a 'mix tape'.


we won't ask about 3.5 drives, funny thing is they have their special uses too.


Or 5 1/4” for that matter! I remember my cousin’s old PC used those. Very flimsy but seemed to work remarkably well!


IMHO they wasn't flimsy just a bit floppy


Another option is to use a read-only filesystem with overlayfs to provide a writeable filesystem (like JFFS2) that also has a solid static FS underneath in case of error. OpenWrt does, or at least did, this.


You got a few good “how” answers but as to “why”, it’s common for containers to use an overlay file system to handle writes. So in a container situation, you’ve already paid the overlay tax. Adding compression is a smaller incremental cost.


Just like a read-only file or service. There's some kind of a construction step, and thereafter it's read-only. One might do that to make it explicit that updates are expensive, to grant read-only privileges to a less trusted process, or whatever.

Somebody else can chime in with the exact mechanism by which this one is written, but common solutions include being writable sometimes or having a program to build the filesystem from known data. That might be filesystem-as-a-file, filesystem on a separate partition, or what have you.


Right I want to know what the construction step is in this case, but that makes sense that there's multiple approaches.


Just like creating any sort of archive. You (or a program of sorts) create the fs structure in some directory, then invoke something like `mkdwarfs -i /path/to/that/directory -o /path/to/output/file.dfs`


And squashfs works the same way - mksquashfs takes a directory as input and writes a file as output. That file can then be loopback-mounted to present the readonly filesystem.


Got it, yeah so that tracks then, thanks.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: