Linux】linux系统boot目录误删了怎么恢复

2021-03-17 11:18发布

4条回答
爱学习的小巴
1楼 · 2021-03-19 15:59.采纳回答

(1)重启机器,用光盘或USB引导进入救援模式的shell

(2) 查看硬盘信息,找出/boot分区和根分区

(3)找到根分区之后就可以重新写/etc/fstab文件了

(4)重新进入救援模式的shell

(5)修复grub

修复完grub之后,重启!

小橘子
2楼 · 2021-03-17 14:39

无法引导与你没分boot分区没有关系。把grub安装在linux的根分区上,然后用引导盘进入系统通过:dd if=/dev/hdx of=/boot.sec bs=512 count=1 之后用usb盘或paragon partition manager把boot.sec拷出即可用nt的引导程序引导linux

水默
3楼 · 2021-03-17 15:00

linux系统中的/boot目录存放着系统开机所需要的各种文件,其中包含内核、开机菜单及所需配置文件等等。

但是当不小心删除了/boot目录里的某些文件或者干脆整个/boot目录都不见了的情况下,该如何恢复系统并重启系统呢,

以下通过加载磁盘镜像文件以重装内核与grub2加载器的方式可解决这个问题,只是过程有点复杂...


我的网名不再改
4楼 · 2021-12-15 16:14

同事误操作删除了/bin和/boot分区,/bin目录没有了,/boot目录下面为空,导致.net527.cn/index.html'>系统命令不能正常使用,也不敢重新启动.net527.cn/index.html'>系统命令不能正常使用,也不敢重新启动.net527.cn/index.html'>系统命令不能正常使用,也不敢重新启动.net527.cn/index.html'>系统命令不能正常使用,也不敢重新启动.net527.cn/index.html'>系统,还有业务系统在跑。

解决思路:

1、找一台操作系统环境相同的机器,拷贝目录到该机器。

2、估计的重新安装内核,因为找不到内核映射了。

详细解决步骤如下:

1、重新启动机器,插入光盘,进入带网络环境的救援模式。

2、把另外一个系统的bin目录的压缩包拷贝过来,然后解压。

3、因为系统内核丢失了,所以我们需要先安装内核,在安装内核时会自动生成initrd

a、cd /mnt/

b、mkdir cd

c、mount -t iso9660 -o ro /dev/hda /mnt/cd/  (注意,使用dmesg命令详细查看光驱挂载的设备,我的是/dev/hda)

d、rpm -Uvh --force kernel-2.6.18-164.el5.i686.rpm

4、安装grub

a、grup-install /dev/sda

5、编辑grub.conf

# grub.conf generated by anaconda

#

# Note that you do not have to rerun grub after making changes to this file

# NOTICE:  You have a /boot partition.  This means that

#          all kernel and initrd paths are relative to /boot/, eg.

#          root (hd0,0)

#          kernel /vmlinuz-version ro root=/dev/sda7

#          initrd /initrd-version.img

#boot=/dev/sda

default=0

timeout=5

splashimage=(hd0,0)/grub/splash.xpm.gz

hiddenmenu

title CentOS (2.6.18-164.el5)

root (hd0,0)

kernel /vmlinuz-2.6.18-164.el5 ro root=LABEL=/dev/VolGroup00/LogVol00 rhgb quiet

initrd /initrd-2.6.18-164.el5.img

注意,如果你是逻辑卷需要修改根目录的标签,我的是逻辑卷。

6,重新启动系统

重新启动系统未成功,出现以下错误:

mount: could not find filesystem '/dev/root'

setuproot: moving /dev failed: No such file or directory

setuproot: error mounting /proc: No such file or directory

setuproot: error mounting /sys: No such file or directory

switchroot: mount failed: No such file or directory

Kernel panic - not syncing: Attempted to kill init!

经过搜索后,发现此类问题多集中在逻辑卷管理的情况,具体原因是我们在重新安装内核的时候,没有加载一些逻辑卷,解决方法如下:

1) Boot with the rescue CD

2) Type 'chroot /mnt/sysimage'

3) 'cd /boot'

4) 'mkdir newinit'

5) 'cd newinit'

6) 'gunzip -c ../initrd-2.6.18-164.el5.img | cpio -idmv'

7) 'vi init'

8) Find 'mount /sysroot'

9) Delete or comment this out

10) Replace with 'mount -o defaults --ro -t ext3

/dev/VolGroup00/LogVol00 /sysroot' where /dev/VolGroup00/LogVol00 is

the mount point for /

11) ':wq' out of vi

12) 'find . | cpio --quiet -c -o >../newinitrd'

13) 'cd ..' - you are now in /boot

14) 'mv initrd-2.6.18-164.el5.img initrd-2.6.18-164.el5.img.bak' - backup current initrd img file

15) 'gzip -9 < newinitrd> initrd-2.6.18-164.el5.img'

16) Reboot the computer without the CD

再次重新启动系统,OK,问题解决。

7、 尝试进行远程连接,因为远程服务器不允许root直接连接,可以用普通用户进行登录,登录后执行 su - root

命令,输入密码总是提示密码错误,但是在终端直接用root是可以登录的,奇怪,后来发现问题出在 su

命令上,是文件权限粘贴位的问题,因为拷贝过来的su命令权限如下:

[root@localhost ~]# ll /bin/su

-rwxr-xr-x 1 root root 23960 Oct 18 21:46 /bin/su

正确如下:

[root@localhost ~]# ll /bin/su

-rwsr-xr-x 1 root root 23960 Oct 18 21:46 /bin/su

这样就简单了,设置粘贴位如下:

[root@localhost ~]# chmod u+s mount

除了su命令外,还有另外几个需要设置粘贴位,mount,ping,ping6,traceroute,traceroute6,umount。

另外还要注意一些软连接。


回答: 2021-12-15 16:15

同事误操作删除了/bin和/boot分区,/bin目录没有了,/boot目录下面为空,导致.net527.cn/index.html'>系统命令不能正常使用,也不敢重新启动.net527.cn/index.html'>系统命令不能正常使用,也不敢重新启动.net527.cn/index.html'>系统命令不能正常使用,也不敢重新启动.net527.cn/index.html'>系统命令不能正常使用,也不敢重新启动.net527.cn/index.html'>系统,还有业务系统在跑。

解决思路:

1、找一台操作系统环境相同的机器,拷贝目录到该机器。

2、估计的重新安装内核,因为找不到内核映射了。

详细解决步骤如下:

1、重新启动机器,插入光盘,进入带网络环境的救援模式。

2、把另外一个系统的bin目录的压缩包拷贝过来,然后解压。

3、因为系统内核丢失了,所以我们需要先安装内核,在安装内核时会自动生成initrd

a、cd /mnt/

b、mkdir cd

c、mount -t iso9660 -o ro /dev/hda /mnt/cd/  (注意,使用dmesg命令详细查看光驱挂载的设备,我的是/dev/hda)

d、rpm -Uvh --force kernel-2.6.18-164.el5.i686.rpm

4、安装grub

a、grup-install /dev/sda

5、编辑grub.conf

# grub.conf generated by anaconda

#

# Note that you do not have to rerun grub after making changes to this file

# NOTICE:  You have a /boot partition.  This means that

#          all kernel and initrd paths are relative to /boot/, eg.

#          root (hd0,0)

#          kernel /vmlinuz-version ro root=/dev/sda7

#          initrd /initrd-version.img

#boot=/dev/sda

default=0

timeout=5

splashimage=(hd0,0)/grub/splash.xpm.gz

hiddenmenu

title CentOS (2.6.18-164.el5)

root (hd0,0)

