# \`nixos-enter\` environment failed to run \`nixos-rebuild switch\`, cannot fix broken SSD

**URL:** https://discourse.nixos.org/t/nixos-enter-environment-failed-to-run-nixos-rebuild-switch-cannot-fix-broken-ssd/80649
**Category:** Help
**Created:** [October 20, 2026, 2:42pm UTC](https://discourse.nixos.org/t/nixos-enter-environment-failed-to-run-nixos-rebuild-switch-cannot-fix-broken-ssd/80649 "2026-10-20T14:42:05Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![phaeseeKe5Ee](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/p/f0a364/32.png) [@phaeseeKe5Ee](https://discourse.nixos.org/u/phaeseeKe5Ee)
#### Post date: [October 20, 2026, 2:42pm UTC](https://discourse.nixos.org/t/nixos-enter-environment-failed-to-run-nixos-rebuild-switch-cannot-fix-broken-ssd/80649/1 "2026-10-20T14:42:06Z")

</div>

Today my nixos is so broken after update and won’t boot. I partially fixed it with liveusb and able to booted into it again. I garbage collect all the things to try fixing the config as I think there were something broken in nix store. Then I run nixos-rebuild switch. But then it hang again, I have to long press power button to turn off the computer. Now it cannot recognize my SSD and boot strict to BIOS again, so I have to use live-usb, mount all the filesystem and then run `nixos-enter` to enter the environment again.

When running as root in `nixos-enter`, I run this command in my flake repo: `nixos-rebuild switch --flake .#my_host`  
This is the output:

```auto
building the system configuration...
Checking switch inhibitors... done
update GRUB 2 menu...
Error: Failed to open dbus connection

Caused by:
      Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
Command '/nix/store/................./bin/switch-to-configuration switch' returned non-zero exit status 1.

```

Then I tried to switch to my own user with `su - user` and run `sudo nixos-rebuild switch --flake .#my_host`

```auto
sudo: /run/current-system/sw/bin/sudo must be owned by uid 0 and have the setuid bit set

```

After both the SSD is still not bootable. I do not know what to do now.

---

<div class="post-metadata">

### Author: ![phaeseeKe5Ee](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/p/f0a364/32.png) [@phaeseeKe5Ee](https://discourse.nixos.org/u/phaeseeKe5Ee)
#### Post date: [October 20, 2026, 3:40pm UTC](https://discourse.nixos.org/t/nixos-enter-environment-failed-to-run-nixos-rebuild-switch-cannot-fix-broken-ssd/80649/2 "2026-10-20T15:40:58Z")

</div>

> **[Re-installing the bootloader - Bootloader - Official NixOS Wiki](https://wiki.nixos.org/wiki/Bootloader#Re-installing_the_bootloader)**
>
> Booting from the installation media, mount the root partition under /mnt and the boot partition under /mnt/boot. Next, enter the installed system with nixos-enter, or by manually binding the virtual filesystems and then calling chroot. Finally, run...

`nixos-rebuild --install-bootloader boot`
