最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
CentOS无法挂载lvm格式硬盘解决办法
时间:2022-11-14 22:09:40 编辑:袖梨 来源:一聚教程网
使用 pvs 查看显示如下:
代码如下 | 复制代码 |
[root@localhost ~]# pvs PV VG Fmt Attr PSize PFree /dev/sda2 VolGroup00 lvm2 a- 372.50G 0 /dev/sdb2 VolGroup00 lvm2 a- 136.62G 0 |
发现可以正确认别到两个VG,但是同名,如何挂载呢?
解决办法是,将原来的VG更名,解决冲突即可挂载。
重命名格式为:vgrename VolGroup00 VolGroup01
此时会提示:
代码如下 | 复制代码 |
[root@localhost ~]# vgrename VolGroup00 VolGroup01 Found more than one VG called VolGroup00. Please supply VG uuid. |
原因是存在两个 VolGroup00,修改的方法他已经提示了要指定 VG uuid即可。
查看VG uuid的命令为:
代码如下 | 复制代码 |
[root@localhost ~]# vgs -v Finding all volume groups Finding volume group "VolGroup00" Finding volume group "VolGroup00" VG Attr Ext #PV #LV #SN VSize VFree VG UUID VolGroup00 wz--n- 32.00M 120372.50G 0 dcHa6G-abU2-Xfq8-EPBm-jBLj-sf18-O5uH0U VolGroup00 wz--n- 32.00M 120136.62G 0 OF8g7h-PQJB-9D9z-yPxn-1kfY-Advq-YbNHJ9 |
查到VG uuid以后,再次执行改名:
代码如下 | 复制代码 |
[root@localhost ~]# vgrename OF8g7h-PQJB-9D9z-yPxn-1kfY-Advq-YbNHJ9 VolGroup01 Volume group "VolGroup00" still has active LVs |
修改成功以后,再执行:lvscan
代码如下 | 复制代码 |
[root@localhost ~]# lvscan inactive '/dev/VolGroup01/LogVol00' [130.84 GB] inherit inactive '/dev/VolGroup01/LogVol01' [1.94 GB] inherit ACTIVE '/dev/VolGroup00/LogVol00' [367.09 GB] inherit ACTIVE '/dev/VolGroup00/LogVol01' [5.41 GB] inherit |
可以看到新修改的VolGroup01是inactive状态。
再使用vgchange 加载 VolGroup01
代码如下 | 复制代码 |
[root@localhost ~]# vgchange -ay /dev/VolGroup01 2 logical volume(s) in volume group "VolGroup01" now active |
再执行 :lvscan
代码如下 | 复制代码 |
[root@localhost ~]# lvscan ACTIVE '/dev/VolGroup01/LogVol00' [134.69 GB] inherit ACTIVE '/dev/VolGroup01/LogVol01' [1.94 GB] inherit ACTIVE '/dev/VolGroup00/LogVol00' [367.09 GB] inherit ACTIVE '/dev/VolGroup00/LogVol01' [5.41 GB] inherit |
可以发现VolGroup01已经是ACTIVE状态了。
最后 mount 就可以
代码如下 | 复制代码 |
[root@localhost ~]# mount /dev/VolGroup01/LogVol00 /data/www |
附解决办法二
代码如下 | 复制代码 |
[root@MyVPS ~]# fdisk -l //*查看硬盘分区情况*// Disk /dev/xvda: 10.7 GB, 10737418240 bytes 255 heads, 63 sectors/track, 1305 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/xvda1 * 1 13 104391 83 Linux /dev/xvda2 14 1044 8281507+ 8e Linux LVM /dev/xvda3 1045 1305 2096482+ 8e Linux LVM Disk /dev/xvdb: 7516 MB, 7516192768 bytes 255 heads, 63 sectors/track, 913 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk /dev/xvdb doesn't contain a valid partition table [root@MyVPS ~]#df -hal //*查看已划分区空间使用情况*// Filesystem Size Used Avail Use% Mounted on /dev/mapper/VolGroup00-LogVol00 9.3G 1.2G 7.7G 13% / proc 0 0 0 - /proc sysfs 0 0 0 - /sys devpts 0 0 0 - /dev/pts /dev/xvda1 99M 29M 66M 31% /boot tmpfs 151M 0 151M 0% /dev/shm none 0 0 0 - /proc/sys/fs/binfmt_misc sunrpc 0 0 0 - /var/lib/nfs/rpc_pipefs [root@MyVPS ~]#fdisk /dev/xvdb //*对硬盘/dev/xvdb进行增加分区操作*// Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won't be recoverable. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) Command (m for help):n //*输入n新建分区*// Command action e extended p primary partition (1-4) p //*输入p,主分区*// Partition number (1-4): 1 //*由于xvdb还没有分区.我们这里输入1.第1个分区*// First cylinder (1-913, default 1)://*回车跳过*// Using default value 1 Last cylinder or +size or +sizeM or +sizeK (1-913, default 913)://*回车跳过*// Using default value 913 Command (m for help): t //*通过t来指定分区系统格式*// Selected partition 1 Hex code (type L to list codes):8e //*输入8e LVM系统格式*// Changed system type of partition 1 to 8e (Linux LVM) Command (m for help):w //*输入w保存退出*// The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. [root@MyVPS ~]#reboot //*重启使之生效*// Broadcast message from root (pts/0) (Mon Aug 15 00:43:03 2011): The system is going down for reboot NOW! [root@MyVPS ~]# Connection closed by foreign host. Type `help' to learn how to use Xshell prompt. Xshell:> Connecting to :22... Connection established. Escape character is '^@]'. Last login: Mon Aug 15 00:41:06 2011 from [root@MyVPS1280 ~]#fdisk -l //*查看硬盘分区情况*// Disk /dev/xvda: 10.7 GB, 10737418240 bytes 255 heads, 63 sectors/track, 1305 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/xvda1 * 1 13 104391 83 Linux /dev/xvda2 14 1044 8281507+ 8e Linux LVM /dev/xvda3 1045 1305 2096482+ 8e Linux LVM Disk /dev/xvdb: 7516 MB, 7516192768 bytes 255 heads, 63 sectors/track, 913 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/xvdb1 1 913 7333641 8e Linux LVM [root@MyVPS1280 ~]#pvcreate /dev/xvdb1 //*创建物理卷*// Physical volume "/dev/xvdb1" successfully created [root@MyVPS1280 ~]#vgextend VolGroup00 /dev/xvdb1 //*将物理卷加入到组VolGroup2011*// Volume group "VolGroup00" successfully extended [root@MyVPS1280 ~]# vgdisplay //*查看物理卷组情况.可以看到我们有6.97G的容量可以扩展*// --- Volume group --- VG Name VolGroup00 System ID Format lvm2 Metadata Areas 3 Metadata Sequence No 6 VG Access read/write VG Status resizable MAX LV 0 Cur LV 2 Open LV 2 Max PV 0 Cur PV 3 Act PV 3 VG Size 16.81 GB PE Size 32.00 MB Total PE 538 Alloc PE / Size 315 / 9.84 GB Free PE / Size 223 / 6.97 GB VG UUID ONGPxy-HBvY-xrrQ-IjEW-PIiO-2cX7-tg6tuI [root@MyVPS1280 ~]# lvresize -L +6G /dev/VolGroup00/LogVol00 //*扩容6G(我们第一次加6G)*// Extending logical volume LogVol00 to 15.59 GB Logical volume LogVol00 successfully resized [root@MyVPS1280 ~]#resize2fs /dev/VolGroup00/LogVol00 //*动态扩容分区大小*// resize2fs 1.39 (29-May-2006) Filesystem at /dev/VolGroup00/LogVol00 is mounted on /; on-line resizing required Performing an on-line resize of /dev/VolGroup00/LogVol00 to 4087808 (4k) blocks. The filesystem on /dev/VolGroup00/LogVol00 is now 4087808 blocks long. [root@MyVPS1280 ~]# vgdisplay //*查看物理卷组情况.可以看到我们还有992M的容量可以扩展*// --- Volume group --- VG Name VolGroup00 System ID Format lvm2 Metadata Areas 3 Metadata Sequence No 7 VG Access read/write VG Status resizable MAX LV 0 Cur LV 2 Open LV 2 Max PV 0 Cur PV 3 Act PV 3 VG Size 16.81 GB PE Size 32.00 MB Total PE 538 Alloc PE / Size 507 / 15.84 GB Free PE / Size 31 / 992.00 MB VG UUID ONGPxy-HBvY-xrrQ-IjEW-PIiO-2cX7-tg6tuI [root@MyVPS1280 ~]# lvresize -L +992M /dev/VolGroup00/LogVol00 //*扩容992M(我们第2次加992M)*// Extending logical volume LogVol00 to 16.56 GB Logical volume LogVol00 successfully resized [root@MyVPS1280 ~]# resize2fs /dev/VolGroup00/LogVol00 //*动态扩容分区大小*// resize2fs 1.39 (29-May-2006) Filesystem at /dev/VolGroup00/LogVol00 is mounted on /; on-line resizing required Performing an on-line resize of /dev/VolGroup00/LogVol00 to 4341760 (4k) blocks. The filesystem on /dev/VolGroup00/LogVol00 is now 4341760 blocks long. [root@MyVPS1280 ~]#vgdisplay //*最后再查看扩容完没有 可以看到已经扩容完毕*// --- Volume group --- VG Name VolGroup00 System ID Format lvm2 Metadata Areas 3 Metadata Sequence No 8 VG Access read/write VG Status resizable MAX LV 0 Cur LV 2 Open LV 2 Max PV 0 Cur PV 3 Act PV 3 VG Size 16.81 GB PE Size 32.00 MB Total PE 538 Alloc PE / Size 538 / 16.81 GB Free PE / Size 0 / 0 VG UUID ONGPxy-HBvY-xrrQ-IjEW-PIiO-2cX7-tg6tuI [root@MyVPS1280 ~]# df -hal //*查看已划分区空间使用情况 可以看到我们挂载成功*// Filesystem Size Used Avail Use% Mounted on /dev/mapper/VolGroup00-LogVol00 17G 1.2G 15G 8% / proc 0 0 0 - /proc sysfs 0 0 0 - /sys devpts 0 0 0 - /dev/pts /dev/xvda1 99M 29M 66M 31% /boot tmpfs 151M 0 151M 0% /dev/shm none 0 0 0 - /proc/sys/fs/binfmt_misc sunrpc 0 0 0 - /var/lib/nfs/rpc_pipefs |
注意事项:
1. 教程所用主机为CentOS系统,不同Linux、不同服务器的VPS的卷标(本教程中那个的VolGroup00-LogVol00)可能不同,使用df-hal命令可以查看卷标。
2. 如果你使用的不是基本套餐或者你的硬盘不是15G,那么你两次操作需要增加的容量要以你vgdisplay所看到的为准,(vgidsplay里面的Free PE/Size显示的就是可扩容容量)。我们只所以分两次扩容是由于1024的进制差别造成的,我们所实际看到的容量6.97G并不能直接一次扩容,所以我们可以先扩容整数部分,然后扩容以M为单位的部分。
3. 系统重装后的重装扩展处理(仅格式化系统盘)
系统重装后,直接执行resize2fs进行动态扩容即可:
代码如下 | 复制代码 |
resize2fs /dev/VolGroup2011/LogVol00 |
4. PVs missing导致LVM无法重新扩容的解决办法
运行vgextend/vgdisplay返回错误:
代码如下 | 复制代码 |
Couldn’t find device with uuid ************************ |
此时可以运行:
代码如下 | 复制代码 |
vgreduce VolGroup2011 –removemissing |
然后重新扩容LVM即可。
相关文章
- 《无限暖暖》天星之羽获得位置介绍 12-20
- 《流放之路2》重铸台解锁方法介绍 12-20
- 《无限暖暖》瞄准那个亮亮的成就怎么做 12-20
- 《无限暖暖》魔气怪终结者完成方法 12-20
- 《无限暖暖》曙光毛团获得位置介绍 12-20
- 《无限暖暖》日光果获得位置介绍 12-20