kernel /vmlinuz-2.6.18-164.el5 ro root=LABEL=/dev/VolGroup00/LogVol00 rhgb quiet

initrd /initrd-2.6.18-164.el5.img

注意,如果你是逻辑卷需要修改根目录的标签,我的是逻辑卷。

6,重新启动系统

重新启动系统未成功,出现以下错误:

mount: could not find filesystem '/dev/root'

setuproot: moving /dev failed: No such file or directory

setuproot: error mounting /proc: No such file or directory

setuproot: error mounting /sys: No such file or directory

switchroot: mount failed: No such file or directory

Kernel panic - not syncing: Attempted to kill init!

经过搜索后,发现此类问题多集中在逻辑卷管理的情况,具体原因是我们在重新安装内核的时候,没有加载一些逻辑卷,解决方法如下:

1) Boot with the rescue CD

2) Type 'chroot /mnt/sysimage'

3) 'cd /boot'

4) 'mkdir newinit'

5) 'cd newinit'

6) 'gunzip -c ../initrd-2.6.18-164.el5.img | cpio -idmv'

7) 'vi init'

8) Find 'mount /sysroot'

9) Delete or comment this out

10) Replace with 'mount -o defaults --ro -t ext3

/dev/VolGroup00/LogVol00 /sysroot' where /dev/VolGroup00/LogVol00 is

the mount point for /

11) ':wq' out of vi

12) 'find . | cpio --quiet -c -o >../newinitrd'

13) 'cd ..' - you are now in /boot

14) 'mv initrd-2.6.18-164.el5.img initrd-2.6.18-164.el5.img.bak' - backup current initrd img file

15) 'gzip -9 < newinitrd> initrd-2.6.18-164.el5.img'

16) Reboot the computer without the CD

再次重新启动系统,OK,问题解决。

7、 尝试进行远程连接,因为远程服务器不允许root直接连接,可以用普通用户进行登录,登录后执行 su - root

命令,输入密码总是提示密码错误,但是在终端直接用root是可以登录的,奇怪,后来发现问题出在 su

命令上,是文件权限粘贴位的问题,因为拷贝过来的su命令权限如下:

[root@localhost ~]# ll /bin/su

-rwxr-xr-x 1 root root 23960 Oct 18 21:46 /bin/su

正确如下:

[root@localhost ~]# ll /bin/su

-rwsr-xr-x 1 root root 23960 Oct 18 21:46 /bin/su

这样就简单了,设置粘贴位如下:

[root@localhost ~]# chmod u+s mount

除了su命令外,还有另外几个需要设置粘贴位,mount,ping,ping6,traceroute,traceroute6,umount。

另外还要注意一些软连接。


