Help: How to restore Centos 8 system after deleting accidentally boot data

Issues related to applications and software problems and general support
Post Reply
amtenorio
Posts: 2
Joined: 2021/01/19 00:18:05

Help: How to restore Centos 8 system after deleting accidentally boot data

Post by amtenorio » 2021/01/19 01:02:46

Well, this weekend has been very difficult. I have a centOS 8 computer, configured as Web and SSH servers. It have been working very well in two years, without any issue. Because of confinement I need to do a lot of remote work to access the server and to store files in external HDs I need to recover from time to time. But playing with mount commands (a bad idea), It seems I mounted by accident the boot partititon which had also the efi folders. So I apparently I unmounted it but for some reason the mounted folders didn't desapair, they persisted. But saddly I notice this when I tried to delete the mounting folder.

Then, in a chain of unfortunate events, I reboot the computer but it entered to the DELL setup system (its a Dell Presicion), but it is not booting any more.

So I tried to recover using the original usb and centos-iso I used to install the server, with the application Rescue a Centos Linux system (I needed to visit my lab for doing that), with the option: 1) Continue

then I mounted the system with:

chroot /mnt/sysimage

I can see all my files are still there in /home and /var/www/html (I have a moodle system for teaching).

but when I try to reapair with:

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

I am getting an error message: There is not an EFI folder

Then I try also:

grub2-install /dev/sda1 #(becasue on this dev it is present /boot/grub/efi/EFI/centos as showed with lsblk )

However I am getting a message:

grub2-install: error: /usr/lib/grub/x86_64-efi/modinfo.sh doesn't exist

when I visit the folder /usr/lib/grub there is only an i386 folder

What can I do? Forgive me, this is my first post. Not sure if this is the correct place and which other information I need to include. I don't have access in this moment to the server, but tomorrow I can.

I am very sad, becasue no recent backups of my course were made recently (a month at least), important to recover my moodle system (all the file system if possible)

So, also I wonder if there is some third-party software can help me (like rescatux?) but I can try the hard way. I am desperate to recover my data this week :cry:
Last edited by amtenorio on 2021/01/19 17:01:37, edited 2 times in total.

User avatar
penguinpages
Posts: 91
Joined: 2015/07/21 13:58:05

Re: Help

Post by penguinpages » 2021/01/19 13:20:24

Is this a physical or virtual machine?

I would assume physical based on thread.

When it boots do you get grub menu... or blinking cursor?

Is the data on an independent partition where you could reload the OS and leave the data partitions alone. Ex: /var and /opt are separated partition on my systems to avoid user overrunning space. As such if I were in the situation you are .. I would mount with Live media .. move over any OS configuration files I may have of use.. Ex: httpd.conf SSH keys etc.. and reload the OS.. Then just remount the partitions with data back.

I and others may be able to help repair the OS via various steps and commands but need to know the current state of the boot process to help AND.... ROI may just be faster to reload.





PS: Subject "help" less then descriptive :)

amtenorio
Posts: 2
Joined: 2021/01/19 00:18:05

Re: Help

Post by amtenorio » 2021/01/19 16:23:21

First of all thank you for your help. I will try to answer the questions.

1. This is a physical machine, as it is a dedicated server. Is running on a Dell Precision Tower 5810. It is the only operating system. Originally had Windows 8, but I replaced it with CentOS 7 y upgraded later to CentOS 8.

2. When it boots I got a grub menu but it only has the option System setup. If I press this option it restarts and enters to the BIOS setup menu.

3. When I start the system with bootable usb stick and using the option "Rescue a CentOS Linux System" I am able to mount the file system running chroot. When I use fdisk -l it shows:

Disk /dev/sda: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 699D38F4-7032-4456-A3DE-B6F6DA3BC365

Device Start End Sectors Size Type
/dev/sda1 2048 411647 409600 200M EFI System
/dev/sda2 1026048 1288191 262144 128M Microsoft reserved
/dev/sda3 1288192 1290239 2048 1M BIOS boot
/dev/sda4 1926371328 1927292927 921600 450M Windows recovery environment
/dev/sda5 1927292928 1953523711 26230784 12.5G Windows recovery environment
/dev/sda6 1290240 3387391 2097152 1G Linux filesystem
/dev/sda7 3387392 1926371327 1922983936 917G Linux LVM

Partition table entries are not in disk order.

....

There are more lines, so I include the full display as an attachment

The command lsblk shows:

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop0 7:0 0 448.8M 1 loop
loop1 7:1 0 3G 1 loop
├─live-rw 253:0 0 3G 0 dm /
└─live-base 253:1 0 3G 1 dm
loop2 7:2 0 32G 0 loop
└─live-rw 253:0 0 3G 0 dm /
sda 8:0 0 931.5G 0 disk
├─sda1 8:1 0 200M 0 part /mnt/sysimage/boot/efi
├─sda2 8:2 0 128M 0 part
├─sda3 8:3 0 1M 0 part
├─sda4 8:4 0 450M 0 part
├─sda5 8:5 0 12.5G 0 part
├─sda6 8:6 0 1G 0 part /mnt/sysimage/boot
└─sda7 8:7 0 917G 0 part
├─cl-root 253:2 0 250G 0 lvm /mnt/sysimage
├─cl-home 253:3 0 635.5G 0 lvm /mnt/sysimage/home
└─cl-swap 253:4 0 31.5G 0 lvm [SWAP]
sdb 8:16 1 7.3G 0 disk /run/install/repo
├─sdb1 8:17 1 6.7G 0 part
└─sdb2 8:18 1 9.7M 0 part
sr0 11:0 1 1024M 0 rom

and with the command df -h:


Filesystem Size Used Avail Use% Mounted on
devtmpfs 32G 0 32G 0% /dev
tmpfs 32G 12K 32G 1% /dev/shm
tmpfs 32G 18M 32G 1% /run
tmpfs 32G 0 32G 0% /sys/fs/cgroup
/dev/sdb 6.7G 6.7G 0 100% /run/install/repo
/dev/mapper/live-rw 2.9G 1.8G 1.2G 61% /
tmpfs 32G 1.5M 32G 1% /tmp
/dev/mapper/cl-root 250G 51G 200G 21% /mnt/sysimage
/dev/sda6 976M 18M 892M 2% /mnt/sysimage/boot
/dev/sda1 200M 32M 169M 16% /mnt/sysimage/boot/efi
tmpfs 32G 0 32G 0% /mnt/sysimage/dev/shm
/dev/mapper/cl-home 636G 146G 491G 23% /mnt/sysimage/home
/dev/sdc 7.2G 36M 6.8G 1% /mnt/usb

4. I was considering to build tar files of var/, etc/. and home accounts. Even recover manually the mysql database and then moving to a USB stick. The idea of a Live media is interesting, I only see one for CentOS 7.

But if is possible to restore server function reparing the Boot would be wonderful.
Attachments
dfisk_data.txt
Result of fdisk -l command
(3 KiB) Downloaded 21 times


desertcat
Posts: 843
Joined: 2014/08/07 02:17:29
Location: Tucson, AZ

Re: Help: How to restore Centos 8 system after deleting accidentally boot data

Post by desertcat » 2021/01/21 08:38:46

sml wrote:
2021/01/20 11:30:41
See How to reinstall GRUB2 EFI?

I was just about to post you a note: THANK YOU for helping me get Grub Customizer installed. There was some hacking needed, but I used the version I have on CentOS 7.9, and probably dating back as far as 7.6, as a template. But it *is* up and running, but still have some cleanup and reorganization to do.

TO THE OP: Congratulations you have now faced the BIG HAIRY MONSTER called Grub2. I know very few people who have kind words for Grub2. You don't have to do something "accidentally" and for reasons unknown Grub2 will go on a walkabout and stray out into the weeds. When it does you are looking at a major chore to replace. I am thanking sml for directing me to a place where I could get Grub Customizer for CentOS 8.x.

So what is "Grub Customizer"? Is is a nifty little utility that every one should have installed on their machine as it allows for an almost instantaneous recovery should your Grub2 go on a walkabout, or wander off into the weeds -- for whatever reason. Basically there are 3 files that if one or more gets screwed up can toast you: The first one is /boot/grub2; the second is /etc/grub.d; and the third is /etc/default/grub... or the efi equivalents. The file most likely to get scrambled is grub.cfg under /boot/grub2. The second most likely to get scrambled is /etc/grub.d. The least likely to cause you problems is /etc/default/grub.

In addition to allowing you to create a unique and cool start up page (where all the kernels are listed) it also allows you to painlessly update the kernel page in about 5 seconds. To make SURE I don't get caught with my pants down, I copy those 3 directories to both an off-disk as well as to on-disk BACKUP location. If Grub goes down I boot the disk with another great utility program called KNOPPIX . I then DELETE all 3 files and then COPY back all 3 files from my BACKUP FILES. Total down time is about 5-10 minutes tops.

At the current time Grub Customizer is NOT in any of the Repos, however sml took the source RPM from Fedora and rebuilt it. It didn't require any adjustments. See viewtopic.php?f=54&t=76786

Hope this helps,

D'Cat

Post Reply