chesty / overlayroot

mounts an overlay file system over root
GNU General Public License v2.0
166 stars 38 forks source link

/overlay/lower file not found. #3

Closed VigibotDev closed 6 years ago

VigibotDev commented 6 years ago

My system work perfectly in RO. but there is a strange bug inside the bashscript at 32 (chroot line)

${SUDO} IMCHROOTED=${ROOT} chroot ${ROOT}

(it's my own PS1)

(root|~/overlayroot) ./rootwork ./rootwork: ligne 32: IMCHROOTED=/overlay/lower: Aucun fichier ou dossier de ce type

I must remove the IMCHROOTED=${ROOT} before the chroot on line 32 to get the RW chroot.

chesty commented 6 years ago

what's your PS1? can you run rootwork with bash -x rootwork and show my the output for the chroot line? it should look something like sudo IMCHROOTED=/overlay/lower chroot /overlay/lower

VigibotDev commented 6 years ago

I don't applied your PS1 for now. I use global /etc/bash.bashrc

# set a fancy prompt (non-color, overwrite the one in /etc/profile)
#PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
PS1='\[\e[33;1m\](\[\e[31;1m\]\u\[\e[33;1m\]|\[\e[32;1m\]\w\[\e[33;1m\])\[\e[0m\] '

-x debug out :

(root|~/overlayroot) bash -x rootwork
+ SUDO=
+ '[' 0 -gt 0 ']'
+ '[' -z '' ']'
+ ROOT=/overlay/lower
+ mount -o remount,rw /overlay/lower
+ mount -o remount,rw /boot
+ '[' -d /overlay/lower/proc ']'
+ mount -t proc proc /overlay/lower/proc
+ '[' -d /overlay/lower/sys ']'
+ mount -t sysfs sys /overlay/lower/sys
+ for DIR in dev dev/pts boot run
+ '[' -d /overlay/lower/dev ']'
+ mount -o bind /dev /overlay/lower/dev
+ for DIR in dev dev/pts boot run
+ '[' -d /overlay/lower/dev/pts ']'
+ mount -o bind /dev/pts /overlay/lower/dev/pts
+ for DIR in dev dev/pts boot run
+ '[' -d /overlay/lower/boot ']'
+ mount -o bind /boot /overlay/lower/boot
+ for DIR in dev dev/pts boot run
+ '[' -d /overlay/lower/run ']'
+ mount -o bind /run /overlay/lower/run
+ export IMCHROOTED=/overlay/lower
+ IMCHROOTED=/overlay/lower
+ IMCHROOTED=/overlay/lower chroot /overlay/lower
rootwork: ligne 32: IMCHROOTED=/overlay/lower: Aucun fichier ou dossier de ce type
+ umount /overlay/lower/proc
+ umount /overlay/lower/sys
+ for DIR in dev/pts dev boot run
+ umount /overlay/lower/dev/pts
+ for DIR in dev/pts dev boot run
+ umount /overlay/lower/dev
+ for DIR in dev/pts dev boot run
+ umount /overlay/lower/boot
+ for DIR in dev/pts dev boot run
+ umount /overlay/lower/run
+ mount -o remount,ro /boot
+ mount -o remount,ro /overlay/lower
VigibotDev commented 6 years ago

Why you export the variable AND you set before the launch ? This is a duplicate think.

VigibotDev commented 6 years ago

Oops I clicked on the wrong button

chesty commented 6 years ago

the variable doesn't need to be exported, it doesn't do any harm exporting it, i don't know.

It seems to be trying to execute "IMCHROOTED=/overlay/lower" rather than set IMCHROOTED to /overlay/root

the only change you made was to PS1 in /etc/bash.bashrc ? did you modify /root/.bashrc too? if so can you show me?

I should quote the variables, too, if you want to try quoting them and see if anything changes? like ${ROOT} becomes "${ROOT}"

VigibotDev commented 6 years ago

I'm french please excuse my mistakes in english.

Yes I only modded the PS1 inside /etc/bash.bashrc.

I'm a fan of "if I do not know, I do not add it" to keep all minimalist. Just add what is needed to work it's always better. otherwise it generates a lot of entropy because everyone does not understand what the other did.

I have 5 Raspberry PI 3B+ and 1 Zero W with minimalist NETINSTALL Raspbian image + my C/NodeJS software + your overlayroot script successfully installed.

-> All need the "IMCHROOTED=${ROOT}" removed to work.

(All embedded systems where I use your script appear here https://www.serveurperso.com/?page=robots zero ads)

VigibotDev commented 6 years ago

I just added your scripts to my ODROID XU4 with clean Armbian minimal image. There is already an initramfs inside it:) My XU4 is now protected with overlayfs ! Thanks A LOOOT for your work. It work everywhere.

For rootwork bug here is the stdout on Armbian XU4 :

root|~/overlayroot) ./rootwork
mount: /boot not mounted or bad option

       In some cases useful info is found in syslog - try
       dmesg | tail or so.
