LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux From Scratch
User Name
Password
Linux From Scratch This Forum is for the discussion of LFS.
LFS is a project that provides you with the steps necessary to build your own custom Linux system.

Notices


Reply
  Search this Thread
Old 07-07-2022, 03:33 AM   #1
phaddad
LQ Newbie
 
Registered: Jul 2022
Posts: 2

Rep: Reputation: 0
Ensure read-only boot of BLFS root filesystem


I have specific embedded hardware that I am building LFS and BLFS with minimal requirements such as X graphics stack in order to run dedicated OpenGL accelerated software. I build this custom system as an image file and then dd this image onto CFast media cards to boot up on the hardware which is all fine.

However I do have a requirement that the root filesystem must be read only and can not have any bytes altered. On older software where I used a debootstrap system (Ubuntu 14.04) and a lot of insane extra effort to make it read only with initramfs this was possible. However I'm not sure if I need to use initramfs to achieve the same thing with LFS/BLFS. I'm wondering if I can achieve this read only bootable rootfs system (on ext2) without initramfs and if there are any pointers to how I can do it? Is it just as simple as making sure in /etc/fstab I have the options for "/" to be "ro"? Will this ensure that the mount counter and any other meta data doesn't get altered?

Thanks for any help or tips in advance!

Cheers
 
Old 07-08-2022, 08:31 AM   #2
derguteweka
Member
 
Registered: Sep 2018
Distribution: BLFS
Posts: 74

Rep: Reputation: 21
Moin,

Should be possible, as e.g. squashfs may be used as rootfs.
But usually B/LFS will want to write to certain locations during boot or later, like e.g. /tmp; /run; ... So it might be necessary to mount there some tmpfs or work with e.g. overlayfs to stack some rw-filesystem over the ro-filesystem.

cheers,
WK
 
Old 07-11-2022, 06:39 AM   #3
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Void, Linux From Scratch, Slackware64
Posts: 3,154

Rep: Reputation: 857Reputation: 857Reputation: 857Reputation: 857Reputation: 857Reputation: 857Reputation: 857
As above, also in /etc/rc.d/init.d/mountfs look for and comment out/remove
Code:
mount --options remount,rw / >/dev/null
Presuming you are using sysv, there will probably be something similar for systemd.
 
Old 07-19-2022, 06:17 AM   #4
phaddad
LQ Newbie
 
Registered: Jul 2022
Posts: 2

Original Poster
Rep: Reputation: 0
My fstab is pretty standard. I still have a tmpfs and such, its just the main root filesystem "/" that needs to remain read only and not have any partition metadata updated at all, from what I've understood from both documentation and looking at the code myself if I mount the root filesystem "/" as read-only (this is an ext2 fs) then technically mount counters or any other meta data should not be touched by the system or kernel. I can still create files and write to tmpfs as it is a true tmpfs system (RAM) and specifics like Xorg that write lock files generally use tmpfs also. The only thing I'm not 100% sure about is the /run mount and why on a proper pre-built distribution like Ubuntu you also need to modify the initramfs to make sure that the root filesystem partition will not be updated. I would rather not use squashfs if I dont have to.

Thanks Keith for the heads up on the remount

Last edited by phaddad; 07-19-2022 at 06:18 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] BLFS 10.0 How do I get total ownership of my blfs system ? Captian Kangeroo Linux From Scratch 4 12-09-2020 08:45 PM
how to change the filesystem from read only to read write while logged via kali live persistance boot usb drive? ertanuj Linux - Newbie 1 03-24-2017 07:25 AM
*How* read-only is a read-only filesystem? hippiejake Linux - General 3 02-14-2010 03:24 PM
How can I have: Root has Read-Write, user has read only for the boot filesystem? xmrkite Linux - Software 6 10-16-2008 04:31 AM
Read-only root filesystem at the boot karimson Linux - General 0 03-20-2003 05:01 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux From Scratch

All times are GMT -5. The time now is 11:32 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration