Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Technical question about mount/remount ro/rw
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Unsupported Software
View previous topic :: View next topic  
Author Message
Fulgurance
Veteran
Veteran


Joined: 15 Feb 2017
Posts: 1258

PostPosted: Thu Mar 06, 2025 10:33 am    Post subject: Technical question about mount/remount ro/rw Reply with quote

Hi guys, as some know, I am working on my package manager.

I decided to add a lock system that when it install a package, it unlock the /bin /sbin /lib and /libexec directories as rw, but when the installation is finished, it's remounted as ro.

So it work, but I am facing a big problem. When I do this test (so under virtual machine), it look like after a while, I mean after changing from RO to RW few times, I am facing big performance issues. The system become extremly slow (under the VM)
Is it normal ?
Is there any way to improve this ?

Basically when I unlock/lock, I run these commands:

Code:

sudo mount --rbind -o remount,rw /bin /bin
sudo mount --rbind -o ro /bin /bin

_________________
My actual project: https://github.com/Fulgurance/ISM

Ingenius Software Manager is a tool to build and manage a Linux system from scratch.
It will able to manage a linux installation just with a given path to the futur root path
Back to top
View user's profile Send private message
pingtoo
Veteran
Veteran


Joined: 10 Sep 2021
Posts: 1520
Location: Richmond Hill, Canada

PostPosted: Thu Mar 06, 2025 12:12 pm    Post subject: Reply with quote

Not able to tell in you code logic if mount/umount pair were performed or not.

So may be just check use 'mount' command to see if you have many many time mount same directories.
Back to top
View user's profile Send private message
Fulgurance
Veteran
Veteran


Joined: 15 Feb 2017
Posts: 1258

PostPosted: Thu Mar 06, 2025 6:09 pm    Post subject: Reply with quote

I find a better way to do so.

I realized this method wasn't really what I am looking for, because it is not the purpose of rbind option.

Thank you for your help anyway :)

I will use chattr
_________________
My actual project: https://github.com/Fulgurance/ISM

Ingenius Software Manager is a tool to build and manage a Linux system from scratch.
It will able to manage a linux installation just with a given path to the futur root path
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 23156

PostPosted: Thu Mar 06, 2025 6:50 pm    Post subject: Reply with quote

I think chattr is a worse way. It does not work on all filesystems, and is persistent, so an untimely system halt may leave the directory in the wrong state. Further, it is not recursive.

A read-only mount is a good approach for what you said you want, but you need to do it properly. I would also use a private mount namespace for the read-write mount, so that nothing else has access during the window that your package manager is working on it.
Back to top
View user's profile Send private message
szatox
Advocate
Advocate


Joined: 27 Aug 2013
Posts: 3542

PostPosted: Thu Mar 06, 2025 7:39 pm    Post subject: Reply with quote

Are you looking for union mount?
Overlayfs is in the main kernel, there's a good chance your system already has all the pieces and you can just use it. And since it keeps all changes in a separate directory, you can reset things with a simple rm -rf
_________________
Make Computing Fun Again
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Unsupported Software All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum