Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
"Accidentally" deleted boot partition & systemd. What do?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
FatFourtyTwo
n00b
n00b


Joined: 10 Jul 2022
Posts: 21

PostPosted: Tue Aug 16, 2022 7:09 pm    Post subject: Screwed up boot partition & systemd. Can I save it? Reply with quote

This was a series of extremely stupid decisions on my part. It went something like this:

> be me, scrolling through random root directories in Gentoo


> think "Hmm, I can't help but notice I have both systemd and OpenRC on here. Those are both init systems, right? That seems redundant. I'm going to just remove one."

> enter sudo rm -R /lib/systemd

> reboot.

> discover that Gentoo Xsession can't start after login

> check user home directory using tty2; discover that .xsession-error file says:

Code:

gnome-session-binary: WARNING: Failed to upload environment to systemd: GDbus.Error:org.freedesktop.Dbus.error.systemd1 does not exist

gnome-session-binary: WARNING: Could not parse desktop file xscreensaver.desktop

[discover_other_daemon]: 0** Message: couldn't access control socket.  /run/user/1001/keyring/control: No such file or directory

(gsd-sharing:3302): sharing-plugin-WARNING **: Faied to StopUnit service: GDBus.Error:org.freedesktop.Dbus.Error.ServiceUnknown
...


> think "Hmm, that's annoying. I'll probably have to reinstall systemd. I can sort this out later. In the meantime, I have this Manjaro install disk that I've been meaning to put on the rest of my hard drive. Maybe I can use it as some kind of recovery drive! Let's partition using fdisk."

partitions disk

sets Calamares to call /dev/nvme0n1p1 its EFI boot partition, the same boot partition as the Gentoo system

> Calamares: Erases Gentoo boot partition (while keeping the root partition, /dev/nvme0n1p3, intact)

> Me, not thinking this through: naively thinks that grub will display both Manjaro and Gentoo partitions

> Me: realizes that I just deleted the deleted the boot partition of my old system

> Also me: headdesks repeatedly, boots Manjaro, and runs to Gentoo forums in hopes that benevolent strangers can fix the consequences of his stupidity


Needless to stay, I don't trust myself not to screw this up even more. So my question is:

1. How do I fix my boot partition?

2. How can I boot into an Xsession on my Gentoo install?

3. Is there a smart way to do the thing I was trying to do in a stupid fashion (i.e. removing one init system and giving its jobs to another)?

To clarify: Currently there are four partitions on the disk: partition 1 = the EFI boot partition that I screwed up (FAT32), partition 2 = the Gentoo swap partition, partition 3 =the Gentoo root partition (ext4), partition 4 = the Manjaro root partition (ext4)

EDIT: I should also note that the reason I'd like to save my Gentoo system that I already had a functioning system on partiiton 3 that I've been using for a few days (and which I spent a lot of time customizing). I am only posting this in the "Installing Gentoo" section because I tried tio post in the "Other Things Gentoo" section, but kept getting an error.
Back to top
View user's profile Send private message
alamahant
Advocate
Advocate


Joined: 23 Mar 2019
Posts: 3879

PostPosted: Tue Aug 16, 2022 7:50 pm    Post subject: Reply with quote

Hi
Sorry for your loss.
The precense of
Code:

 /lib/systemd

directory doesnot imply a systemd system.
All openrcs have this directory also.
To solve this you could try
Code:

mkdir  /lib/systemd
emerge -eav @world

ie rebuild all your packages.
Best is if you backed up everyday before emerge update.
Plz make a habit of it.
Quote:

> Calamares: Erases Gentoo boot partition (while keeping the root partition, /dev/nvme0n1p3, intact)


This is not a big problem. Recreate the partition, mount it in chroot, re-emerge grub, reinstall grub, reinstall the kernel either via /usr/src/linux or via re-emerging it(if binary), recreate initramfs and update grub.
_________________
:)
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54225
Location: 56N 3W

PostPosted: Tue Aug 16, 2022 8:06 pm    Post subject: Reply with quote

FatFourtyTwo,

The good news is that everything in /boot either exists elsewhere on your install or is automatically created.

Get into your Gentoo install by chrooting.
Just as you did when you installed. Do not make any partitions, do not make any filesystems, just moun what is already there.
Install grub,
Install your kernel
Tell grub all about about it by creating grub.cfg. There is a script for that.

Check that your EFI will boot grub.

Reboot to test.

Your Gnome session needs a different fix.
There is a an emerge command to emerge all the packages that put files into a given path.
I rarely use it.

Code:
emerge -1av /lib/systemd
looks promising

See
man emerge:

       file   A  file  must be a file or directory that has been installed by one or more packages. If an absolute path is not used, then it must begin with either "./"
              or "../". For directories that are owned by multiple packages, all owning packages will be selected. See the portageq(1) owners command if you would  like
              to query the owners of one or more files or directories.


It takes a special talent so break Gentoo so badly it cannot be fixed. You haven't done it ... yet :)

On my system
Code:
emerge -1av /lib/systemd
wants to rebuild 26 packages. You will get a different answer.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
FatFourtyTwo
n00b
n00b


Joined: 10 Jul 2022
Posts: 21

PostPosted: Tue Aug 16, 2022 11:15 pm    Post subject: Reply with quote

Update for posterity:

I tried to retrace my steps in the install (i.e. mounting the file systems, chrooting into the disk, etc), and I did. But when I tried to emerge @world, it said that I didn't have permission to do this (which was odd, because I was root), and some error like 'this may indicate a bad /dev/fd.' I had absolutely no idea what it was trying to say, so I gave up on that. Instead I just booted into a grub shell, and mounted vmlinuz and initramfs manually. That was successful, and I was able to get into the system.

However, when I tried the suggested commands (emerge @world and emerge -1av /lib/systemd), I still was not able to boot into my desktop environment. In fact, I wasn't able to boot into *any* DE.

What I tried to do next was grub-mkconfig /dev/partition1 thinking that grub would find the config file and boot to my current layout. Apparently, I misunderstood what this command did, and now the entire system is just not bootable.

This is the point at which I throw up my hands, boot a live disk, chroot into the partition, save my important files to a USB drive, and do a clean install. Yes, I know there are other paths I could try. This is just a lot more straightforward and I'm sick of dealing with it. But I definitely learned my lesson: don't go deleting system files when you don't know what they do.
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21607

PostPosted: Wed Aug 17, 2022 12:23 am    Post subject: Reply with quote

Next time, if you want to remove system files, remove them by using emerge --ask --depclean --verbose package-which-owns-the-files. This will let Portage check that the package is truly unneeded, refuse to proceed if the package is needed, and clean out the package properly if it is unneeded.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54225
Location: 56N 3W

PostPosted: Wed Aug 17, 2022 11:42 am    Post subject: Reply with quote

FatFourtyTwo.

In the chroot, /dev/fd and all of /dev is providedby the bind mount of /dev.
Its not enough to mount just your partitions, /dev, /proc and /sys are required too.
its retrace the handbook steps but skip the partition and filesystem making as you want to reuse what is already there.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum