Erased /boot by mistake

I did a mount error while installing a unix on a usb ssd external disk and I erased my zorin /boot directory. My uefi partition was not destroyed. Zorin is not anymore bootable. It is installed on zfs filesystem with encryption. I have booted on another disk with CachyOS (also in zfs) and chrooted on zorin. Everything is still in place but /boot . I have created the uefi mount point, mounted the uefi partition, decrypted the zfs pools (bpool,rpool) decrypted and mounted all datasets. I can chroot in zorin but when I try to reinstall linux-image-hwe-22.04 or any other package I get this error messages :
GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name is not activatable
I haven't find how to solve this. And what bootloader does the zfs installation normally use ? I have grub installed but not grub-mkconfig nor update-grub. Is it possible that zorin with zfs encrypted is booting with systemd ?

Thanks in advance for any hint to solve this!
Regards,
Bernard
EDIT: I have found the rest of grub that was missing. It's my PATH that was missing /sbin and /usr/sbin. Now I can try a grub-update to see if anything happens ...

Yes, given all you describe, you are very likely using SystemD boot.
The steps to try to restore boot on your machine are lengthy and complex, and given you are using ZFS with encryption, this offers little room for mistakes.

If you are able to access your Zorin OS system in order to backup your data, I would backup personal files and data, then perform a fresh, clean install in order to safely and easily repair everything.
You can try

service dbus restart

run from inside your chroot environment if you need dbus running at that time.

You can't start/restart services in a chroot since it would interfere with the host.

(CHROOT)root@cachalot:~# service dbus restart
Running in chroot, ignoring command 'restart'

Fair enough. You might try using the host's dbus socket:

mount --bind /run/dbus /mnt/run/dbus
chroot /mnt
1 Like

I already have mounted : /dev, /proc,/sys,/run ... all with --rbind option.
But is it possible that the dbus socket is not named exactly the same way in arch ? I see there is a "/run/system_bus_socket" but no "/run/dbus" ???

Do you mean Arch Linux?
Yes... Arch and Arch based distros would use a different naming convention
/run/system_bus_socket

You also do not want to bind dbus blindly... You need its location before mounting and binding.
Zorin OS:

ls -l /run | grep dbus

Arch / Arch-based:

ls -l /run | grep system_bus_socket

Yes I'm booting from a usb ssd disk with cachyos. CachyOS is based on Arch and I'm chrooting in the laptop disk that has the zorin installation.
The system_bus_socket is in /run/dbus directory.

(CHROOT)root@cachalot:/run/dbus# ls
system_bus_socket
I have to check on a zorin live where is exactly dbus .
Will do tomorrow, it's getting late here (almost 1 am) and I need to sleep.

Thanks a lot for the help. :+1:

1 Like

This is why I stick with Ext4, and no encryption. Taking regular snapshots is a good idea too. Am I right in thinking Zorin has been installed as a VM?

No, it's on the nvme laptop internal disk. I had backups with borgbackup but my root backups got corrupted and I lost them. I'm reading about snapshot on zfs but didn't took any zfs snapshots yet. I'm just looking for a solution to rebuild the /boot directory by reinstalling kernel, modules, and all the stuff that use to go there. There is not much to reinstall to get back to be a bootable installation.

Out of curiosity I did a search, basing on Ubuntu 22.04 on which Zorin is based and Brave A.I. came back with:

"#

Rebuilding ZFS Encrypted Boot Directory

To rebuild the /boot directory of a ZFS encrypted Linux drive running Ubuntu 22.04, follow these steps:

  1. Ensure ZFS Pools are Exported:
zpool export -a
  1. Prepare the Boot Partition:
  • If using UEFI, create an unencrypted /boot/efi partition (1MB) and an unencrypted /boot partition (512MB).
  • For BIOS systems, ensure the /boot partition is unencrypted and accessible.
  1. Import the ZFS Pools:
zpool import -N -R /mnt rpool
zpool import -N -R /mnt bpool
  1. Mount the Filesystems:
zfs mount rpool/ROOT/ubuntu_$UUID
zfs mount bpool/BOOT/ubuntu_$UUID
zfs mount -a
  1. Chroot into the Installed Environment:
mount --make-private --rbind /dev /mnt/dev
mount --make-private --rbind /proc /mnt/proc
mount --make-private --rbind /sys /mnt/sys
mkdir /mnt/run/lock
chroot /mnt /bin/bash --login
  1. Install GRUB:
  • For UEFI systems:
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=ubuntu --recheck --no-floppy
  • For BIOS systems:
grub-install /dev/sda
  1. Update GRUB Configuration:
