Hello everyone,
How can I restore a corrupted AlmaLinux server if system files /lib /lib64 or other location are deleted? Any help appreciated.
Thanks in advance.
Jenn
Hello everyone,
How can I restore a corrupted AlmaLinux server if system files /lib /lib64 or other location are deleted? Any help appreciated.
Thanks in advance.
Jenn
If critical system files are mistakenly removed such as the /lib64 or /lib directories — the best course of action is to restore them from a previously saved backup.
In case no backup is available, attempting to reinstall the relevant RPM packages is an alternative option.
The notes provided below should be treated as a last resort when trying to recover the system.
Enter the following commands before entering “chroot /mnt/sysimage” in Linux rescue mode.
Run the commands below to identify any missing files:
# rpm -Va --root /mnt/sysimage | tee /tmp/rpms_va
# for FILE in `awk '/^missing/ {print $NF}' /tmp/rpms_va`; do rpm -qf --root /mnt/sysimage $FILE; done | sort | uniq > /tmp/rpms_to_reinstall
Copy both the /var/lib/rpm directory and the /tmp/rpms_to_reinstall file to an internet-connected machine—using a USB drive, CD, or similar media. This machine must be registered with subscription and should be running the same major AlmaLinux version as the damaged server.
# scp -r /mnt/sysimage/var/lib/rpm /tmp/rpms_to_reinstall root@server:/tmp/
Log in to the internet-connected machine and install the yumdownloader package on it.
# yum install yum-utils
# yum clean all
Back up the existing RPM database directory on the internet-connected machine, then replace it with the RPM directory copied from the offline damaged server:
# mv -v /var/lib/rpm /var/lib/rpm.orig
# mv -v /tmp/rpm /var/lib/
Download the required RPM packages listed in /tmp/rpms_to_reinstall into the /tmp/rpms_install directory, then restore the original /var/lib/rpm directory back to its previous state.
# mkdir -v /tmp/rpm_updates
# for RPM in `cat /tmp/rpms_to_reinstall`; do yumdownloader $RPM --destdir=/tmp/rpms_install; done
# rm -rvf /var/lib/rpm
# mv -v /var/lib/rpm.orig /var/lib/rpm
Copy the rpms back to the damaged server:
# scp -r /tmp/rpms_install server:/mnt/sysimage/tmp/
Switch back to the damaged server and execute the following:
# rpm -i --root /mnt/sysimage --force /mnt/sysimage/tmp/rpms_install/*.rpm
# reboot
To avoid such issues in future avoid deleting system linux files.
Relax.
Albert. ![]()