相关问题推荐

  • 回答 7

    使用命令:chmod 744 myflile就可以实现以上的操作。

  • 回答 4

    关于CLOSE_WAIT和TIME_WAIT状态,服务器端都有可能出现,TIME_WAIT出现应该是短连接较多,需要通过修改内核参数解决,CLOSE_WAIT状态则是服务器程序可能有问题,服务器需要主动close,以及epoll多路复用模型中使用linger调整关闭等待时间分析解决这类问题,关...

  • 回答 6
    已采纳

    chmod 命令:chmod命令是非常重要的,用于改变文件或目录的访问权限。用户用它控制文件或目录的访问权限。该命令有两种用法。一种是包含字母和操作符表达式的文字设定法;另一种是包含数字的数字设定法。1. 文字设定法:chmod [who] [+ | - | =] ...

  • 回答 3
    已采纳

    Linux chattr 命令一般,chattr命令用于更改Linux文件上属性。以下是它的语法:chattr [ -RVf ] [ -v version ] [ mode ] files...下面是man手册对它的描述:chattr 改变一个Linux文件系统上的文件属性。一个通用格式是:+-=[aAcCdDeijsStTu]‘+’选项,将给...

  • 回答 8
    已采纳

    命令格式cat [选项] [文件]...命令功能cat主要有三大功能:一次显示整个文件:cat filename从键盘创建一个文件:cat > filename 只能创建新文件,不能编辑已有文件.将几个文件合并为一个文件:cat file1 file2 > file命令参数-n 或 --number 对输出的所有行编号,...

  • 回答 3

    shell的执行过程: 首先,脚本是从上至下从左至右执行每一行的语句的。 其次,当执行脚本时会进入一个新的shell,也成为nologin shell,在该shell下执行完成后,再返回执行前的shell。更加详细的讲解请楼主参考鸟哥linux网站中的bash shell章节有图能让您更...

  • 回答 3

    学习linux为什么要学习Shell: 1、首先我们了解一下shell编程是什么,其实shell编程就是一坨linux命令的集合再加上一些控制语句而已 2、为什么要学习linux下的shell编程,我们平时在做运维工作时总会遇到一些重复的工作,如果我们会shell编程的话就可以将这些...

  • 回答 6

    1.服务器一般情况下只有在进行项目部署或者是出现问题的时候才需要进行远程连接操作,在进行连接的时候我们一般都是使用的外部连接软件2.启动软件,点击快速连接,我们要选择连接的协议3.协议选择要然后填写服务器的IP地址和用户名,然后点击连接4.在通过验证...

  • 回答 4

    看看系统内存是否足够多,然后分区的时候是否正常运行

  • 回答 5

    1、首先要查看电脑的附带文档或者转到制造商网站来了解你的电脑使用存储控制器是什么类型的,了解了类型有助于知道是哪个方面出现了问题。2、然后在另一台电脑上同样是转到制造商的网站,将最新的驱动程序下载下来,并且保存在usb闪存驱动器或者是别的可以移...

  • 回答 7

    1、切换到root用户后。2、键入vim /etc/inittab, 就可以查看并修改该配置文件。3、在输入上面的命令后,我们可以看到该配置文件里面的信息如下:4、注意最后的那几行,就是Linux系统默认启动有七种。0:关机(不要设置这个!)1:单用户(类似于windows操作系统...

  • 回答 5
    已采纳

    很多朋友经常会忘记Linux系统的root密码,linux系统忘记root密码的情况该怎么办呢?重新安装系统吗?当然不用!进入单用户模式更改一下root密码即可。步骤如下:重启linux系统重启系统后出现GRUB界面在引导装载程序菜单上,按 E出现内核选择 ,选择第二行 ...

  • 回答 6

    1.正确的关机流程为:sysnc ? shutdown ? reboot ? halt;2.sync 将数据由内存同步到硬盘中。3.shutdown 关机指令,你可以man shutdown 来看一下帮助文档。例如你可以运行如下命令关机:4.shutdown –h 10 ‘This server will shutdown after 10 mins’ ...

  • 回答 2

    1、LPIC,全称Linux专业委员会认证2、Oracle联合认证(OCA)3、Oracle专业认证(OCP)4、RHCE,也叫做红帽认证工程师5、RHCA即红帽认证架构师6、SUSE认证Linux管理员(SUSE CLA)7、SUSE认证Linux专业人员(CLP)8、SUSE认证Linux工程师(CLE)...

  • 回答 15
    已采纳

    1、cd命令这是一个非常基本,也是大家经常需要使用的命令,它用于切换当前目录,它的参数是要切换到的目录的路径,可以是绝对路径,也可以是相对路径。如:cd /root/Docements # 切换到目录/root/Docementscd ./path          # 切换到当前目录下的path...

  • 回答 7
    已采纳

    目录/bin存放二进制可执行文件(ls,cat,mkdir等),常用命令一般都在这里。/etc存放系统管理和配置文件/home存放所有用户文件的根目录,是用户主目录的基点,比如用户user的主目录就是/home/user,可以用~user表示 /usr用于存放系统应用程序,比较重要的目录/u...

没有解决我的问题,去提问