this post was submitted on 25 Feb 2024
32 points (86.4% liked)

Linux

47356 readers
1347 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 5 years ago
MODERATORS
 

The title explains it well. But I installed Mint on a 2nd partition, then deleted it since I no longer used it, and now Grub dumps me to the command line on boot :/

How do I recover?

EDIT: gonna give up. Fuck grub lmao EDIT2: Just reinstalled mint and used the grub it gives to fix everything lmfao

you are viewing a single comment's thread
view the rest of the comments
[–] 12510198@lemmy.blahaj.zone 24 points 6 months ago (17 children)

As long as the kde neon partition is still there, recovery should be possible. You will need a way to boot into a linux environment like a installation media of just about any distro, where you will be able to mount your kde neon install, chroot in, and reinstall grub. Now I dont know your system or how you have it setup, but I can try and give some basic instructions.

So first things first, you are gonna want to get into a linux environment and open a terminal and start a root shell, this may be different depending on your environment, but its pretty much just:

sudo bash

or

su -l root

now if either of these ask you for a password, and its not presented somewhere, you may have to search on the internet for like installation disk default password, but hopefully sudo is just setup to run without one.

Now that you are in the root shell, you need to find the name of the block device that corresponds with your kde neon partition, the lsblk utility can be used to list all detected block devices, you are gonna want to find the one with the same size as your kde neon partition, this will likely be the one. Now if your partition has a label on it, you can use ls to look into the /dev/disk/by-label/ directory and see if you see your partitions label there, if so, you can just mount it like this:

mount /dev/disk/by-label/example-label /mnt

If the /dev/disk/by-label/ directory does not exist, it just means that none of the partitions are labeled. If you are having trouble determining what partition has your data, you can try mounting each one and looking inside, and unmounting them if it doesnt have your kde neon install like this:

mount /dev/sda1 /mnt
ls /mnt
umount /mnt

sda1 is just an example here, it may be different on your system.

Now when you have found the partition that has your kde neon install and mounted it to /mnt, you can now cd in and bind mount the special directories like this:

cd /mnt
mount -t proc /proc proc/
mount -t sysfs /sys sys/
mount --rbind /dev dev/

now if you are booting using UEFI, you will have to bind mount the efivars directory with this command:

mount --rbind /sys/firmware/efi/efivars sys/firmware/efi/efivars/

Now with everything mounted, you should be ready to chroot in and reinstall grub, you can chroot with this command:

chroot /mnt /bin/bash

Now that you are in your kde neon install, you can reinstall grub, the installation process may vary depending on if you are booting legacy BIOS or UEFI, to install grub on bios, you would run:

grub-install --target=i386-pc /dev/sda

now /dev/sda is just an example here, but you want to install it to the main disk, dont install it to a partition like sda1 or something.

But if you are on efi, there may be an extra mount involved, the EFI system partition, now if the EFI system partition gets mounted automatically in normal circumstances, you should be able to just run:

mount -a

this command will mount the partitions listed in the /etc/fstab file. If the partition was destroyed, it will have to be recreated. If it is not listed in the fstab and is not automatically mounted, you may have to seek it out manually with lsblk, it should be the smallest partition, use the mount command to mount it to /boot/efi, creating this directory if it does not already exist. If you have to create one, just make a partition with at least 16 megs of space, and format it as a FAT partition, you can use the mkfs.msdos or mkfs.fat command line utilities like this:

mkfs.msdos /dev/sda2

where /dev/sda2 is the free space that is gonna be used for the system partition, this command is destructive, and will overwrite any data on the partition, so make sure you enter the one with just free space.

Once you know what partition is your efi system partition, and you have mounted it to /boot/efi in the chroot, you can now install the UEFI version of grub, you can use this command

grub-install --target=x86_64-efi --efi-directory=/boot/efi

and for good measure/backup incase grub cant tell your firmware where it is located, you can install it to the removable media path where your firmware will look if it doesnt have any entries with this command:

grub-install --target=x86_64-efi --efi-directory=/boot/efi --removable

And finally, once you have installed grub for either UEFI or BIOS, you can generate the config file, like this:

grub-mkconfig -o /boot/grub/grub.cfg

Now you can reboot using the reboot command like this:

reboot

it should take care of unmounting everything for you, make sure you remove whatever installation media if you are using any from your system. And hopefully it should just boot into the normal grub menu and start your kde neon install.

[–] KanariePieter@feddit.nl 2 points 6 months ago

Saving this comment just in case I ever end up in a similar situation. Very well explained!

load more comments (16 replies)