sync
This commit is contained in:
parent
48f640b55d
commit
440a2fa01f
28 changed files with 1849 additions and 96 deletions
57
10-linux/90-stories/сценарий монтирования и chroot.md
Normal file
57
10-linux/90-stories/сценарий монтирования и chroot.md
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
Почти: после загрузки livecd сначала нужно **смонтировать разделы твоей установленной системы**, а уже потом — `proc/sys/dev/run` и `chroot`. Иначе ты будешь “чрутьнуться в пустоту” или в старое состояние.[1]
|
||||
|
||||
## Правильный порядок
|
||||
1) Смонтировать root и ESP:
|
||||
```sh
|
||||
mount /dev/vda2 /mnt/gentoo
|
||||
mkdir -p /mnt/gentoo/boot/efi
|
||||
mount /dev/vda1 /mnt/gentoo/boot/efi
|
||||
```
|
||||
|
||||
2) Потом уже то, что ты написал (proc/sys/dev/run) и chroot:
|
||||
```sh
|
||||
mount -t proc /proc /mnt/gentoo/proc
|
||||
mount --rbind /sys /mnt/gentoo/sys
|
||||
mount --make-rslave /mnt/gentoo/sys
|
||||
mount --rbind /dev /mnt/gentoo/dev
|
||||
mount --make-rslave /mnt/gentoo/dev
|
||||
mount --bind /run /mnt/gentoo/run
|
||||
mount --make-slave /mnt/gentoo/run
|
||||
|
||||
chroot /mnt/gentoo /bin/bash
|
||||
source /etc/profile
|
||||
export PS1="(chroot) ${PS1}"
|
||||
```
|
||||
|
||||
# размонтировать
|
||||
|
||||
```bash
|
||||
exit
|
||||
umount -l /mnt/gentoo/dev{/shm,/pts,}
|
||||
cd /
|
||||
umount -R /mnt/gentoo
|
||||
reboot
|
||||
```
|
||||
|
||||
`--rbind` + `--make-rslave` как раз нужны, чтобы внутри chroot корректно “виделись” устройства и динамические mount’ы, но изменения не утекали обратно в хостовую систему.[2][3]
|
||||
|
||||
[1](https://www.simplified.guide/gentoo/build-chroot-environment)
|
||||
[2](https://emirror.d0a.io/wiki/wiki.gentoo.org/wiki/Handbook_Alpha/Installation/Base.html)
|
||||
[3](https://www.reddit.com/r/linuxquestions/comments/czgk8u/what_is_the_purpose_of_bind_mounting_rbind/)
|
||||
[4](https://www.reddit.com/r/Gentoo/comments/14ou6z8/trying_to_chroot_into_install_but_nothing_exists/)
|
||||
[5](https://wiki.archlinux.org/title/Chroot)
|
||||
[6](https://groups.google.com/g/linux.gentoo.user/c/hADFN2EHjmY)
|
||||
[7](https://www.funtoo.org/Talk:Install/Chroot)
|
||||
[8](https://gist.github.com/zunkree/c28ccef99df972e4af75a97616bab2ff)
|
||||
[9](https://www.reddit.com/r/Gentoo/comments/wge8w5/cant_chroot_into_gentoo/)
|
||||
[10](https://gist.github.com/gekola/7bd15bfd80f94a257a76093f218cbb43)
|
||||
[11](https://emirror.d0a.io/wiki/wiki.gentoo.org/wiki/Handbook_AMD64/Installation/Base/ja.html)
|
||||
[12](https://www.linux.org.ru/forum/general/13908919)
|
||||
[13](https://www.youtube.com/watch?v=oXJrevOr7Pc)
|
||||
[14](https://grandekos.com/index.php?static_page=Memorize%2FLinux+things%2Fchroot+some+directory)
|
||||
[15](https://www.linux.org.ru/forum/general/13611252)
|
||||
[16](https://www.reddit.com/r/Gentoo/comments/w2qlel/what_would_happen_if_i_dont_use_mount_makerslave/)
|
||||
[17](https://www.reddit.com/r/Gentoo/comments/xgr9b6/error_during_installation/)
|
||||
[18](https://www.reddit.com/r/Gentoo/comments/143wq54/regaining_access_to_install_via_chroot/)
|
||||
[19](https://seekstar.github.io/2022/04/27/%E5%9C%A8chroot%E7%8E%AF%E5%A2%83%E4%B8%AD%E6%8C%82%E8%BD%BDdev-proc-sys/)
|
||||
[20](https://github.com/sorah/gentoo-build/blob/master/scripts/prepare-chroot.sh)
|
||||
Loading…
Add table
Add a link
Reference in a new issue