linux系统排错

 

系统排错

一、MBR主导分区损坏

 1.可覆盖掉虚拟机的主导分区

 

   dd if=/dev/zero of=/dev/vda bs=446 count=1

   此时系统将无法正常开机

 2.根据虚拟机版本添加光驱(如7.0的系统光驱为7.0版本的镜像)

 

 3.开机模式中选择修复选项  ##注意:光驱启动

 

   进入系统后,打开shell  chroot  /mnt/sysimage
   查看boot程序所在分区  df

 

   安装主导分区的程序  grub2-install /dev/xda

 

   安装完成后,以虚拟硬盘驱动开机即可(注意镜像版本,不同版本安装步骤不同)
   
二、文件引导损坏

  1.boot分区的引导文件  /boot/grub2/grub.cfg
   引导文件指定了boor分区的位置;加载内核;启动系统初始化进程  
set root='hd0,msdos1'
linux16 /boot/vmlinuz-3.10.0-123.el7.x86_64 ro root=/dev/vda1

 

initrd16 /boot/initramfs-3.10.0-123.el7.x86_64.img


  2.若不小心删除,可通过命令自动创建  
   grub2-mkconfig > /boot/grub2/grub.cfg
[root@localhost grub2]# grub2-mkconfig > /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-123.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-123.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-946cb0e817ea4adb916183df8c4fc817
Found initrd image: /boot/initramfs-0-rescue-946cb0e817ea4adb916183df8c4fc817.img

 

done

 

 

  

 

  3.若系统没有该文件(rm -fr /boot/grub2/grub.cfg  手动删除该文件),启动时须手动引导

(注意:此实验重起虚拟机引导启动直接从硬盘启动,不用从光驱启动)

 

grub > set root='hd0,msdos1'
grub > linux16 /boot/vmlinuz-3.10.0-123.el7.x86_64 ro root=/dev/vda1

 

grub > initrd16 /boot/initramfs-3.10.0-123.el7.x86_64.img

grub > boot

 

 

 

三、内核引导文件损坏  vmlinuz

 

(手动删除内核引导文件)


  1.内核引导文件vmlinuz
    检测硬件设备;设备驱动初始化;将/只读挂载;载入初始进程 systemd
  2.内核文件损坏,则无法正常开机,须重新安装内核软件
  3.开机模式中选择修复选项  ##注意:光驱启动
    进入系统后,打开shell  chroot  /mnt/sysimage
    挂载光驱  mount /dev/sr0  /mnt
    将光驱中内核软件拷贝至指定目录下
    mkdir /kernel

 

    cp /mnt/Packages/kernel-3.10.0-123.el7.x86_64.rpm /kernel

 

 

    解开kernel,得到所需的内核引导软件
    rpm2cpio  kernel-3.10.0-123.el7.x86_64.rpm | cpio -id
    cp ./boot/vmlinuz-3.10.0-123.el7.x86_64  /boot

 

    查看/boot分区文件是否完整,ok后以虚拟硬盘驱动开机即可


四、img文件损坏
   

 

  1.若不小心删除,可通过命令自动创建

 

  2.img文件损坏后,无法正常开机,须重新建立img文件

 

  3.开机模式中选择修复选项  ##注意:光驱启动
    进入系统后,打开shell  chroot  /mnt/sysimage
    在/boot目录下自动建立文件  mkinitrd /boot/initramfs-`uname -r`.img `uname -r`

 

    ##uname -r 系统内核版本:3.10.0-123.el7.x86_64

 

 

    查看/boot分区文件是否完整,ok后以虚拟硬盘驱动开机即可

五、systemd初始化
  
  1.systemd初始化目录 /etc/systemd/system/multi-user.target.wants/
    开启selinux和systemd-tools;加载内核参数;加载系统时钟,键盘,主机名称
    读写挂载/文件系统;激活raid,lvm设备;激活系统配额;
    启动/etc/systemd/system/multi-user.target.wants/中所有脚本
    启用虚拟控台;启动图形;

  2.若系统故障,开机自动关机
    重启时按上下键,停止系统引导
    开机时按e,在内核引导时设置图形化界面开启
    正常开启后,修改systemd初始化默认参数,即可修复
    systemctl set-default graphical.target

六、root用户密码修改
 
   ###root用户密码被更改或忘记
   1.重启时按上下键,停止系统引导
   2.按e,在内核引导时找到指定行linux16,从最后往前删除至ro
    修改ro=rw rd.break

 

   3.ctrl + x 启动修改设定后的系统引导

 

   4.进入系统后切换到真实系统环境,修改root密码
    chroot /sysroot
    passwd
   5.建立文件 /.autorelabel 
    ##当selinux关闭时,可不建立该文件;但当selinux开启时,必须建立该文件
    建议:重启时默认执行此命令

 

   6.输入2次exit退出、重新启动

 

 

 

排错

02-27

报错和程序如下,没改好,大家帮着看看,谢谢!rnrn--------------------Configuration: j2sdk1.4.2_03 --------------------rnC:\j2sdk1.4.2_03\mycode\ThreadTest\Counter2.java:48: actionPerformed(java.awt.event.ActionEvent) in cannot implement actionPerformed(java.awt.event.ActionEvent) in java.awt.event.ActionListener; attempting to assign weaker access privileges; was publicrn void actionPerformed(ActionEvent e)rn ^rnC:\j2sdk1.4.2_03\mycode\ThreadTest\Counter2.java:61: actionPerformed(java.awt.event.ActionEvent) in cannot implement actionPerformed(java.awt.event.ActionEvent) in java.awt.event.ActionListener; attempting to assign weaker access privileges; was publicrn void actionPerformed(ActionEvent e)rn ^rn2 errorsrn------------------------------------------------------------------------rnrnimport java.awt.*;rnimport java.awt.event.*;rnimport javax.swing.*;rn//import java.applet.*;rnrnrnpublic class Counter2rnrn public static void main(String[] args)rn rn Counter2Frame frame = new Counter2Frame();rn frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);rn frame.show();rn rnrnrnrnclass Counter2Frame extends JFramernrn public Counter2Frame()rn rn Counter2Panel panel = new Counter2Panel();rn getContentPane().add(panel);rn rn setTitle("ThreadTest2");rn setSize(300,200);rn rn rnrnrnrnclass Counter2Panel extends JPanelrnrn private JTextField text;rn private JButton on;rn private JButton off;rn private SubThread t1;rn rn public Counter2Panel()rn rn setLayout(new BorderLayout());rn text = new JTextField(30);rn add(text,BorderLayout.CENTER);rn rn on = new JButton("start");rn on.addActionListener(newrn ActionListener()rn void actionPerformed(ActionEvent e)rn rn if (t1 == null)rn rn t1 = new SubThread();rn t1.start(); rn rn rn rn );rn off = new JButton("stop");rn off.addActionListener(newrn ActionListener()rn void actionPerformed(ActionEvent e)rn rn if(!(t1 == null))rn t1.invertFlag(); rn rn rn );rn rn JPanel buttonPanel = new JPanel();rn buttonPanel.add(on);rn rn buttonPanel.add(off);rn add(buttonPanel,BorderLayout.SOUTH); rn rn rn private class SubThread extends Threadrn rn private int counter =0;rn private boolean runFlag = true;rn rn public void run()rn rn while(true)rn rn tryrn sleep(100);rn rn catch(InterruptedException e) rn rn if(runFlag)rn rn text.setText(Integer.toString(++counter)); rn rn rn rn rn public void invertFlag() runFlag = !runFlag;rnrn rn rn rnrn-------------------------------------------------------------------------rnrnrn

排错~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

02-15

