Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Restore the method of restoring boot Partition mistakenly deleted by CentOS 6

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

The main content of this article is about how to restore the boot partition deleted by CentOS 6. Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "restore restore CentOS 6 mistakenly deleted boot partition method"!

1. First, use the centos6 image to enter the linux rescue rescue mode.

two。 Start the sshd service, look at the ip address obtained by eth0, and then connect with ssh secure shell.

SSH Secure Shell 3.2.9 (Build 283)

Copyright (c) 2000-2003 SSH Communications Security Corp-http://www.ssh.com/

This copy of SSH Secure Shell is a non-commercial version.

This version does not include PKI and PKCS # 11 functionality.

[root@localhost ~] # cd / boot / / enter / boot partition

[root@localhost boot] # ls / / View the contents of the boot partition

Config-2.6.32-71.el6.i686 symvers-2.6.32-71.el6.i686.gz

Grub System.map-2.6.32-71.el6.i686

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

[root@localhost boot] # cd . . / / return to the upper directory

[root@localhost /] # rm-rf / boot/*// deletes all contents of the / boot partition

[root@localhost /] # ls / boot// View / boot partition content is empty

[root@localhost /] # mount / dev/sr0 / mnt// Mount the cdrom device to the / mnt directory

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

[root@localhost /] # rpm-ivh / mnt/Packages/kernel-2.6.32-71.el6.i686.rpm-- root=/-- force / / install the kernel package of the CD-ROM

Preparing. . . # [100%]

1:kernel # # [100%]

[root@localhost /] # ls / boot / / View / boot partition content

Config-2.6.32-71.el6.i686 System.map-2.6.32-71.el6.i686

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

Symvers-2.6.32-71.el6.i686.gz

[root@localhost /] # mkdir / boot/grub// create a new grub directory in the / boot directory

[root@localhost /] # touch / boot/grub/grub.conf// create a new grub.conf configuration file

[root@localhost /] # cp-rf / usr/share/grub/i386-pc/* / boot/grub/ copy all the contents of / usr/share/grub/i386-pc to / boot/grub.

[root@localhost /] # ls / boot// View / boot partition content

Config-2.6.32-71.el6.i686 symvers-2.6.32-71.el6.i686.gz

Grub System.map-2.6.32-71.el6.i686

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

[root@localhost /] # ls / boot/grub/ View the contents of / boot/grub directory

E2fs_stage1_5 iso9660_stage1_5 stage1 vstafs_stage1_5

Fat_stage1_5 jfs_stage1_5 stage2 xfs_stage1_5

Ffs_stage1_5 minix_stage1_5 stage2_eltorito

Grub.conf reiserfs_stage1_5 ufs2_stage1_5

[root@localhost /] # fdisk-l / / View Partition

Disk / dev/sda: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x000b1db4

Device Boot Start End Blocks Id System

/ dev/sda1 * 1 13 102400 83 Linux// this is the / boot boot partition

Partition 1 does not end on cylinder boundary.

/ dev/sda2 13 144 1048576 82 Linux swap / Solaris

Partition 2 does not end on cylinder boundary.

/ dev/sda3 2611 19819520 83 Linux / / this is / root partition

[root@localhost /] # mount// to view all mounted partitions

/ dev/sda3 on / type ext4 (rw) / / Root partition

/ dev/sda1 on / boot type ext4 (rw) / / boot partition is sda1

Devpts on / dev/pts type devpts (rw)

Tmpfs on / dev/shm type tmpfs (rw)

Proc on / proc type proc (rw)

Sysfs on / sys type sysfs (rw)

/ dev/sr0 on / mnt type iso9660 (ro)

[root@localhost /] # grub// starts grub

Probing devices to guess BIOS drives. This may take a long time.

GNU GRUB version 0.97 (640K lower / 3072K upper memory)

[Minimal BASH-like line editing is supported. For the first word, TAB

Lists possible command completions. Anywhere else TAB lists the possible

Completions of a device/filename.]

Grub "root (hd0,0) / / first find / grub/stage1 View / boot partition is (hd0,0)

Root (hd0,0) / / set / boot partition to / dev/sda1

Filesystem type is ext2fs, partition type 0x83

Grub "setup (hd0) / / reinstall grub

Setup (hd0)

Checking if "/ boot/grub/stage1" exists. No

Checking if "/ grub/stage1" exists. Yes

Checking if "/ grub/stage2" exists. Yes

Checking if "/ grub/e2fs_stage1_5" exists. Yes

Running "embed / grub/e2fs_stage1_5 (hd0)". 26 sectors are embedded.

Succeeded

Running "install / grub/stage1 (hd0) (hd0) 116p (hd0,0) / grub/stage2 / grub/grub.conf". Succeeded

Done.

Grub "quit// exit

3. Restart the reboot boot system to enter the grub interface for testing

4. Look for find / grub/stage1 and find / boot partition as (hd0,0), specify kernel,initrd, boot boot the system successfully.

5. The system boots successfully, then enter the system to rewrite the / boot/grub/grub.conf file.

6. [root@localhost /] # vi / boot/grub/grub.conf configuration file is as follows:

Finally, fill in the contents of the grub.conf file

Default=0 / / default menu is the first

Timeout=6// wait time is 6 seconds

Title mylinux / / launch with the title mylinux

The partition of root (hd0,0) / / boot is / dev/sda1

Kernel / vmlinuz-2.6.32-71.el6.i686 ro root=/dev/sda3 rhgb quiet//kernel is located in read-only mode mount / dev/sda3 root partition rhgb quiet for quiet mode does not display kernel information.

Initrd / initramfs-2.6.32-71.el6.i686.img// loads the initrd image.

7. Finally, enter linux rescue to rebuild a grub.

8. Finally, the startup interface is as follows

At this point, I believe you have a deeper understanding of "restore the method of restoring boot partitions mistakenly deleted by CentOS 6". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report