Restore steps for the Linux BOOTF partition being emptied

Source: Internet
Author: User
Tags gpg ssh secure shell

If the brain is disabled, the contents of the system/boot partition are removed, but you do not want to reinstall the system, you can restore the boot partition through the Linux rescue mode.

The following experimental platform is CentOS 6.2.

Root user login system, using the rm–rf/boot command to delete/boot, will be raised without/boot cannot be deleted, but all the data inside/boot is deleted.

After deleting the/boot partition, restart the system, and certainly not even the grub boot interface, there is only one "error 5" error black screen.

From the system CD-ROM boot, select "Rescue installed System", that is, rescue mode, enter into the subsequent boot process, select the default option is. Www.it165.net

There is a step together hint "do you want to start the network interfaces the", select Yes or no is not so-called, this article for the convenience of writing documents, to use SSH connection, so chose Yes, and set the network mode to DHCP.

Finally select "Shell Start Shell" to open a shell environment.

At this point the current directory of the system is/mnt/sysimage,

With Ifconfig you can see that the system automatically obtains the IP address, but using the service sshd Start command is not valid, prompting "unrecognized service",

Use the chroot command to switch the current directory to the root directory.

Using the service sshd Start command, SSH services can be turned on normally.

You can use SSH Secure Shell client to remotely access the system above, mainly to facilitate the copying of commands and results (if all the hand knocks, it is dead ~)

The operation process is as follows:

[Email protected] ~]# ls/boot/

(Note: You can see that boot is an empty directory at this point)

[Email protected] ~]# ls/mnt/

[Email protected] ~]# mount/dev/cdrom/mnt

Mount:block Device/dev/sr0 is write-protected, mounting read-only

(Note: Load the disc to/MNT)

[Email protected] ~]# ls/mnt

Centos_buildtag Packages rpm-gpg-key-centos-security-6

EULA release-notes-en-us.html rpm-gpg-key-centos-testing-6

GPL Repodata TRANS. TBL

Images rpm-gpg-key-centos-6

Isolinux rpm-gpg-key-centos-debug-6

[Email protected] ~]# cd/mnt/packages/

(Note: Enter into the packages directory where the packet is stored)

[Email protected] packages]# RPM-IVH--force kernel-2.6.32-220.el6.i686.rpm

Preparing ... ########################################### [100%]

1:kernel ########################################### [100%]

[Email protected] packages]# ls/boot/

config-2.6.32-220.el6.i686 system.map-2.6.32-220.el6.i686

Initramfs-2.6.32-220.el6.i686.img vmlinuz-2.6.32-220.el6.i686

Symvers-2.6.32-220.el6.i686.gz

(Note: Reinstall the kernel, use the--force option, force the installation, you can see the boot and/or directory with the kernel files and other files)

[Email protected] packages]# Grub-install--root-directory=//DEV/SDA

[Email protected] packages]# Ls/boot

config-2.6.32-220.el6.i686 symvers-2.6.32-220.el6.i686.gz

Grub system.map-2.6.32-220.el6.i686

Initramfs-2.6.32-220.el6.i686.img vmlinuz-2.6.32-220.el6.i686

[Email protected] packages]# ls/boot/grub/

Device.map ffs_stage1_5 minix_stage1_5 stage2 xfs_stage1_5

E2fs_stage1_5 iso9660_stage1_5 reiserfs_stage1_5 ufs2_stage1_5

Fat_stage1_5 jfs_stage1_5 stage1 vstafs_stage1_5

(Note: Re-install grub to/boot,

# Grub-install--root-directory=//DEV/SDA

The--root-directory=/in the command refers to the relative path of/boot, and the value of--root-directory can also be null, i.e.

# Grub-install--root-directory=/DEV/SDA

The system will generate a grub folder in/boot and store grub files in it, if written as--root-directory=/boot, the system will generate a boot folder in/boot and a grub folder in it. That is, the grub file is stored in the/boot/boot/grub/directory, which is not correct.

The above/boot/grub/data, in fact, can also be copied directly from the/usr/share/grub/i386-redhat/.

In the/boot/grub data listed above, it is found that the key grub.conf file does not. Need to be created manually-this is a test of memory, if each system has a backup of the grub.conf file, it is good, of course, can also be copied from other versions of the system, modified to be available-this is the manual creation of a.

[Email protected] packages]# cd/boot/

[email protected] boot]# Touch grub/grub.conf

[[email protected] boot]# ls

config-2.6.32-220.el6.i686 symvers-2.6.32-220.el6.i686.gz

Grub system.map-2.6.32-220.el6.i686

Initramfs-2.6.32-220.el6.i686.img vmlinuz-2.6.32-220.el6.i686

[Email protected] boot]# echo vmlinuz-2.6.32-220.el6.i686 >> grub/grub.conf

[Email protected] boot]# echo initramfs-2.6.32-220.el6.i686.img >> grub/grub.conf

(Note: Create a grub.conf file under/boot/grub to write Vmlinuz and Initramfs files to the grub.conf file)

[Email protected] boot]# vim grub/grub.conf

Default=0

timeout=10

Title CentOS 6

Root (hd0,0)

kernel/vmlinuz-2.6.32-220.el6.i686 ro Root=/dev/mapper/vg_itpro-lv_root Quiet

Initrd/initramfs-2.6.32-220.el6.i686.img

(Note: Edit the grub.conf content, note that "title CentOS 6" is not "=", and save the exit;

It is recommended to use VIM instead of VI, because VIM coloring, it is easier to know their input error, of course, SSH remote See coloring;

If you forget the root=/dev/mapper/vg_itpro-lv_root, you can see it through the Df–h command, as shown in P-03)

When the above settings are complete, unmount the disc and restart the system

[Email protected] boot]# umount/dev/cdrom/mnt

Umount:/mnt:not Mounted

[Email protected] boot]# Eject

[[Email protected] boot]# Init 6

init:failed to connect to Socket/com/ubuntu/upstart:connection refused

[email protected] boot]# reboot

Shutdown:unable to shutdown system

[Email protected] boot]#

Broadcast message from [email protected]

(/dev/pts/0) at 15:31 ...

The system is going down for reboot now!

The above init 6 is invalid, reboot also invalid, indicating rescue mode, these two commands are not available,

Need to go to the local system, exit the shell with the Exit command,

Then select the "Reboot reboot" option to restart the system (as shown in P-01).

The first reboot, the speed is relatively slow, there is a longer period of repair process, P-03 shown;

After the repair, the system will automatically restart again, normal access to the login screen.

Recovery steps for a Linux BOOTF partition being emptied

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.