using System;rnusing System.Data;rnusing System.Data.SqlClient;rnusing System.Configuration;rnusing System.Collections;rnusing System.Web;rnusing System.Web.Security;rnusing System.Web.UI;rnusing System.Web.UI.WebControls;rnusing System.Web.UI.WebControls.WebParts;rnusing System.Web.UI.HtmlControls;rnrnpublic partial class Invoice_Add : System.Web.UI.Pagernrn protected void Page_Load(object sender, EventArgs e)rn rnrn rnrn protected void Button1_Click(object sender, EventArgs e)rn rnrn //防止外部数据提交的脚本 rn string sHttp = Request.Headers["referer"];rn string sServer = Request.Headers["host"];rn if (sServer.Equals(sHttp.Substring(7, sServer.Length)) == false)rn rn Response.Write(" ");rn return;rn rnrn SqlConnection myConnection = new SqlConnection("Data Source=Localhost;Initial Catalog=RCMS;User ID=sa;Password=yxgxgs;");rn myConnection.Open();rnrn SqlTransaction myTrans = myConnection.BeginTransaction(); //使用New新生成一个事务rn SqlCommand myCommand = new SqlCommand();rn myCommand.Transaction = myTrans;rnrn string InvoiceIDG = InvoiceID.Text;rnrn string GoodsNameA = GoodsName1.Text;rn string UnitPriceA = UnitPrice1.Text;rn string UnitA = Unit1.Text;rn string QuantityA = Quantity1.Text;rn string UnitCTA = UnitCT1.Text;rn string CostTypeA = CostType1.Text;rn string AmountCTA = AmountCT1.Text;rn string AmountA = Amount1.Text;rnrn string GoodsNameB = GoodsName2.Text;rn string UnitPriceB = UnitPrice2.Text;rn string UnitB = Unit2.Text;rn string QuantityB = Quantity2.Text;rn string UnitCTB = UnitCT2.Text;rn string CostTypeB = CostType2.Text;rn string AmountCTB = AmountCT2.Text;rn string AmountB = Amount2.Text;rnrn string GoodsNameC = GoodsName3.Text;rn string UnitPriceC = UnitPrice3.Text;rn string UnitC = Unit3.Text;rn string QuantityC = Quantity3.Text;rn string UnitCTC = UnitCT3.Text;rn string CostTypeC = CostType3.Text;rn string AmountCTC = AmountCT3.Text;rn string AmountC = Amount3.Text;rnrn string GoodsNameD = GoodsName4.Text;rn string UnitPriceD = UnitPrice4.Text;rn string UnitD = Unit4.Text;rn string QuantityD = Quantity4.Text;rn string UnitCTD = UnitCT4.Text;rn string CostTypeD = CostType4.Text;rn string AmountCTD = AmountCT4.Text;rn string AmountD = Amount4.Text;rnrn string GoodsNameE = GoodsName5.Text;rn string UnitPriceE = UnitPrice5.Text;rn string UnitE = Unit5.Text;rn string QuantityE = Quantity5.Text;rn string UnitCTE = UnitCT5.Text;rn string CostTypeE = CostType5.Text;rn string AmountCTE = AmountCT5.Text;rn string AmountE = Amount5.Text;rnrn string GoodsNameF = GoodsName6.Text;rn string UnitPriceF = UnitPrice6.Text;rn string UnitF = Unit6.Text;rn string QuantityF = Quantity6.Text;rn string UnitCTF = UnitCT6.Text;rn string CostTypeF = CostType6.Text;rn string AmountCTF = AmountCT6.Text;rn string AmountF = Amount6.Text;rnrn tryrn rnrn AddSource1.Insert();rnrn myCommand.CommandText = "INSERT INTO [Invoice_Detail] ([InvoiceID], [GoodsName], [UnitPrice], [Unit], [Quantity], [UnitCT], [CostType], [AmountCT], [Amount], [NBBH]) VALUES ('" + InvoiceIDG + "', '" + GoodsNameA + "', '" + UnitPriceA + "', '" + UnitA + "', '" + QuantityA + "', '" + UnitCTA + "', '" + CostTypeA + "', '" + AmountCTA + "', '" + AmountA + "')";rn myCommand.ExecuteNonQuery();rn myCommand.CommandText = "INSERT INTO [Invoice_Detail] ([InvoiceID], [GoodsName], [UnitPrice], [Unit], [Quantity], [UnitCT], [CostType], [AmountCT], [Amount], [NBBH]) VALUES ('" + InvoiceIDG + "', '" + GoodsNameB + "', '" + UnitPriceB + "', '" + UnitB + "', '" + QuantityB + "', '" + UnitCTB + "', '" + CostTypeB + "', '" + AmountCTB + "', '" + AmountB + "')";rn myCommand.ExecuteNonQuery();rn myCommand.CommandText = "INSERT INTO [Invoice_Detail] ([InvoiceID], [GoodsName], [UnitPrice], [Unit], [Quantity], [UnitCT], [CostType], [AmountCT], [Amount], [NBBH]) VALUES ('" + InvoiceIDG + "', '" + GoodsNameC + "', '" + UnitPriceC + "', '" + UnitC + "', '" + QuantityC + "', '" + UnitCTC + "', '" + CostTypeC + "', '" + AmountCTC + "', '" + AmountC + "')";rn myCommand.ExecuteNonQuery();rn myCommand.CommandText = "INSERT INTO [Invoice_Detail] ([InvoiceID], [GoodsName], [UnitPrice], [Unit], [Quantity], [UnitCT], [CostType], [AmountCT], [Amount], [NBBH]) VALUES ('" + InvoiceIDG + "', '" + GoodsNameD + "', '" + UnitPriceD + "', '" + UnitD + "', '" + QuantityD + "', '" + UnitCTD + "', '" + CostTypeD + "', '" + AmountCTD + "', '" + AmountD + "')";rn myCommand.ExecuteNonQuery();rn myCommand.CommandText = "INSERT INTO [Invoice_Detail] ([InvoiceID], [GoodsName], [UnitPrice], [Unit], [Quantity], [UnitCT], [CostType], [AmountCT], [Amount], [NBBH]) VALUES ('" + InvoiceIDG + "', '" + GoodsNameE + "', '" + UnitPriceE + "', '" + UnitE + "', '" + QuantityE + "', '" + UnitCTE + "', '" + CostTypeE + "', '" + AmountCTE + "', '" + AmountE + "')";rn myCommand.ExecuteNonQuery();rn myCommand.CommandText = "INSERT INTO [Invoice_Detail] ([InvoiceID], [GoodsName], [UnitPrice], [Unit], [Quantity], [UnitCT], [CostType], [AmountCT], [Amount], [NBBH]) VALUES ('" + InvoiceIDG + "', '" + GoodsNameF + "', '" + UnitPriceF + "', '" + UnitF + "', '" + QuantityF + "', '" + UnitCTF + "', '" + CostTypeF + "', '" + AmountCTF + "', '" + AmountF + "')";rn myCommand.ExecuteNonQuery();rnrn myTrans.Commit();rnrn rn catch (Exception ex)rn rn myTrans.Rollback();rn Response.Write(" ");rn rn finallyrn rn myConnection.Close();rn Response.Write(" ");rn rn rn rn rn

没有更多推荐了,返回首页

私密
私密原因:
请选择设置私密原因
  • 广告
  • 抄袭
  • 版权
  • 政治
  • 色情
  • 无意义
  • 其他
其他原因:
120
出错啦
系统繁忙,请稍后再试