0

I'm working on a RH 7.3 with some issues on the partitions so It doesn't boot properly and goes in emergency mode. I booted the machine from an RH 7.3 iso and I need to extract an sosreport in Rescue mode but I have the following errors:

chroot /mnt/sysimage
chroot: failed to run command '/bin/sh': No such file or directory

So I use the following command as in the page https://access.redhat.com/solutions/43133:

ln -s bash /mnt/sysimage/bin/sh

but I'm getting the error message:

ln: failed to create symbolic link /mnt/sysimage/bin/sh: No such file or directory

Could you help me please?

intore
  • 399
  • 1
  • 6
  • 13
  • symlinking to a file outside the chroot will not and can not work. the linked file is inaccessible inside the chroot, and the symlink is followed with the chroot dir as /. copy the file instead, e.g. `cp -a /bin/bash /mnt/sysimage/bin/`. Note that a symlink like `ln -s /bin/bash /mnt/sysimage/bin/sh` will now work because there **is** now a /bin/bash inside the chroot – cas Oct 22 '19 at 03:38
  • BTW, the chroot will also need its own copy of any shared libs required by bash. and lots of other stuff if you want to do anything useful inside the chroot. – cas Oct 22 '19 at 03:40
  • I can't copy because the directory bin in /mnt/sysimage/ doesn't exist – intore Oct 22 '19 at 09:52
  • that's what `mkdir` is for. mkdir then cp. BTW that explains your "No such file or directory" error message - you can't create a symlink in a non-existent directory, either. – cas Oct 22 '19 at 10:22
  • To anyone with a similar problem: Note that `/mnt/sysimage` being completely empty when in RHEL rescue mode suggests that the start-up of the rescue mode failed to mount the installation that should be rescued, suggesting a major problem with its root filesystem. There should also have been a message dialog from the rescue mode start-up, indicating the failure to mount the root filesystem. You should first try and investigate the state of the problematic root filesystem without chrooting, and mount it manually and *then* chroot if possible. – telcoM Jan 10 '23 at 05:18

1 Answers1

0

The link is not public. But most likely you have to use the full path to the bash shell (or be in the folder /bin). Try:

ln -s /bin/bash /mnt/sysimage/bin/sh
Eduardo Trápani
  • 12,032
  • 1
  • 18
  • 35