Jump to content

mounting rw partition along with overlayroot


gailu

Recommended Posts

Hi Experts,

 

I am trying to achieve following and facing some difficulties. Hope you can guide me.

 

Target: Freez rootfs with overlayroot but allow application to write data file on permanent basis in separate partition on sd card.

 

Steps Taken:

1. Partition SD card (8GB) with rootfs in primary partition (4GB) and extended/logical partition (4GB). 

2. Formatted logical partition (ext4)

3. Created Entry in fstab to mount logical partition automatically at boot.

4. Run overlay root as described in https://docs.armbian.com/User-Guide_Advanced-Features/#how-to-freeze-your-filesystem

 

Behaviour Observed:

Partition is mounted at boot and files can be created but changes on partition disappear on reboot due to overlayroot.

 

Qustion: Is there any way to mount partition for permanent read/write?

 

My etc in overlay-chroot looks as follows

UID=fd472eba-571d-4583-8873-97f09353655c / ext4 defaults,noatime,nodiratime,commit=600,errors=remount-ro 0 1
tmpfs /tmp tmpfs defaults,nosuid 0 0
/var/swap none swap sw 0 0
/dev/mmcblk0p5 /mnt/data ext4 defaults 0 2

But when system is booted /etc/fstab on NON overlay-chroot mode looks as below

UUID=fd472eba-571d-4583-8873-97f09353655c /media/root-ro/ ext4 ro,defaults,noatime,nodiratime,commit=600,errors=remount-ro 0 1
/media/root-ro/ / overlayfs lowerdir=/media/root-ro/,upperdir=/media/root-rw/overlay/ 0 1
tmpfs /tmp tmpfs defaults,nosuid 0 0 # overlayroot:fs-virtual
#overlayroot:swap=0#/var/swap none swap sw 0 0
/dev/mmcblk0p5 /media/root-ro/mnt/data ext4 ro,defaults 0 2
/media/root-ro/mnt/data /mnt/data overlayfs lowerdir=/media/root-ro/mnt/data,upperdir=/media/root-rw/overlay/mnt/data 0 2

 Since my partition as specified in /etc/fstab is mounted by overlayroot it is automatically changed to have changes on temp basis.

 

Question:

Is there a way to specify in /etc/fstab that a particular mount point should not be touched by overlayroot?

 

Thanks 

Link to comment
Share on other sites

The Debian packages bilibop(-*) are what you want. It works with kernels that have either aufs or overlayfs. You must be using initramfs-tools (as opposed to dracut). When your initrd is rebuilt it includes some of its scripts and files that do the magic. Use a normal /etc/fstab. In the bilibop configuration file you can whitelist other partitions that you want mounted normally.

 

You have to put in a kernel command line argument, I like 'lockfs=soft', but other options are available. With lockfs=soft the real rootfs is mounted read-only at either /overlay/ro or /aufs/ro. You can, as root, do something like below if you need to change something permanently:

root@skylight1:~$ mount -o remount,rw /overlay/ro
root@skylight1:~$ chroot /overlay/ro
root@skylight1:/$ .... do your work here
root@skylight1:/$ exit
root@skylight1:~$ mount -o remount,ro /overlay/ro

For simple file edits that's it. But some operations, say 'apt-get install somepackage', will require more work. You'll need to bind mount /dev, /proc and maybe others to /overlay/ro before entering the chroot (and umounting it all later).

 

One caution: if you use lockfs=hard (good for kiosk mode) you can paint yourself into a corner where you can't change the system at all. You'd have to mount your rootfs on another system (if you're working off an SD card) or NFS boot if you're working off of MMC.

 

 The included /usr/share/doc/bilibop* files are pretty good at explaining how it works.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines