Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
arch-chroot and error with umount -l /mnt/gentoo/dev
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
st834
Tux's lil' helper
Tux's lil' helper


Joined: 23 Jun 2022
Posts: 95

PostPosted: Wed Jul 24, 2024 10:12 am    Post subject: arch-chroot and error with umount -l /mnt/gentoo/dev Reply with quote

Hello, this is not a description of the problem, but just a question for a short answer to which I would be grateful.

Why, when, during installation, I enter a new system using an arch-chroot script (https://wiki.gentoo.org/wiki/Handbook:AMD64/Installation/Base), then when I exit it and execute the command (https://wiki.gentoo.org/wiki/Handbook:AMD64/Installation/Bootloader):
Code:
umount -l /mnt/gentoo/dev{/shm, /pts,}

I get errors below?
Code:

umount: /mnt/gentoo/dev/shm: no mount point specified.
umount: /mnt/gentoo/dev/pts: no mount point specified.
umount: /mnt/gentoo/dev: no mount point specified.

When I mount the /proc, /sys, /dev, /run file systems manually:
Code:
root #mount --types proc /proc /mnt/gentoo/proc
root #mount --rbind /sys /mnt/gentoo/sys
root #mount --make-rslave /mnt/gentoo/sys
root #mount --rbind /dev /mnt/gentoo/dev
root #mount --make-rslave /mnt/gentoo/dev
root #mount --bind /run /mnt/gentoo/run
root #mount --make-slave /mnt/gentoo/run

this command runs without problems.

I research the arch-chroot script and could not see (I'm not saying that they did not exists) the fundamental differences in it from manual mounting.

Thank you very much for your answers.
Back to top
View user's profile Send private message
ali3nx
l33t
l33t


Joined: 21 Sep 2003
Posts: 731
Location: Winnipeg, Canada

PostPosted: Wed Jul 24, 2024 10:18 am    Post subject: Reply with quote

Often umount -l may hang or perhaps single directory unmount may not succeed. that behaviour is just consequential functional quirk that is what it is.

If you try using

Code:
umount -R /mnt/gentoo


to unmount the chroot mount directories that often succeeds if you've exited chroot and changed directory to any other directory than /mnt/gentoo

One other reason the chroot mount may not unmount is if a gpg-agent process used by portage was running in the chroot.
_________________
Compiling Gentoo since version 1.4
Thousands of Gentoo Installs Completed
Emerged on every continent but Antarctica
Compile long and Prosper!
Back to top
View user's profile Send private message
st834
Tux's lil' helper
Tux's lil' helper


Joined: 23 Jun 2022
Posts: 95

PostPosted: Wed Jul 24, 2024 10:46 am    Post subject: Reply with quote

Thank you very much for your answer.

umount -l works stably even for one directory when /proc, /sys, /dev, /run mounted manually and does not work stably when they are mounted via arch-chroot script. The command unmounts two/dev/shm/and dev/pts file systems.

Are there differences in mounting methods (arch-chroot and manual) that lead to different umount -l behavior?
Back to top
View user's profile Send private message
ali3nx
l33t
l33t


Joined: 21 Sep 2003
Posts: 731
Location: Winnipeg, Canada

PostPosted: Wed Jul 24, 2024 11:17 am    Post subject: Reply with quote

whether you've used arch-chroot or an arch livecd last I used one I've had similar experiences with chroot subdirectories not single directory unmounting while booted from many livecd iso's not limited to arch or having used arch-chroot.


livecd's are fantastic but have functional behaviour quirks that a complete linux distro system install doesn't usually exhibit as commonly. Livecd's are considered temporary in some ways. I usually do gentoo bulds using a fully functional linux distro install as a preference when i'm able to avoid using a livecd for long duration's

umount --lazy is essentially a more polite attempt to unmount a directory. for example if you kill a specific process


Code:
kill <pid>

that's more polite than

Code:
kill -9 <pid>


however there can be necessary use cases to use the more suggestive or forceful command option.

Or a less specific recursive unmount command.

There's also a command

Code:
fuser -m /path


that will reveal process id's used by a directory you can review and consider using kill -9 to stop that process such as but may not be limited to gpg-agent. should a process be using /mnt/gentoo an unmount command will not succeed.
_________________
Compiling Gentoo since version 1.4
Thousands of Gentoo Installs Completed
Emerged on every continent but Antarctica
Compile long and Prosper!


Last edited by ali3nx on Wed Jul 24, 2024 12:22 pm; edited 1 time in total
Back to top
View user's profile Send private message
st834
Tux's lil' helper
Tux's lil' helper


Joined: 23 Jun 2022
Posts: 95

PostPosted: Wed Jul 24, 2024 11:45 am    Post subject: Reply with quote

Thank you for your answer.

I don't use arch livecd, Gentoo Handbook says
Quote:
Tip
If using Gentoo's install media, this step can be replaced with simply: arch-chroot /mnt/gentoo.


I checked as you said (fuser -m /path) and did not get the processes that would occupy this directory. As error i receive, that "no mount point specified", i think, that the arch-chroot script mounts these file systems differently from "mount --rbind /sys /mnt/gentoo/sys" for example.
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 22619

PostPosted: Wed Jul 24, 2024 1:43 pm    Post subject: Reply with quote

How exactly does arch-chroot create its mounts? If it is using a private mount namespace, they would all vanish when you exit.
Back to top
View user's profile Send private message
st834
Tux's lil' helper
Tux's lil' helper


Joined: 23 Jun 2022
Posts: 95

PostPosted: Thu Jul 25, 2024 9:12 am    Post subject: Reply with quote

hello, I found the script here: https://gist.github.com/bhelm/65283c37a0cb585089041214002df4f7 , the same is on livecd Gentoo.

as I understand it, using proc and dev as an example, they are mounted like this:

Code:
chroot_add_mount() {
  mount "$@" && CHROOT_ACTIVE_MOUNTS=("$2" "${CHROOT_ACTIVE_MOUNTS[@]}")
}


Code:
chroot_setup() {
 ...

  chroot_add_mount proc "$1/proc" -t proc -o nosuid,noexec,nodev &&
  ...
  chroot_add_mount udev "$1/dev" -t devtmpfs -o mode=0755,nosuid &&
 ...
}


$1 - parameter with chroot directory, for example /mnt/gentoo.

The string that creates the mount namespace is present at the end of scripts:
Code:
SHELL=/bin/bash unshare --fork --pid chroot "${chroot_args[@]}" -- "$chrootdir" "$@"
Back to top
View user's profile Send private message
st834
Tux's lil' helper
Tux's lil' helper


Joined: 23 Jun 2022
Posts: 95

PostPosted: Thu Jul 25, 2024 11:18 am    Post subject: Reply with quote

I think I figured it out, these file systems will be unmounted automatically when I exit chroot. this is done through the exit trap:

Code:
chroot_setup() {
  CHROOT_ACTIVE_MOUNTS=()
  [[ $(trap -p EXIT) ]] && die '(BUG): attempting to overwrite existing EXIT trap'
  trap 'chroot_teardown' EXIT
  ...


Code:
chroot_teardown() {
  if (( ${#CHROOT_ACTIVE_MOUNTS[@]} )); then
    umount "${CHROOT_ACTIVE_MOUNTS[@]}"
  fi
  unset CHROOT_ACTIVE_MOUNTS
}


Thanks a lot for help!
Back to top
View user's profile Send private message
teika
Apprentice
Apprentice


Joined: 19 Feb 2011
Posts: 163
Location: YYYY-MM-DD, period. Have you ever used the Internet?

PostPosted: Mon Jul 29, 2024 10:54 pm    Post subject: Reply with quote

When not mounted, the error message is this:

 $ umount /tmp/foo/
 umount: /tmp/foo/: not mounted.

My guess is that it's because the namespace is separated by unshare:
Quote:
SHELL=/bin/bash unshare --fork --pid chroot "${chroot_args[@]}" -- "$chrootdir" "$@"

But sorry I don't know much about this.

This kind of stuff was too technical or esoteric in the past, but today is of more importance, because of the high demand of containers/dockers.

unshare (2) appeared in 2005, according to LWN.
_________________
Hack of easy Shift / Ctrl / AltGr etc; save your pinkies, type without drudgery: topic 865313

BTRFS - Biden & TRump, Fools Suck.
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 22619

PostPosted: Tue Jul 30, 2024 12:13 am    Post subject: Reply with quote

That use of unshare only unshares the pid namespace, but not the mount namespace, so you can ignore it for the purpose of determining when mounts are created and destroyed. Building complicated chroots, and automatically destroying them on exit, is a great use case for unsharing the mount namespace, so I find it a bit surprising that this script would use unshare (thereby depending on its presence), and not make use of a mount namespace.
Back to top
View user's profile Send private message
teika
Apprentice
Apprentice


Joined: 19 Feb 2011
Posts: 163
Location: YYYY-MM-DD, period. Have you ever used the Internet?

PostPosted: Wed Jul 31, 2024 5:38 am    Post subject: Reply with quote

Then maybe this part?
Code:
# From arch-chroot
pid_unshare="unshare --fork --pid"
mount_unshare="$pid_unshare --mount --map-auto --map-root-user --setuid 0 --setgid 0"

The upstream repo at github is here.
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 22619

PostPosted: Wed Jul 31, 2024 11:45 am    Post subject: Reply with quote

If they use that part, yes. I looked at the upstream repository earlier, but since the script is stored as a template to be modified at install time, I did not try to follow its logic.
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