Gentoo Archives: gentoo-user

From: "Canek Peláez Valdés" <caneko@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] What to put in chroot mtab
Date: Fri, 01 Aug 2014 21:32:05
Message-Id: CADPrc80M-NVrF4dJXPJ8ikO8rmFPParz8OJ9VN-8=D9XV5vnUw@mail.gmail.com
In Reply to: Re: [gentoo-user] What to put in chroot mtab by "J. Roeleveld"
1 On Aug 1, 2014 3:46 PM, "J. Roeleveld" <joost@××××××××.org> wrote:
2 >
3 > On 1 August 2014 15:28:01 CEST, Dale <rdalek1967@×××××.com> wrote:
4 > >Peter Humphrey wrote:
5 > >> On Friday 01 August 2014 14:07:08 I wrote:
6 > >>
7 > >>> I run a couple of chroots on this box to build packages for other
8 > >boxes on
9 > >>> the LAN. So far, I haven't worked out what I should populate
10 > >/etc/mtab with
11 > >>> in each chroot. Is it enough to "grep ext4 /etc/mtab >
12 > >>> /mnt/chroot/etc/mtab"? That catches all the physical partitions, but
13 > >I
14 > >>> imagine I need to add some /proc, /sys and /dev entries as well, but
15 > >is
16 > >>> there a simple formula for doing this?
17 > >> I meant to add that one chroot is 32-bit and the other is 64. The
18 > >host is an
19 > >> i5 running openrc.
20 > >>
21 > >
22 > >It has been a good while since I used this. So, make sure it makes
23 > >sense to you before trying this. This may not work if something has
24 > >changed in the past several years. Use with caution if at all.
25 > >
26 > >This is a little script, if you want to call it that, that I used to do
27 > >mine. It also lists the command to use to do a 32 bit chroot from a 64
28 > >bit rig. Here it is:
29 > >
30 > >root@fireball / # cat /root/xx.chroot-mount-32bit
31 > >
32 > >
33 > >mount -o bind /dev /mnt/gentoo32/dev
34 > >mount -o bind /dev/pts /mnt/gentoo32/dev/pts
35 > >mount -o bind /dev/shm /mnt/gentoo32/dev/shm
36 > >mount -o bind /proc /mnt/gentoo32/proc
37 > >mount -o bind /proc/bus/usb /mnt/gentoo32/proc/bus/usb
38 > >mount -o bind /sys /mnt/gentoo32/sys
39 > >mkdir -p /mnt/gentoo32/usr/portage/
40 > >mount -o bind /usr/portage /mnt/gentoo32/usr/portage/
41 > >
42 > >
43 > >echo " mounting finished"
44 > >
45 > >echo "run linux32 chroot /mnt/gentoo32 /bin/bash next"
46 > >root@fireball / #
47 > >
48 > >
49 > >You may have different mount points at the very least so edit to match
50 > >what you have. Again, things could have changed and that no longer
51 > >will
52 > >work. It may not be a bad idea to let someone who has done this more
53 > >recently to give a thumbs up to that.
54 > >
55 > >That last command should be:
56 > >
57 > >linux32 chroot /mnt/gentoo32 /bin/bash
58 > >
59 > >Dale
60 > >
61 > >:-) :-)
62 >
63 > That script is too long :)
64 >
65 > cd /mnt/gentoo
66 > mount -o rbind /dev dev
67 > mount -o rbind /sys sys
68 > mount -o rbind /proc proc
69 > cp -L /etc/resolv.conf etc/resolv.conf
70 > cd ..
71 > chroot gentoo /bin/bash
72 >
73 > To undo:
74 > cd /mnt/gentoo
75 > umount -l proc sys dev
76
77 That's still too long :)
78
79 With systemd-nspawn, you only do:
80
81 systemd-nspawn -D /mnt/gentoo
82
83 Systemd takes care of /dev, /sys, etc. If the container has systemd
84 installed, you can do
85
86 systemd-nspawn -bD /mnt/gentoo
87
88 and the services inside the container will be started like in a regular
89 boot (you'll need to set the root password for the container).
90
91 Also, if you want to share the /usr/portage directory between host and
92 container, you only need to
93
94 systemd-nspawn --bind=/usr/portage -bD /mnt/gentoo
95
96 Regards.
97 --
98 Canek

Replies

Subject Author
Re: [gentoo-user] What to put in chroot mtab "Canek Peláez Valdés" <caneko@×××××.com>