1 |
On 1 August 2014 23:33:05 CEST, "Canek Peláez Valdés" <caneko@×××××.com> wrote: |
2 |
>On Fri, Aug 1, 2014 at 4:31 PM, Canek Peláez Valdés <caneko@×××××.com> |
3 |
>wrote: |
4 |
>> On Aug 1, 2014 3:46 PM, "J. Roeleveld" <joost@××××××××.org> wrote: |
5 |
>>> |
6 |
>>> On 1 August 2014 15:28:01 CEST, Dale <rdalek1967@×××××.com> wrote: |
7 |
>>> >Peter Humphrey wrote: |
8 |
>>> >> On Friday 01 August 2014 14:07:08 I wrote: |
9 |
>>> >> |
10 |
>>> >>> I run a couple of chroots on this box to build packages for |
11 |
>other |
12 |
>>> >boxes on |
13 |
>>> >>> the LAN. So far, I haven't worked out what I should populate |
14 |
>>> >/etc/mtab with |
15 |
>>> >>> in each chroot. Is it enough to "grep ext4 /etc/mtab > |
16 |
>>> >>> /mnt/chroot/etc/mtab"? That catches all the physical partitions, |
17 |
>but |
18 |
>>> >I |
19 |
>>> >>> imagine I need to add some /proc, /sys and /dev entries as well, |
20 |
>but |
21 |
>>> >is |
22 |
>>> >>> there a simple formula for doing this? |
23 |
>>> >> I meant to add that one chroot is 32-bit and the other is 64. The |
24 |
>>> >host is an |
25 |
>>> >> i5 running openrc. |
26 |
>>> >> |
27 |
>>> > |
28 |
>>> >It has been a good while since I used this. So, make sure it makes |
29 |
>>> >sense to you before trying this. This may not work if something |
30 |
>has |
31 |
>>> >changed in the past several years. Use with caution if at all. |
32 |
>>> > |
33 |
>>> >This is a little script, if you want to call it that, that I used |
34 |
>to do |
35 |
>>> >mine. It also lists the command to use to do a 32 bit chroot from |
36 |
>a 64 |
37 |
>>> >bit rig. Here it is: |
38 |
>>> > |
39 |
>>> >root@fireball / # cat /root/xx.chroot-mount-32bit |
40 |
>>> > |
41 |
>>> > |
42 |
>>> >mount -o bind /dev /mnt/gentoo32/dev |
43 |
>>> >mount -o bind /dev/pts /mnt/gentoo32/dev/pts |
44 |
>>> >mount -o bind /dev/shm /mnt/gentoo32/dev/shm |
45 |
>>> >mount -o bind /proc /mnt/gentoo32/proc |
46 |
>>> >mount -o bind /proc/bus/usb /mnt/gentoo32/proc/bus/usb |
47 |
>>> >mount -o bind /sys /mnt/gentoo32/sys |
48 |
>>> >mkdir -p /mnt/gentoo32/usr/portage/ |
49 |
>>> >mount -o bind /usr/portage /mnt/gentoo32/usr/portage/ |
50 |
>>> > |
51 |
>>> > |
52 |
>>> >echo " mounting finished" |
53 |
>>> > |
54 |
>>> >echo "run linux32 chroot /mnt/gentoo32 /bin/bash next" |
55 |
>>> >root@fireball / # |
56 |
>>> > |
57 |
>>> > |
58 |
>>> >You may have different mount points at the very least so edit to |
59 |
>match |
60 |
>>> >what you have. Again, things could have changed and that no longer |
61 |
>>> >will |
62 |
>>> >work. It may not be a bad idea to let someone who has done this |
63 |
>more |
64 |
>>> >recently to give a thumbs up to that. |
65 |
>>> > |
66 |
>>> >That last command should be: |
67 |
>>> > |
68 |
>>> >linux32 chroot /mnt/gentoo32 /bin/bash |
69 |
>>> > |
70 |
>>> >Dale |
71 |
>>> > |
72 |
>>> >:-) :-) |
73 |
>>> |
74 |
>>> That script is too long :) |
75 |
>>> |
76 |
>>> cd /mnt/gentoo |
77 |
>>> mount -o rbind /dev dev |
78 |
>>> mount -o rbind /sys sys |
79 |
>>> mount -o rbind /proc proc |
80 |
>>> cp -L /etc/resolv.conf etc/resolv.conf |
81 |
>>> cd .. |
82 |
>>> chroot gentoo /bin/bash |
83 |
>>> |
84 |
>>> To undo: |
85 |
>>> cd /mnt/gentoo |
86 |
>>> umount -l proc sys dev |
87 |
>> |
88 |
>> That's still too long :) |
89 |
>> |
90 |
>> With systemd-nspawn, you only do: |
91 |
>> |
92 |
>> systemd-nspawn -D /mnt/gentoo |
93 |
>> |
94 |
>> Systemd takes care of /dev, /sys, etc. If the container has systemd |
95 |
>> installed, you can do |
96 |
>> |
97 |
>> systemd-nspawn -bD /mnt/gentoo |
98 |
>> |
99 |
>> and the services inside the container will be started like in a |
100 |
>regular boot |
101 |
>> (you'll need to set the root password for the container). |
102 |
>> |
103 |
>> Also, if you want to share the /usr/portage directory between host |
104 |
>and |
105 |
>> container, you only need to |
106 |
>> |
107 |
>> systemd-nspawn --bind=/usr/portage -bD /mnt/gentoo |
108 |
> |
109 |
>Oh, and I forgot: to stop the container, just log out if the container |
110 |
>runs OpenRC, or run systemctl poweroff if the container runs systemd. |
111 |
> |
112 |
>Regards. |
113 |
|
114 |
That script could easily be written in C and compiled and then called in a similar way as systemd-nspawn. |
115 |
|
116 |
What your command does is basically the same apart from doing something different from using chroots. |
117 |
|
118 |
Converting a perfectly working and efficiently running system to use something like systemd just to have a chroot environment is overly complex and convoluted. |
119 |
These solutions often cause more issues then the problem it tried to solve. |
120 |
|
121 |
-- |
122 |
Joost |
123 |
-- |
124 |
Sent from my Android device with K-9 Mail. Please excuse my brevity. |