1 |
Am Mon, 11 Dec 2017 20:12:49 +0100 schrieb Helmut Jarausch: |
2 |
|
3 |
> On 12/11/2017 05:58:42 PM, David Haller wrote: |
4 |
>> Hello, |
5 |
>> |
6 |
>> On Mon, 11 Dec 2017, Helmut Jarausch wrote: |
7 |
>> >But now, don't ask me why, |
8 |
>> >chroot /OtherGentoo /bin/bash |
9 |
>> >dies of a segment fault. |
10 |
>> > |
11 |
>> >Is there any means to repair such a Gentoo system short of |
12 |
>> rebuilding it |
13 |
>> >(nearly) from scratch? |
14 |
|
15 |
You could try to start emerge with chroot directly instead of dropping |
16 |
into a shell, then rebuild whatever causes the segfault: |
17 |
|
18 |
$ chroot /OtherGentoo emerge -1a bash |
19 |
|
20 |
But keep in mind that chroot doesn't do a very good isolation against the |
21 |
host system. You may want to use a wrapper script to setup the needed |
22 |
mounts, and maybe some more stuff. |
23 |
|
24 |
You could also try running busybox instead of bash. |
25 |
|
26 |
|
27 |
>> How about a bit of debugging first? |
28 |
>> |
29 |
>> # catchsegv chroot /OtherGentoo /bin/bash |
30 |
>> # cd /OtherGentoo/ && chroot /OtherGentoo/ /bin/bash |
31 |
>> |
32 |
>> (ISTR, there was/is a reason for first cd-ing into the chroot and then |
33 |
>> chrooting with the full-path...) |
34 |
>> |
35 |
>> Have you (bind) mounted /sys, /dev, /proc into the chroot? |
36 |
>> |
37 |
>> I use this as the top and bottom of a little bit longer |
38 |
>> chroot-wrapper-script: |
39 |
>> |
40 |
>> ==== /root/bin/chrooter ==== |
41 |
>> #!/bin/bash |
42 |
>> root="$1" |
43 |
>> shift |
44 |
>> |
45 |
>> test -e "${root}/proc/kcore" || mount --bind /proc/ "${root}/proc" |
46 |
>> test -e "${root}/sys/block" || mount --bind /sys/ "${root}/sys" |
47 |
>> test -e "${root}/dev/root" || mount --bind /dev/ "${root}/dev" |
48 |
>> test -e "${root}/dev/pts/0" || mount --bind /dev/pts/ |
49 |
>> "${root}/dev/pts" |
50 |
>> [..] |
51 |
>> cd "$root" |
52 |
>> chroot "$root" /bin/bash -l |
53 |
>> ==== |
54 |
> |
55 |
> My procedure is quite similar, I only use |
56 |
> |
57 |
> mount --rbind /dev/ "${root}/dev" |
58 |
> |
59 |
> and |
60 |
> |
61 |
> mount --rbind /run /${NROOT}/run |
62 |
> |
63 |
> --- |
64 |
> |
65 |
> I've tried |
66 |
> catchsegv chroot /OtherGentoo /bin/bash |
67 |
> |
68 |
> as well as |
69 |
> |
70 |
> chroot /OtherGentoo catchsegv /bin/bash |
71 |
> |
72 |
> In both cases, I don't get any error messages BUT I don't get chrooted. |
73 |
> |
74 |
> Strangely enough, dmesg shows |
75 |
> |
76 |
> systemd-coredump[25375]: Failed to connect to coredump service: No |
77 |
such |
78 |
> file or directory |
79 |
|
80 |
It seems that at least systemd is installed and dropped some sysctl files |
81 |
in the directory structure. This would then set kernel.core_pattern to |
82 |
systemd-coredump. |
83 |
|
84 |
OTOH, you may want to try to enter other Gentoo system with systemd-nspawn |
85 |
instead of chroot. It would also setup most of your bind mounts correctly: |
86 |
|
87 |
$ cd /OtherGentoo && sudo systemd-nspawn |
88 |
|
89 |
Similar to your use-case, I'm using such a OS tree to manage a rescue |
90 |
system in case my main system would not boot. A simple script is used as |
91 |
a wrapper to enter the system: |
92 |
|
93 |
$ cat /mnt/rescue/enter.sh |
94 |
#!/bin/bash |
95 |
cd $(dirname $0) && \ |
96 |
exec sudo systemd-nspawn --bind=/usr/portage --bind=/boot $@ |
97 |
|
98 |
|
99 |
> although I'm not using system but openrc on both system |
100 |
|
101 |
systemd-nspawn should be able to enter non-openrc systems but the host OS |
102 |
needs a running systemd instance to build the namespace scope. |
103 |
|
104 |
I can even simulate a full rescue system boot that way: |
105 |
|
106 |
$ /mnt/rescue/enter.sh -nb |
107 |
|
108 |
and the container boots, dropping me at a console login. |
109 |
|
110 |
|
111 |
Both provides much better isolation and simulation of the root |
112 |
environment than chroot. |
113 |
|
114 |
|
115 |
-- |
116 |
Regards, |
117 |
Kai |
118 |
|
119 |
Replies to list-only preferred. |