Linux system open Fault Troubleshooting and linux-4.16.8 kernel compilation installation

Source: Internet
Author: User
Tags md5 encryption

1. Break root password and set protection for grub

1). Enter single-user mode using the "E" button in the GRUB boot menu to enter the CentOS boot menu to the interface, move the cursor to the "kernel" configuration item line, add single,ctrl+x at the end, and go to the bash# page
2). After entering the single user mode, do not need to enter the user name and password, the system boot will be directly after the administrator root permissions, the console prompt is "#", requires the RW mount/mount-o remount RW/
3). Enter the passwd command and type the new password two times to complete the change. Crack root Password
4). vi/boot/grub/grub.conf
Password--md5 passwd #grub-crypt type two times New password to complete the generation of MD5 encryption password passwd, the next time the system enters the Grub boot requires a password to enter

2. Destroy native grub Stage1, then fix it in rescue mode

1). Reboot press ESC to boot to the rescue environment mbr446 bytes are destroyed, backup data to/DATA/MBR, DD command
2)dd if=/data/mbr of=/dev/sda1 bs=1 count=446

3, delete vmlinuz and Initramfs files can not start, two ways to restore

Reboot after pressing ESC, you can boot through the disc to enter the rescue environment

mkdir /mnt/cdrommount /dev/sr0 /mnt/cdromchroot /mnt/sysimage   #切换/mkinitrd /boot/initramfs-`uname -r`.img `uname -r `cp /mnt/cdrom/isolinux/vmlinuz  /boot/vmlinuz-`uname -r`syncsync #写入磁盘

Method Two,

mkdir /mnt/cdrommount /dev/sr0 /mnt/cdromrpm -ivh /mnt/cdrom/Packages/kernel-2.6.32-696.e16.x86_64.rpm --root=/mnt/sysimage/ --forcels /mnt/sysimage/boot
4. Add a new hard drive on which to create a system that can run kernel and bash alone
fdisk /dev/sdbmkfs.ext4 /dev/sdb1  #/dev/sdb1对应/boot /dev/sdb2对应根 /mkfs.ext4 /dev/sdb2mkdir /mnt/bootmount /dev/sdb1 /mnt/bootgrub-install --root-directory=/mnt /dev/sdbcp /boot/vmlinuz-2.6.32-642.el6.x86_64 /mnt/boot/cp /boot/initramfs-2.6.32-642.el6.x86_64.img /mnt/bootcat >> /mnt/boot/grub.conf <<EOFtitle wanglinuxroot (hd0,0)kernel /vmlinuz-2.6.32-642.el6.x86_64 root=/dev/sda2 selinux=0 init=/bin/bashinitrd /initramfs-2.6.32-642.el6.x86_64.imgEOFchroot /mnt/sysrootmkdir /mnt/sysrootmount /dev/sdb2 /mnt/sysrootmkdir –pv/mnt/sysroot/{etc,lib,lib64,bin,sbin,tmp,var,usr,sys,proc,opt,home,root,boot,dev,mnt,media}#复制bash和相关库文件#复制相关命令及相关库文件

5. Customize Linux on a USB stick to enable it to boot up the system and have network capabilities

6. Delete all files from the/etc/fstab and/boot directories and restore them
1).reboot后按下ESC,即可通过光盘引导,进入救援环境fdisk -l  #查找对应的根在那个硬盘分区mkdir /mnt/rsrootmount /dev/sda2 /mnt/rsrootcat >> /mnt/rsroot/etc/fstab <<EOF/dev/sda2  /  exrt4  defaults 0 0/dev/sda1 /boot exrt4  defaults 0 0 #临时恢复fstab文件EOFsyncexit2).恢复fstab后,reboot后按下ESC,即可通过光盘再次引导,进入救援环境mkdir /mnt/cdrommount /dev/sr0 /mnt/cdromrpm -ivh /mnt/cdrom/Packages/kernel-2.6.32-696.e16.x86_64.rpm --root=/mnt/sysimage/ --forcels /mnt/sysimage/bootchroot /mnt/sysimage #切根/grub-install -- /dev/sdacat > /boot/grub.confdefault=0timmeout=5title linux    root(hd0,0)    kernel /vmlinuz-2.6.32-696.el6.x86_64 ro root=/dev/sda3    initrd /initramfs-2.6.32-696.el6.x86_64.img

Ps:/boot/grub configuration file: In addition to grub.conf, splash.xpm.gz, the system is clean, the other files can not exist; 2. After Grub-install, all files are related to startup and cannot be destroyed.

7. Compile and install kernel to enable the NTFS file system feature

Download LINUX-4.16.8.TAR.XZ

tar -xvf linux-4.16.8.tar.xzcd linux-4.16.8cp /boot/config-3.10.0-862.el7.x86_64 .configyum gruopinstall "Development Tools"yum install ncursesmake menuinstall  #报错的可以安装一下,yum install ncurses ,基于curses的文本窗口 ,第一次编译安装的时候,yum gruopinstall "Development Tools"#  General setup  --->  Local version - append to kernel release ---> enter,修改内核版本号相关参数#  File systems  --->   DOS/FAT/NT Filesystems  --->  NTFS file system support ,修改linux可以支持NTFS文件系统#  exti 保存make -j [#]  ##代表cpu数量,越多编译速度越快,最后大概生成10-11G文件,全部编译{#只编译某子目录中的相关代码cd /usr/src/linux#make dir/#只编译一个特定的模块cd /usr/src/linux#make dir/file.komake drivers/net/ethernet/intel/e1000/e1000.ko}make modules_install#cp 相关模块到/lib/moudulsmake install#安装bzImage为/boot/vmlinuz-VERSION-RELEASE#生成initramfs文件#编辑grub的配置文件make clean #清理大多数编译生成的文件,但会保留config文件等make mrproper #:清理所有编译生成的文件、config及某些备份文件make distclean #mrproper、patches以及编辑器备份文件reboot #开始新内核之旅吧

Linux system open Fault Troubleshooting and linux-4.16.8 kernel compilation installation

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.