update-grub
  1. Rebuild the /boot Directory:
  • Ensure the /boot directory is populated with the necessary kernel and initramfs files.
  • If necessary, regenerate the initramfs:
mkinitramfs -o /boot/initrd.img-$(uname -r)
  1. Exit Chroot and Reboot:
exit
reboot

These steps should help you rebuild the /boot directory for your ZFS encrypted Linux drive running Ubuntu 22.04. Ensure that you have backups of your data before making any changes to your boot partition or filesystems."

I suspect you would need to replace ubuntu with zorin, but I would not care to risk it. Scary stuff!

Wow! I will retry with this guide. Thanks a lot!
I will come back with results soon.

The grub-install command doesn't work on zfs :

(CHROOT)root@fido:/# grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=ubuntu --recheck --no-floppy
Installation pour la plate-forme x86_64-efi.
grub-install : erreur : système de fichiers inconnu.

(error : unknown file system)

the zfs module is loaded in memory :

(CHROOT)root@fido:/# lsmod|grep zfs
zfs 7053312 24
spl 163840 1 zfs
(CHROOT)root@fido:/#

It seems that grub doesn't like zfs ??? (I have grub-2.06-2ubuntu7.2+zorin1)
or is there some more parameters to add for zfs ???

Still googling and searching for a solution :nerd_face:

1 Like

The Brave A.I. bravely tried... But yes, you should be setting up SystemD boot, instead. Further, it is a lot more steps than listed in that post - which I mentioned earlier in this thread.
Sadly, just installing some kernel and other packages will not automatically restore /boot.

I am pretty firm in the camp that reinstalling the O.S. is your best option. Trying to restore /boot will be tedious and tricky; especially given that youa re running ZFS on a fully encrypted drive.

You were quite on top of your game using CachyOS to access your internal contents which allows for making backups of personal files and data. In my opinion: Take The WIN and run with it.
And a reinstall can be done even more painlessly:

2 Likes

Thanks, I will go for a reinstall. But it'a a bad for a good since it gave me the opportunity to learn more on the zorin boot process. My data is not lost. I will just take a good backup of everything. And try a reinstall with you guide.

Thank you everyone for your very appreciated help,
Bernard
:+1:

3 Likes

To be honest, ZFS encryption only makes sense, for a government computer workstation, or other job where you need high level's of security. The first time I tried a ZFS install of OS, I immediately ran up against road blocks. I was told to not use ZFS if I don't really need it.

You need to realize, Linux is already by default, far more secure then Windows! So, unless your setting up a government computer on a secure network, you don't need ZFS! I think sometimes we Linux users get so caught up in the mindfulness of security, we forget how secure Linux already is.

To be perfectly honest, unless someone breaks into your house, and sticks a USB stick in, to do that typical hacker level BS, you have nothing to worry about. You'd be better suited installing camera's on your house. As doing that alone, will greatly secure your home against intruders, especially if intruders can see the infrared led's at night time.


1 Like

I think that a laptop ought to be encrypted since it's more exposed to stealing. I want a filesystem with COW (snapshots) but I had many bad experiences with btrfs (not mature enough for everyday usage and recovery tools stinks).
Note that I wanted also to get rid of systemd but I didn't succeed booting with zfs encrypted, ZBM and VoidLinux (I tried Redcore and Gentoo but updates are too long and complex. I want a life ;=) ). So my quest for the perfect linux and desktop is not ended ... I'm still not decided on what will follow. I continue my reflection as to what shall be installed on this laptop

2 Likes

FreeBSD has ZFS. I personally use UFS with no encryption on my FreeBSD but next install I may give ZFS a try after hearing the praises sung about it. However laptop mileage may vary, although they have been doing a lot of work groups lately with the aim seemingly to offer broader laptop support.

EDIT: Also I reckon they don't care much for systemd over there on them BSDs.

1 Like

I have installed cachyos on zfs with Hyprland on the laptop. I'm just having all configs fixed to my taste. But It's already ok for about 90% of the configuration.
The external ssd drive will be available for trying something like freeBSD. But I need to read a bit before going that way.

2 Likes

I had the best BSD experience with Ghost BSD. In terms of a systemd free OS, I can highly recommend PCLinuxOS Debian Plasma, but there is also xfce, MATE, budgie and Cinnamon DE's. For security, why not implement a YUBI key where the laptop won't boot without it? There was an article in Linux Magazine in two parts, missed the first one, but I think the second article I have somewhere tells how to create your own, and to keep a spare thumb drive if something happens to the first.

3 Likes

Note that a yubikey is a strong authentication device but it doesn't protect your data from being read by others that have physical access to your disk. You still need encryption for that. I'd say that a yubikey is more relevant on a server with many users or a in business context.