public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
From: Kai Krakow <hurikhan77@gmail.com>
To: gentoo-user@lists.gentoo.org
Subject: [gentoo-user] Re: How to repair a 'secondary Gentoo system'
Date: Tue, 12 Dec 2017 02:45:48 +0100	[thread overview]
Message-ID: <cvo3ge-cif.ln1@hurikhan77.spdns.de> (raw)
In-Reply-To: DBYDB4DM.H33UZDZF.NOJ2JSBF@4LJ2255N.JE52AS6M.VAVRWHVD

Am Mon, 11 Dec 2017 20:12:49 +0100 schrieb Helmut Jarausch:

> On 12/11/2017 05:58:42 PM, David Haller wrote:
>> Hello,
>> 
>> On Mon, 11 Dec 2017, Helmut Jarausch wrote:
>> >But now, don't ask me why,
>> >chroot  /OtherGentoo   /bin/bash
>> >dies of a segment fault.
>> >
>> >Is there any means to repair such a Gentoo system short of  
>> rebuilding it
>> >(nearly) from scratch?

You could try to start emerge with chroot directly instead of dropping 
into a shell, then rebuild whatever causes the segfault:

$ chroot /OtherGentoo emerge -1a bash

But keep in mind that chroot doesn't do a very good isolation against the 
host system. You may want to use a wrapper script to setup the needed 
mounts, and maybe some more stuff.

You could also try running busybox instead of bash.


>> How about a bit of debugging first?
>> 
>> # catchsegv chroot  /OtherGentoo   /bin/bash
>> # cd /OtherGentoo/ && chroot  /OtherGentoo/ /bin/bash
>> 
>> (ISTR, there was/is a reason for first cd-ing into the chroot and then
>> chrooting with the full-path...)
>> 
>> Have you (bind) mounted /sys, /dev, /proc into the chroot?
>> 
>> I use this as the top and bottom of a little bit longer
>> chroot-wrapper-script:
>> 
>> ==== /root/bin/chrooter ====
>> #!/bin/bash
>> root="$1"
>> shift
>> 
>> test -e "${root}/proc/kcore" || mount --bind /proc/ "${root}/proc"
>> test -e "${root}/sys/block"  || mount --bind /sys/ "${root}/sys"
>> test -e "${root}/dev/root"   || mount --bind /dev/ "${root}/dev"
>> test -e "${root}/dev/pts/0"  || mount --bind /dev/pts/  
>> "${root}/dev/pts"
>> [..]
>> cd "$root"
>> chroot "$root" /bin/bash -l
>> ====
> 
> My procedure is quite similar, I only use
> 
> mount --rbind /dev/ "${root}/dev"
> 
> and
> 
> mount --rbind /run  /${NROOT}/run
> 
> ---
> 
> I've tried
> catchsegv chroot  /OtherGentoo   /bin/bash
> 
> as well as
> 
> chroot  /OtherGentoo   catchsegv /bin/bash
> 
> In both cases, I don't get any error messages BUT I don't get chrooted.
> 
> Strangely enough, dmesg shows
> 
> systemd-coredump[25375]: Failed to connect to coredump service: No 
such  
> file or directory

It seems that at least systemd is installed and dropped some sysctl files 
in the directory structure. This would then set kernel.core_pattern to 
systemd-coredump.

OTOH, you may want to try to enter other Gentoo system with systemd-nspawn 
instead of chroot. It would also setup most of your bind mounts correctly:

$ cd /OtherGentoo && sudo systemd-nspawn

Similar to your use-case, I'm using such a OS tree to manage a rescue 
system in case my main system would not boot. A simple script is used as 
a wrapper to enter the system:

$ cat /mnt/rescue/enter.sh
#!/bin/bash
cd $(dirname $0) && \
exec sudo systemd-nspawn --bind=/usr/portage --bind=/boot $@


> although I'm not using system but openrc on both system

systemd-nspawn should be able to enter non-openrc systems but the host OS 
needs a running systemd instance to build the namespace scope.

I can even simulate a full rescue system boot that way:

$ /mnt/rescue/enter.sh -nb

and the container boots, dropping me at a console login.


Both provides much better isolation and simulation of the root 
environment than chroot.


-- 
Regards,
Kai

Replies to list-only preferred.



      parent reply	other threads:[~2017-12-12  1:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-11 16:23 [gentoo-user] How to repair a 'secondary Gentoo system' Helmut Jarausch
2017-12-11 16:58 ` David Haller
2017-12-11 19:12   ` Helmut Jarausch
2017-12-11 19:45     ` David Haller
2017-12-11 20:56       ` Rich Freeman
2017-12-11 20:06     ` Dale
2017-12-12  1:45     ` Kai Krakow [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cvo3ge-cif.ln1@hurikhan77.spdns.de \
    --to=hurikhan77@gmail.com \
    --cc=gentoo-user@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox