Linux won’t boot-too many symbolic links

So, I was messing with LFS and I needed to have /bin/sh linked to /bin/bash but it was linked to /bin/dash. So I tried to change the link, I used the terminal, but I can’t remember what exactly the command was. I restarted my computer and when I did, It wouldn’t reboot. I get a failed message saying too many levels of symbolic links. I don’t know what to do.

Yeah, using Ubuntu for an LFS host system is typically a no-no. They don’t follow standards.

Is it possible you over wrote dash with a symlink?

Moreover, it’s probably best to boot a live USB and try to repair it from there. You can mount and chroot into the system from the live environment

1 Like

How would I go about fixing this?

Update: I got onto another Linux os from a different hardrive. I mounted the other drive but when I try to chroot into it, I get this message “chroot: failed to run command ‘/bin/bash’: Too many levels of symbolic links”

Now what?

Oh fuck, okay, don’t chroot in there, and look at the symlinks. Show me how it’s set up.

Just look in there from the live cd.

2 Likes

Don’t have a live cd, just another Linux os. But I can see all the files from the broken Ubuntu. It’s showing bash is linked to sh and sh is linked to bash so I don’t know what the problem is.

Link bash to dash, see if that’ll fix it.

sh -> bash
bash -> sh

So, sh looks for bash, sees a pointer to sh, which is a pointer to bash, which is a pointer to sh, etc… that’s why.

1 Like

And how do I go about doing this? I have access to the files, but from another os, so I don’t know how to link files from a different drive.

so, relative to the root of your drive, dash should be in /bin/dash.

you’d do the following:

ln -sfv /bin/dash /path/to/root/mountpoint/bin/bash

my guess is you symlinked some file(s) from your start dir, which somehow chained a bunch of links back to your start dir.
imagine.
/bin/bash/test.sh->/bin/dash/test.sh->/bin/bash/test.sh
what would happen when your file system see’s that symlink?
try booting a usb and see what info you can gather.

I don’t understand how I’d do this from another os.

Bruh. You are making this hard on yourself. If you can see the files then open a terminal. Navigate to the directory and undo your sh -> bash with unlink sh. Then do unlink bash.

Copy bash from the drive that you are booted on to the target directory and then point sh to the newly copied bash. Should be able to limp in the LFS boot and reinstall bash and then update alternatives on sh.

Honestly, you should not be attempting to mess with core programs and symbolic links until you understand what you are doing. As you mentioned, you did not understand/remember what you did. It is hard for others to assist if you cannot provide that information.

I hope this is not an important system. Maybe try in a VM next time.

1 Like

When you make sure that sh is linked to bash, that’s before you have a working LFS system configured.

Don’t kick him too hard, it’s clear RellyJelly is pretty new to this, we’ve all been there.

Sorry, I’m not being clear enough.

I’ll assume you’ve got zero experience. (don’t take it personally)

First, you need a LiveCD or LiveUSB. The best way to do this is probably going to be following this guide:

If you need help with that, or this won’t work for you, let me know.

Once you have that, reboot your system with the USB stick in, and boot from it. Since you’ve got Ubuntu on your computer already, I’m assuming you know how to do this.

Once that’s done, open up a terminal. From there, you’ll want to be root, so do sudo -s to open a root shell.

From there, you need to use lsblk to look at your partitions. It might look something like this:

NAME                                          MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
sda                                             8:0    0 232.9G  0 disk  
├─sda1                                          8:1    0    40G  0 part  
└─sda2                                          8:2    0   100G  0 part  
sdb                                             8:16   0 232.9G  0 disk  
├─sdb1                                          8:17   0    40G  0 part  
└─sdb2                                          8:18   0   100G  0 part

You need to find something that looks like a root partition. To do that, you need to look for either the largest or second largest partition. A root partition will be at lest 10GB large If you only have one that large or greater, we’ll use that. If you have two that fit that description, choose the second largest, because the largest is probably mounted on /home Now, I’m going to use sdb2 as my example, you need to replace sdb2 with whatever your partition is.

Next step is to mount the partition on /mnt, so you can work on the filesystem:

mount /dev/sdb2 /mnt

If that doesn’t return an error, you’re in business. The df command will show you that the partition is mounted.

From there, cd into /mnt/bin and fix the symlinks:

ln -sfv /bin/dash /path/to/root/mountpoint/bin/bash
2 Likes

Fair enough. Was not trying to be harsh.

I would suggest to do a fresh install and then start over with LFS since we don’t know what happened or how he got there.

Op @RellyJelly, were you following any imstructions. Could you link them?

Probably the LFS book, but it doesn’t say anything about linking bash to sh.