On Wed, Jul 17, 2024, 19:09 Vitaly Zdanevich <zdanevich.vit...@ya.ru> wrote:

> My script in the chroot folder:
>
> ```
> mount --rbind /dev dev
> mount --make-rslave dev
> mount -t proc /proc proc
> mount --rbind /sys sys
> mount --make-rslave sys
> mount --rbind /tmp tmp
> mount --bind /run run
>
> mount -o bind /var/db/repos/ var/db/repos/
>
> chroot . /bin/bash
>
> ```
>

The last line chroots into the current working directory, not the directory
where the script is located. Thus, it doesn't matter where your script is
located.

I would suggest adding the following line to the start of your script:

```
cd "$1"
```

Then you can pass the path to your mounted filesystem as a parameter:

```sh
# /mnt/gentoo/chroot.sh /mnt/gentoo/
```

You could also use `dirname "$0"` in your script to get the directory where
your script is located.

>

Reply via email to