Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Setting up a readonly filesystem
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
michaels70
n00b
n00b


Joined: 30 Jul 2013
Posts: 5

PostPosted: Tue Jul 30, 2013 6:51 pm    Post subject: Setting up a readonly filesystem Reply with quote

I'm trying to setup a readonly filesystem on Gentoo running from an SSD drive to make a system impervious of power loss. Boot-up time is important so I don't want to use a compressed ramdisk and would rather use a union filesystem such as aufs or overlayfs but am having trouble finding information on how to setup scripts to do this with Gentoo. Can anyone help?

Thanks,
Michael
Back to top
View user's profile Send private message
ToeiRei
Veteran
Veteran


Joined: 03 Jan 2005
Posts: 1173
Location: Austria

PostPosted: Wed Jul 31, 2013 8:46 am    Post subject: Reply with quote

I did something for an SD Card on my raspberry pi:

Code:
 #!/bin/sh
 DIR=$1
 ROOT_MOUNT=$(awk '$2=="/" {print substr($4,1,2)}' < /etc/fstab)
 if [ $ROOT_MOUNT = "rw" ]
 then
   /bin/mount --bind ${DIR}_org ${DIR}
 else
   /bin/mount -t tmpfs ramdisk ${DIR}_rw
   /usr/bin/unionfs-fuse -o cow,allow_other,suid,dev,nonempty ${DIR}_rw=RW:${DIR}_org=RO ${DIR}
 fi


Don't forget chmod +x /usr/local/bin/mount_unionfs

Matching fstab entries:
Code:
 mount_unionfs   /etc   fuse    defaults    0  0
 mount_unionfs   /var   fuse    defaults    0  0



Result:
Code:
# df -h

 Dateisystem    Größe Benutzt Verf. Verw% Eingehängt auf
 rootfs          3,6G    1,9G  1,6G   56% /
 /dev/root       3,6G    1,9G  1,6G   56% /
 devtmpfs        212M       0  212M    0% /dev
 tmpfs            44M    556K   44M    2% /run
 tmpfs           5,0M       0  5,0M    0% /run/lock
 tmpfs            88M       0   88M    0% /run/shm
 /dev/mmcblk0p1   56M     19M   38M   34% /boot
 ramdisk         220M       0  220M    0% /etc_rw
 unionfs-fuse    3,8G    3,6G  220M   95% /etc
 ramdisk         220M    232K  219M    1% /var_rw
 unionfs-fuse    3,8G    3,6G  219M   95% /var
 none            220M    4,0K  220M    1% /tmp


/ is ro
/etc is unionfs (etc_rw / etc_org)
/var is unionfs (var_rw / var_org)
and so on

Downside: updates are bloody work due to that.
_________________
Please stand by - The mailer daemon is busy burning your messages in hell...
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo 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