Delete system files and repair them

Source: Internet
Author: User

Delete system files and repair 1 Delete all files under the boot directory [plain] # delete/boot, then restart [root @ serv01 boot] # rm-rf * [root @ serv01 boot] # ls [root @ serv01 boot] # reboot # an Error occurs. Error 15 # Shut down the VM., then use the disc Drive, pay attention to the memory adjusted to 800 M; restart the computer, at the moment of startup, Press ESC key, enter the Boot Menu, choose CD-ROM Drive # enter the Boot interface, select Rescueinstalled system, Choose a language, select English, Keyboad Type select us, Rescue method select Local CD/DVD, Setup networking select no, Rescue select Contiune, Rescue Select OK, select OK again on the next page, shell st Art shell, start shell. # It is found that bash is entered, and cd/boot is unavailable at this time # Enter chroot/mnt/sysimage to enter/, and then enter/boot. It is found that bash is changed to sh # configure yum source, ls/iso mount/dev/cdrom/iso # reinstall the kernel yum reinstall kernerl-y # You can also use rpm to install rpm-ivhkenerl-xxx -- force -- replacefiles # install grub-install /dev/sda # exit sh exit # Enter bash, then restart reboot # Enter grub, execute the following in sequence (press the Tab key) root (hd0, 0) kernel/vmlinuz-2.6.32-131.0.15.el6.x86_64 initrd/initramfs-2.6.32-131.0.15.el6.x86_64.img boot # re-import Run root (hd0, 0) kernel/vmlinuz-2.6.32-131.0.15.el6.x86_64 initrd/initramfs-2.6.32-131.0.15.el6.x86_64.img boot # repair successful, you can edit grub. conf file. You will not reboot next time, grub. the conf file is as follows: [root @ serv01 opt] # cd/boot/grub/[root @ serv01 grub] # vim grub. conf [root @ serv01 grub] # cat grub. conf default = 0 timeout = 5 title RedHat Server 6.1 root (hd0, 0) kernel/vmlinuz-2.6.32-131.0.15.el6.x86_64 ro root =/dev/sda2 initrd/initra Mfs-2.6.32-131.0.15.el6.x86_64.img [root @ larrywen/] # ssh 192.168.1.11 root@192.168.1.11's password: Last login: Wed Jul 31 18:05:19 2013 from192.168.1.1 # It is recommended to put the/boot partition in the first location two rc. sysinit file loss [plain] # rc. the sysinit file is lost and enters the repair mode. You only need to reinstall (copy) the file to [root @ serv01 grub] # ls/etc/rc. d/rc. sysinit/etc/rc. d/rc. sysinit # installation error [root @ serv01 grub] # yum install/etc/rc. d/rc. sysinit # reinstall [root @ serv01 grub] # yum reinsta Ll/etc/rc. d/rc. sysinit [root @ serv01 ~] # Rpm-qf/etc/rc. d/rc. sysinit initscripts-9.03.23-1.el6.x86_6 # Other System File loss, similar to Operation 3 grub. the conf file is deleted [plain] # You can see/etc/grub. conf/boot/grub. conf is the same file [root @ serv01 ~] # Ls/etc/grub. conf/boot/grub. conf-l-rw -------. 1 root 817 Jul 30/boot/grub. conf lrwxrwxrwx. 1 root 22 Jul 23 00:57/etc/grub. conf-> .. /boot/grub. conf # Delete grub. cannot be resolved after the conf file # Step 1: view disk partitions [root @ serv01 ~] # Df-h Filesystem Size Used Avail Use % Mounted on/dev/sda2 9.7G 1.1G 8.1G 12%/tmpfs 188 M 0 188 M 0%/dev/shm/dev/sda1 194 M 25 M 160 M 14%/boot/dev/sda5 4.0G 137 M 3.7G 4%/opt/dev/sr0 3.4G 3.4G 0 100%/iso # Enter the directory to delete grub. conf file [root @ serv01 ~] # Cd/boot/grub/[root @ serv01 grub] # rm-rf grub. conf [root @ serv01 grub] # reboot # input these commands in sequence root (hd0, 0) # In this step, press and hold the tab key to automatically complete the kernel/# And add root =/dev/sda2 to the end. Note that your machine is not necessarily/dev/sda2, you want to view which partition the root partition belongs to through df-h kernel/vmlinuz-2.6.32-131.0.15.el6.x86_64ro root =/dev/sda2 # Press and hold the tab key and the initrd/initramfs-2.6.32-131.0.15.el6.x86_64.img is automatically completed # Note, if you have multiple kernels, You need to select # Enter boot and restart # enter the boot directory after restart. The file [root @ serv01 ~] # Cd/boot/grub/[root @ serv01 grub] # ls grub. conf ls: cannot access grub. conf: No such fileor directory # The next time we start the file, we will find that we need to re-boot the file. At this time, we will re-create the file and enter the following content. # Here is a tip, when using vim to edit files, you can read and copy commands in command mode (! Indicates executing the command) r! Ls/boot/initramfs-2.6.32-131.0.15.el6.x86_64.img [root @ serv01 grub] # vim grub. conf [root @ serv01 grub] # cat grub. conf default = 0 timeout = 5 title RedHat Server 6.1 root (hd0, 0) kernel/vmlinuz-2.6.32-131.0.15.el6.x86_64 ro root =/dev/sda2 initrd/initramfs-2.6.32-131.0.15.el6.x86_64.img [root @ larrywen grub] # ls device. map splash.xpm.gz [root @ serv01 grub] # find. -name "* stage *". /minix_stage1_5. /stage1./ Xfs_stage1_5. /ufs2_stage1_5. /ffs_stage1_5. /e2fs_stage1_5. /stage2. /jfs_stage1_5. /iso9660_stage00005. /vstafs_stage1_5. /fat_stage1_5. /reiserfs_stage1_5 # deleting all files with stages does not affect the operation. The restart is still normal [root @ serv01 grub] # find. -name "* stage *" | xargs rm-rf {}\; [root @ serv01 grub] # ll total 8-rw-r --. 1 root 63 Jul 23 00:57 device. map-rw-r --. 1 root 170 Jul 31 grub. conf lrwxrwxrwx. 1 root roo T 11 Jul 23 00:57 menu. lst->. /grub. conf-rw-r --. 1 root 1341 May 7 2010splash.xpm.gz 4 go to the boot directory, delete all the files, and restore [plain] [root @ serv01 ~] while continuously enabling connections # Cd/boot [root @ serv01 boot] # ls config-2.6.32-131.0.15.el6.x86_64 initramfs-2.6.32-131.0.15.el6.x86_64.img System. map-2.6.32-131.0.15.el6.x86_64 efi lost + found vmlinuz-2.6.32-131.0.15.el6.x86_64 grub symvers-2.6.32-131.0.15.el6.x86_64.gz [root @ serv01 boot] # rm-rf * [root @ serv01 boot] # ll total 0 # Step 1, install grub [root @ serv01 boot] # grub-install/dev/sda Probing devices to guess BIOS drives. thismay t Ake a long time. installation finished. no error reported. this is the contents of the device map/boot/grub/device. map. check if this is correct or not. if any ofthe lines is incorrect, fix it and re-run the script 'grub-install '. (fd0)/dev/fd0 (hd0)/dev/sda # Step 2: Install kernel [root @ serv01 boot] # yum reinstall kernel-y Loaded plugins: product-id, subcategory-manager Updating Red Hat repositories. S Etting up Reinstall Process rhel-iso | 4.0 kB... resolving Dependencies --> Running transaction check ---> Package kernel. x86_640: 2.6.32-131.0.15.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved ================== ========================================================== ========================================================== ====================== Package Arch Version Repository S Ize ===================================================== ========================================================== ========================================================== ================== Reinstalling: kernel x86_64 2.6.32-131.0.15.el6 rhel-iso 23 M Transaction Summary ==================== ========================================================== ========================================================== ======================================= Reinstall 1 Package (s) total download size: 23 M Installed size: 108 M Downloading Packages: Running rpm_check_debug Running Transaction Test Succeeded Running Transaction Installing: kernel-2.6.32-131.0.15.el6.x86_64 1/1 duration: 263 (MS) Installed products updated. installed: kernel. x86_64 0: 2. 6.32-131.0.15.el6 Complete! [Root @ serv01 boot] # ls config-2.6.32-131.0.15.el6.x86_64 initramfs-2.6.32-131.0.15.el6.x86_64.img System. map-2.6.32-131.0.15.el6.x86_64 grub symvers-2.6.32-131.0.15.el6.x86_64.gz vmlinuz-2.6.32-131.0.15.el6.x86_64 # Go To The grub directory and create a new grub. conf file [root @ serv01 boot] # cd grub/[root @ serv01 grub] # ll total 268-rw-r --. 1 root 30 Jul 31 device. map-rw-r --. 1 root 13396 Jul 31 00:44 e2fs _ Stage1_5-rw-r --. 1 root 12620 Jul 31 fat_stage00005-rw-r --. 1 root 11764 Jul 31 ffs_stage00005-rw-r --. 1 root 11772 Jul 31 iso9660_stage1_5-rw-r --. 1 root 13300 Jul 31 jfs_stage1_5-rw-r --. 1 root 11956 Jul 31 minix_stage1_5-rw-r --. 1 root 14444 Jul 31 reiserfs_stage1_5-rw-r --. 1 root 512 Jul 31 00:44 st Age1-rw-r --. 1 root 126040 Jul 31 00: 44stage2-rw-r --. 1 root 12040 Jul 31 ufs2_stage1_5-rw-r --. 1 root 11396 Jul 31 vstafs_stage1_5-rw-r --. 1 root 13980 Jul 31 xfs_stage00005 [root @ serv01 grub] # vim grub. conf # file content: [root @ serv01 grub] # cat grub. conf default = 0 timeout = 5 title Redhat Server 6.1 root (hd0, 0) kernel/vmlinuz-2.6.32-131.0.15.el6.x86_64 Ro root =/dev/sda2 quiet initrd/initramfs-2.6.32-131.0.15.el6.x86_64.img [root @ serv01 grub] # reboot Broadcast message from root@serv01.host.com (/dev/pts/0)... the system is going down for reboot NOW! [Root @ serv01 grub] # Connection to192.168.1.11 closed by remote host. Connection to 192.168.1.11 closed. # restart and reconnect. The Connection is successful. OK! [Root @ larrywen Desktop] # ssh 192.168.1.11 root@192.168.1.11's password: Last login: Wed Jul 31 00:43:50 2013 from192.168.1.1 [root @ serv01 ~] #

Related Article

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.