./rootwork: ligne 32: IMCHROOTED=/overlay/lower: Aucun fichier ou dossier de ce type
mount: /boot not mounted or bad option

       In some cases useful info is found in syslog - try
       dmesg | tail or so.

And now with -x flag :

(root|~/overlayroot) bash -x rootwork
+ SUDO=
+ '[' 0 -gt 0 ']'
+ '[' -z '' ']'
+ ROOT=/overlay/lower
+ mount -o remount,rw /overlay/lower
+ mount -o remount,rw /boot
mount: /boot not mounted or bad option

       In some cases useful info is found in syslog - try
       dmesg | tail or so.
+ '[' -d /overlay/lower/proc ']'
+ mount -t proc proc /overlay/lower/proc
+ '[' -d /overlay/lower/sys ']'
+ mount -t sysfs sys /overlay/lower/sys
+ for DIR in dev dev/pts boot run
+ '[' -d /overlay/lower/dev ']'
+ mount -o bind /dev /overlay/lower/dev
+ for DIR in dev dev/pts boot run
+ '[' -d /overlay/lower/dev/pts ']'
+ mount -o bind /dev/pts /overlay/lower/dev/pts
+ for DIR in dev dev/pts boot run
+ '[' -d /overlay/lower/boot ']'
+ mount -o bind /boot /overlay/lower/boot
+ for DIR in dev dev/pts boot run
+ '[' -d /overlay/lower/run ']'
+ mount -o bind /run /overlay/lower/run
+ export IMCHROOTED=/overlay/lower
+ IMCHROOTED=/overlay/lower
+ IMCHROOTED=/overlay/lower chroot /overlay/lower
rootwork: ligne 32: IMCHROOTED=/overlay/lower: Aucun fichier ou dossier de ce type
+ umount /overlay/lower/proc
+ umount /overlay/lower/sys
+ for DIR in dev/pts dev boot run
+ umount /overlay/lower/dev/pts
+ for DIR in dev/pts dev boot run
+ umount /overlay/lower/dev
+ for DIR in dev/pts dev boot run
+ umount /overlay/lower/boot
+ for DIR in dev/pts dev boot run
+ umount /overlay/lower/run
+ mount -o remount,ro /boot
mount: /boot not mounted or bad option

       In some cases useful info is found in syslog - try
       dmesg | tail or so.
+ mount -o remount,ro /overlay/lower
(root|~/overlayroot)  
chesty commented 6 years ago

I'll test it in the next few days with your PS1.

your english is better than my french ;)

That's a cool robot, is it for business or university or hobby?

check out the test branch I just pushed, see if that helps

chesty commented 6 years ago

i just made some changes and amended the commit so you might have to do a force pull or whatever if you have already pulled it.

VigibotDev commented 6 years ago

I checkouted to origin/test and this solve the problem, your refactored script look better !

Now I need help to get a perfect work on the ODROID XU4 (another issue)

VigibotDev commented 6 years ago

OK, I do this on the readonly system, now I reboot and git pull to get last modification and re-test

VigibotDev commented 6 years ago

Re-test OK, work perfectly. All my procedure :


(root|~/overlayroot) ./rootwork
./rootwork: ligne 32: IMCHROOTED=/overlay/lower: Aucun fichier ou dossier de ce type
(root|~/overlayroot) git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
(root|~/overlayroot) git pull
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 1), reused 3 (delta 1), pack-reused 0
Dépaquetage des objets: 100% (3/3), fait.
Depuis https://github.com/chesty/overlayroot
 * [nouvelle branche] test       -> origin/test
Déjà à jour.
(root|~/overlayroot) git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
  remotes/origin/test
(root|~/overlayroot) git checkout origin/test
Note : extraction de 'origin/test'.

Vous êtes dans l'état « HEAD détachée ». Vous pouvez visiter, faire des modifications
expérimentales et les valider. Il vous suffit de faire une autre extraction pour
abandonner les commits que vous faites dans cet état sans impacter les autres branches

Si vous voulez créer une nouvelle branche pour conserver les commits que vous créez,
il vous suffit d'utiliser « checkout -b » (maintenant ou plus tard) comme ceci :

  git checkout -b <nom-de-la-nouvelle-branche>

HEAD est maintenant sur 68559c1... refactor rootwork script
(root|~/overlayroot) ./rootwork
(root|/) exit
exit
mount: /overlay/lower is busy
(root|~/overlayroot) reboot 
chesty commented 6 years ago

sweet. I'll look at your other issue tomorrow.

VigibotDev commented 6 years ago

can you merge test on master ?

chesty commented 6 years ago

already done