0

I need to keep one system as much intact as possible. Only soldering of HW stuff is allowed :-). I need to install a test software package and this package must not stay there in the future.

I have a following situation:

  1. mmcblck partition mounted as /, ext4, read only, kernel v4.6.0
  2. usb stick (only one partition), mounted to /tmp/usbstick, ext4
  3. Created directories on usbstick /tmp/usbstick/upperdir, /tmp/usbstick/workdir
  4. Using the following line: mount -t overlay overlay -o lowerdir=/,upperdir=/tmp/usbstick/upperdir,workdir=/tmp/usbstick/workdir /

After that the / is still read only. The only partial success I had was when I created /tmp/usbstick/merged and gave it as a "merged" directory, instead of / to the module. Then I saw all my rootfs in that directory and it was rw mounted, but I can't use it there. What should I do?

2

I tried to chroot to the merged directory. The result was just as expected: I had rw rootfs, the only thing I missed was virtual kernel filesystems. So after mounting the overlay I did the following:

TARGETDIR="/tmp/usbstick/merged"
mount -t proc proc $TARGETDIR/proc
mount -t sysfs sysfs $TARGETDIR/sys
mount -t devtmpfs devtmpfs $TARGETDIR/dev
mount -t tmpfs tmpfs $TARGETDIR/dev/shm
mount -t devpts devpts $TARGETDIR/dev/pts

And then linked the mtab:

chroot $TARGETDIR rm /etc/mtab 2> /dev/null 
chroot $TARGETDIR ln -s /proc/mounts /etc/mtab
chroot $TARGETDIR
  • Excellent. Thank you for providing a solution. Please remember to accept your own answer (when you can) so people realise this worked for you. – roaima Nov 3 '17 at 13:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.