红联Linux门户
Linux协助

运用fedora的live-rescure形式康复体系

发布时刻:2017-02-28 11:49:03来历:linux网站作者:k7arm
原因:
之前由于操作不妥,运用体系root权限修正了/lib64/libz.so.1的文件名为/lib64/libz.sozw.1 ,导致了之后无法运用sudo,su等之类的需求动态加载体系库的指令,更严峻的是从头发动虚拟机后直接卡在了体系初始化里,无法再次进入体系了。
 
剖析:
由于是修正了/lib64/libz.so.1的姓名引起了这个问题,再把这个文件的姓名康复回去应该就能够正常进入体系了。
详细了解一下,运用ls -al 检查 /lib64/libz.so.1:
lrwxrwxrwx. 1 root root 13 Sep  8  2015 /lib64/libz.so.1 -> libz.so.1.2.8
其实它是一个符号链接,指向/lib64/libz.so.1.2.8
 
操作:
运用硬盘上的fedora23镜像现已无法完结初始化进入体系了,那就需求运用其他的办法引导进入体系,然后康复回/lib64/libz.sozw.1的文件名。
运用的办法是用下载与硬盘版镜像对应的iso文件,然后运用u盘或光驱加载该iso文件,进入live-rescure形式。留意,在操作时不要选中 install to driver,这是从头装置体系了,会掩盖之前的体系文件。
以下为详细的操作。
首先把非体系盘卸载掉。我是从win的虚拟机装备里操作的,避免误操作损坏硬盘文件。
然后检查一下当时体系的挂载状况:
[liveuser@localhost ~]$ sudo fdisk -l
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
Disk /dev/sda: 40 GiB, 42949672960 bytes, 83886080 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xd1e562e0
Device     Boot    Start      End  Sectors  Size Id Type
/dev/sda1  *        2048  1026047  1024000  500M 83 Linux
/dev/sda2        1026048 41943039 40916992 19.5G 8e Linux LVM
/dev/sda3       41943040 83886079 41943040   20G 8e Linux LVM
Disk /dev/loop0: 12 KiB, 12288 bytes, 24 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/loop1: 1.8 MiB, 1888256 bytes, 3688 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/loop2: 1.3 GiB, 1387098112 bytes, 2709176 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/loop3: 6 GiB, 6442450944 bytes, 12582912 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/loop4: 512 MiB, 536870912 bytes, 1048576 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/live-rw: 6 GiB, 6442450944 bytes, 12582912 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/live-base: 6 GiB, 6442450944 bytes, 12582912 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/live-osimg-min: 6 GiB, 6442450944 bytes, 12582912 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/fedora-swap: 2 GiB, 2147483648 bytes, 4194304 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/fedora-root: 37.5 GiB, 40269512704 bytes, 78651392 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
能够看见有一个sda的硬盘,我在之前装置时区分的分区是/dev/sda1为swap,/dev/sda2为root,/dev/sda3为后来扩展给root运用的。在上面的成果中能够看到。
Device     Boot    Start      End  Sectors  Size Id Type
/dev/sda1  *        2048  1026047  1024000  500M 83 Linux
/dev/sda2        1026048 41943039 40916992 19.5G 8e Linux LVM
/dev/sda3       41943040 83886079 41943040   20G 8e Linux LVM
现在要做的便是把/dev/sda2 挂载到/mnt中去。可是由于它的文件体系为LVM而不是ext4/ext3/ext2之类的文件体系,所以不能直接运用mount /dev/sda2 /mnt这样的操作,这样无法挂载。
LVM是 Logical Volume Manager(逻辑卷办理)的简写,它是Linux环境下对磁盘分区进行办理的一种机制。能够当作它是建立在ext4/ext3/ext2等这些文件体系之上更高一层的文件体系,这么做的实际意义便是能够把一个文件跨分区寄存,即文件的一部分存在/dev/sda2上面,剩余的一部分存在/dev/sda3上。而关于用户来说,就要运用卷组这个概念来定位文件了,每个卷组都有自己的卷组名,这能够通道vgscan指令来检查当个前的体系都有哪些卷组。所以此刻就不能再说文件1在/dev/sda2上了,由于有或许还有一部分文件在/dev/sda3上。
此刻履行扫描的成果为:
[liveuser@localhost ~]$ sudo vgscan
Reading all physical volumes.  This may take a while...
Found volume group "fedora" using metadata type lvm2
[liveuser@localhost ~]$
即体系中只要一个卷组,名为fedora。
下面要做的便是激活这个卷组,然后再挂载它到目录中,就能够读写了。
[liveuser@localhost ~]$ sudo vgchange -a y fedora
2 logical volume(s) in volume group "fedora" now active
[liveuser@localhost ~]$ 
能够看到,激活后的成果显现这个卷组中有2个卷。
下面开端挂载。
我测验将整个卷组挂载到/dev/sda目录下,可是失利了,它提示/dev/fedora这个途径不是指向一个块设备。
[liveuser@localhost ~]$ sudo mount /dev/fedora /mnt/sda/
mount:  /dev/fedora is not a block device
其实,能够运用ls指令检查一下/dev/fedora
[liveuser@localhost ~]$ ls /dev/fedora 
root  swap
[liveuser@localhost ~]$ 
即在它下面还有两个节点,这两个节点才是真实的block device,所以需求从头指定需求挂载的设备:
[liveuser@localhost ~]$ sudo mount /dev/fedora/root /mnt/sda/
[liveuser@localhost ~]$ ls /mnt/sda/
bin  boot  dev  etc  home  lib  lib64  lost+found  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
[liveuser@localhost ~]$ ls /mnt/sda/home/
tftpboot  zhangwei  zhumeng
[liveuser@localhost ~]$ cd /mnt/sda/
[liveuser@localhost sda]$ ls
bin  boot  dev  etc  home  lib  lib64  lost+found  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
[liveuser@localhost sda]$ ls -al
total 96
dr-xr-xr-x.  19 root root  4096 Dec 16 02:57 .
drwxr-xr-x.   3 root root  4096 Feb 27 01:45 ..
lrwxrwxrwx.   1 root root     7 Sep 10  2015 bin -> usr/bin
drwxr-xr-x.   2 root root  4096 May 16  2016 boot
drwxr-xr-x.   2 root root  4096 May 16  2016 dev
drwxrwxr-x.   4 root 1001  4096 May 22  2016 .esmtp_queue
drwxr-xr-x. 151 root root 12288 Feb 23 20:42 etc
drwxr-xr-x.   5 root root  4096 May 30  2016 home
lrwxrwxrwx.   1 root root     7 Sep 10  2015 lib -> usr/lib
lrwxrwxrwx.   1 root root     9 Sep 10  2015 lib64 -> usr/lib64
drwx------.   2 root root 16384 Oct 29  2015 lost+found
drwxr-xr-x.   2 root root  4096 Sep 10  2015 media
drwxr-xr-x.   3 root root  4096 May 19  2016 mnt
drwxr-xr-x.   2 root root  4096 Sep 10  2015 opt
drwxr-xr-x.   2 root root  4096 May 16  2016 proc
dr-xr-x---.   6 root root  4096 Dec 16 02:58 root
drwxr-xr-x.   2 root root  4096 May 16  2016 run
lrwxrwxrwx.   1 root root     8 Sep 10  2015 sbin -> usr/sbin
drwxr-xr-x.   2 root root  4096 Sep 10  2015 srv
drwxr-xr-x.   2 root root  4096 May 16  2016 sys
drwxrwxrwt.   8 root root  4096 May 16  2016 tmp
drwxr-xr-x.  13 root root  4096 May 23  2016 usr
drwxr-xr-x.  22 root root  4096 Feb 22 08:38 var
[liveuser@localhost sda]$ ls
bin  boot  dev  etc  home  lib  lib64  lost+found  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
此刻现已挂载成功了,能够读写/dev/fedora/root对应的文件体系了。
后来我把/lib64/libz.sozw.1改为/lib64/libz.so.1之后体系就能自己发动了。
 
本文永久更新地址:http://www.138comgov138.com/linux/28776.html