Linux误删bin boot目录了,linux误删/bin目录怎么办

推荐答案

解决思路:

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。

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

辅助答案

用户:phm_2016

2017年10月24日

现在是,进系统直接到grub,没有引导,Linux手里引导盘和安装盘都有,装个虚拟机,然后拷贝bin目录过来

用户:赵涛1212

2017年12月01日

将硬盤装在其他同版本linux 并挂载

将/bin copy 回去....

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值