4.10/4.11/4.12 lvm讲解 4.13 磁盘故障小案例

Posted sisul

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了4.10/4.11/4.12 lvm讲解 4.13 磁盘故障小案例相关的知识,希望对你有一定的参考价值。

id83,说明是普通的分区,如果使用LVM,需要改变一下,t,8e

创建第二个

创建第三个

保存退出

yum provides  "/*/pvcreate"

[root@lizhipeng01 ~]# pvcreate /dev/sdb1
Device /dev/sdb1 not found (or ignored by filtering).
[root@lizhipeng01 ~]# fdisk -l /dev/sdb

磁盘 /dev/sdb:5368 MB, 5368709120 字节,10485760 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0xf7fa8582

设备 Boot Start End Blocks Id System
/dev/sdb1 2048 2099199 1048576 8e Linux LVM
/dev/sdb2 2099200 4196351 1048576 8e Linux LVM
/dev/sdb3 4196352 6293503 1048576 8e Linux LVM
[root@lizhipeng01 ~]# ls /dev/sdb1
ls: 无法访问/dev/sdb1: 没有那个文件或目录
[root@lizhipeng01 ~]# partprobe
[root@lizhipeng01 ~]# ls /dev/sdb1
/dev/sdb1

[root@lizhipeng01 ~]# pvcreate /dev/sdb1
Can\'t open /dev/sdb1 exclusively. Mounted filesystem?
[root@lizhipeng01 ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/centos-root 28G 1.1G 27G 4% /
devtmpfs 481M 0 481M 0% /dev
tmpfs 490M 0 490M 0% /dev/shm
tmpfs 490M 6.7M 484M 2% /run
tmpfs 490M 0 490M 0% /sys/fs/cgroup
/dev/sdb 5.0G 33M 5.0G 1% /mnt
/dev/sda1 197M 105M 93M 53% /boot
[root@lizhipeng01 ~]# umount /mnt
[root@lizhipeng01 ~]# pvcreate /dev/sdb1
WARNING: dos signature detected on /dev/sdb1 at offset 510. Wipe it? [y/n]: y
Wiping dos signature on /dev/sdb1.
Physical volume "/dev/sdb1" successfully created.
[root@lizhipeng01 ~]# pvcreate /dev/sdb2
Physical volume "/dev/sdb2" successfully created.
[root@lizhipeng01 ~]# pvcreate /dev/sdb3
Physical volume "/dev/sdb3" successfully created.
[root@lizhipeng01 ~]# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name centos
PV Size 29.51 GiB / not usable 3.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 7554
Free PE 11
Allocated PE 7543
PV UUID bIH33a-WhH8-FSvD-2B57-9S4C-rgOx-FTY3pt

"/dev/sdb1" is a new physical volume of "1.00 GiB"
--- NEW Physical volume ---
PV Name /dev/sdb1
VG Name
PV Size 1.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID JguHsp-lbFC-qoHy-uIup-z9Er-FjvB-b7AN0e

"/dev/sdb2" is a new physical volume of "1.00 GiB"
--- NEW Physical volume ---
PV Name /dev/sdb2
VG Name
PV Size 1.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID lYdeX1-U0k8-8cgW-oBpg-OHIn-NVmQ-sfqsgu

"/dev/sdb3" is a new physical volume of "1.00 GiB"
--- NEW Physical volume ---
PV Name /dev/sdb3
VG Name
PV Size 1.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID de0NN8-O5mT-8ISt-bd0X-E6AV-NqRF-nc6ujJ

[root@lizhipeng01 ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 centos lvm2 a-- <29.51g 44.00m
/dev/sdb1 lvm2 --- 1.00g 1.00g
/dev/sdb2 lvm2 --- 1.00g 1.00g
/dev/sdb3 lvm2 --- 1.00g 1.00g

[root@lizhipeng01 ~]# vgcreate vg1 /dev/sdb1 /dev/sdb2
Volume group "vg1" successfully created
[root@lizhipeng01 ~]# vgdisplay
--- Volume group ---
VG Name vg1
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 2
Act PV 2
VG Size 1.99 GiB
PE Size 4.00 MiB
Total PE 510
Alloc PE / Size 0 / 0
Free PE / Size 510 / 1.99 GiB
VG UUID LwuLpJ-T6ZQ-JFXf-PtzP-wjRQ-BAWd-dMOPsW

--- Volume group ---
VG Name centos
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size <29.51 GiB
PE Size 4.00 MiB
Total PE 7554
Alloc PE / Size 7543 / 29.46 GiB
Free PE / Size 11 / 44.00 MiB
VG UUID qtkYd1-J243-SbZc-hN2y-iLMM-eioc-ZN83k8

[root@lizhipeng01 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
centos 1 2 0 wz--n- <29.51g 44.00m
vg1 2 0 0 wz--n- 1.99g 1.99g

[root@lizhipeng01 ~]# lvcreate -L 100M -n lv1 vg1
WARNING: ext4 signature detected on /dev/vg1/lv1 at offset 1080. Wipe it? [y/n]: y
Wiping ext4 signature on /dev/vg1/lv1.
Logical volume "lv1" created.

格式化

[root@lizhipeng01 ~]# mkfs.ext4 /dev/vg1/lv1
mke2fs 1.42.9 (28-Dec-2013)
文件系统标签=
OS type: Linux
块大小=1024 (log=0)
分块大小=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
25688 inodes, 102400 blocks
5120 blocks (5.00%) reserved for the super user
第一个数据块=1
Maximum filesystem blocks=33685504
13 block groups
8192 blocks per group, 8192 fragments per group
1976 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729

Allocating group tables: 完成
正在写入inode表: 完成
Creating journal (4096 blocks): 完成
Writing superblocks and filesystem accounting information: 完成

[root@lizhipeng01 ~]# mount /dev/vg1/lv1 /mnt/
[root@lizhipeng01 ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/centos-root 28G 1.1G 27G 4% /
devtmpfs 481M 0 481M 0% /dev
tmpfs 490M 0 490M 0% /dev/shm
tmpfs 490M 6.7M 484M 2% /run
tmpfs 490M 0 490M 0% /sys/fs/cgroup
/dev/sda1 197M 105M 93M 53% /boot
/dev/mapper/vg1-lv1 93M 1.6M 85M 2% /mnt
[root@lizhipeng01 ~]# ls -l /dev/vg1/lv1                                     指向同一个文件
lrwxrwxrwx. 1 root root 7 12月 31 22:55 /dev/vg1/lv1 -> ../dm-2           
[root@lizhipeng01 ~]# ls -l /dev/mapper/vg1-lv1
lrwxrwxrwx. 1 root root 7 12月 31 22:55 /dev/mapper/vg1-lv1 -> ../dm-2

[root@lizhipeng01 ~]# mkdir /mnt/1231
[root@lizhipeng01 ~]# touch /mnt/23.txt
[root@lizhipeng01 ~]# echo "111111111111111">/mnt/23.txt
[root@lizhipeng01 ~]# lvresize -L 200M /dev/vg1/lv1
Size of logical volume vg1/lv1 changed from 100.00 MiB (25 extents) to 200.00 MiB (50 extents).
Logical volume vg1/lv1 successfully resized.
[root@lizhipeng01 ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/centos-root 28G 1.1G 27G 4% /
devtmpfs 481M 0 481M 0% /dev
tmpfs 490M 0 490M 0% /dev/shm
tmpfs 490M 6.7M 484M 2% /run
tmpfs 490M 0 490M 0% /sys/fs/cgroup
/dev/sda1 197M 105M 93M 53% /boot
/dev/mapper/vg1-lv1 93M 1.6M 85M 2% /mnt
[root@lizhipeng01 ~]# umount /mnt/
[root@lizhipeng01 ~]# lvresize -L 200M /dev/vg1/lv1
New size (50 extents) matches existing size (50 extents).
[root@lizhipeng01 ~]# e2fsck -f /dev/vg1/lv1                   检查磁盘错误
e2fsck 1.42.9 (28-Dec-2013)
第一步: 检查inode,块,和大小
第二步: 检查目录结构
第3步: 检查目录连接性
Pass 4: Checking reference counts
第5步: 检查簇概要信息
/dev/vg1/lv1: 13/25688 files (7.7% non-contiguous), 8899/102400 blocks

[root@lizhipeng01 ~]# resize2fs /dev/vg1/lv1
resize2fs 1.42.9 (28-Dec-2013)
Resizing the filesystem on /dev/vg1/lv1 to 204800 (1k) blocks.
The filesystem on /dev/vg1/lv1 is now 204800 blocks long.

[root@lizhipeng01 ~]# !mount
mount /dev/vg1/lv1 /mnt/
[root@lizhipeng01 ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/centos-root 28G 1.1G 27G 4% /
devtmpfs 481M 0 481M 0% /dev
tmpfs 490M 0 490M 0% /dev/shm
tmpfs 490M 6.7M 484M 2% /run
tmpfs 490M 0 490M 0% /sys/fs/cgroup
/dev/sda1 197M 105M 93M 53% /boot
/dev/mapper/vg1-lv1 190M 1.6M 175M 1% /mnt

[root@lizhipeng01 ~]# umount /mnt/
[root@lizhipeng01 ~]# e2fsck -f /dev/vg1/lv1
e2fsck 1.42.9 (28-Dec-2013)
第一步: 检查inode,块,和大小
第二步: 检查目录结构
第3步: 检查目录连接性
Pass 4: Checking reference counts
第5步: 检查簇概要信息
/dev/vg1/lv1: 13/49400 files (7.7% non-contiguous), 11887/204800 blocks
[root@lizhipeng01 ~]# resize2fs /dev/vg1/lv1 100M
resize2fs 1.42.9 (28-Dec-2013)
Resizing the filesystem on /dev/vg1/lv1 to 102400 (1k) blocks.
The filesystem on /dev/vg1/lv1 is now 102400 blocks long.

[root@lizhipeng01 ~]# lvresize -L 100M /dev/vg1/lv1
WARNING: Reducing active logical volume to 100.00 MiB.
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce vg1/lv1? [y/n]: y
Size of logical volume vg1/lv1 changed from 200.00 MiB (50 extents) to 100.00 MiB (25 extents).
Logical volume vg1/lv1 successfully resized.

[root@lizhipeng01 ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root centos -wi-ao---- 27.46g
swap centos -wi-ao---- 2.00g
lv1 vg1 -wi-a----- 100.00m
[root@lizhipeng01 ~]# ls /mnt/
[root@lizhipeng01 ~]# !mount
mount /dev/vg1/lv1 /mnt/
[root@lizhipeng01 ~]# ls /mnt/
1231 23.txt lost+found

[root@lizhipeng01 ~]# umount /mnt/
[root@lizhipeng01 ~]# mkfs.xfs -f /dev/vg1/lv1          格式化成xfs
meta-data=/dev/vg1/lv1 isize=256 agcount=4, agsize=6400 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0
data = bsize=4096 blocks=25600, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal log bsize=4096 blocks=853, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0

[root@lizhipeng01 ~]# !mount
mount /dev/vg1/lv1 /mnt/
[root@lizhipeng01 ~]# ls /mnt/
[root@lizhipeng01 ~]# touch /mnt/233.txt
[root@lizhipeng01 ~]# echo "aaa">>!$
echo "aaa">>/mnt/233.txt
[root@lizhipeng01 ~]# cat !$
cat /mnt/233.txt
aaa

[root@lizhipeng01 ~]# xfs_growfs /dev/vg1/lv1
meta-data=/dev/mapper/vg1-lv1 isize=256 agcount=4, agsize=6400 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0
data = bsize=4096 blocks=25600, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal bsize=4096 blocks=853, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 25600 to 76800
[root@lizhipeng01 ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/centos-root 28G 1.1G 27G 4% /
devtmpfs 481M 0 481M 0% /dev
tmpfs 490M 0 490M 0% /dev/shm
tmpfs 490M 6.7M 484M 2% /run
tmpfs 490M 0 490M 0% /sys/fs/cgroup
/dev/sda1 197M 105M 93M 53% /boot
/dev/mapper/vg1-lv1 297M 5.5M 292M 2% /mnt

[root@lizhipeng01 ~]# vgextend vg1 /dev/sdb3
Volume group "vg1" successfully extended
[root@lizhipeng01 ~]# vgdisplay
--- Volume group ---
VG Name vg1
System ID
Format lvm2
Metadata Areas 3
Metadata Sequence No 6
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 3
Act PV 3
VG Size <2.99 GiB
PE Size 4.00 MiB
Total PE 765
Alloc PE / Size 75 / 300.00 MiB
Free PE / Size 690 / <2.70 GiB
VG UUID LwuLpJ-T6ZQ-JFXf-PtzP-wjRQ-BAWd-dMOPsW

[root@lizhipeng01 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
centos 1 2 0 wz--n- <29.51g 44.00m
vg1 3 1 0 wz--n- <2.99g <2.70g

以上是关于4.10/4.11/4.12 lvm讲解 4.13 磁盘故障小案例的主要内容,如果未能解决你的问题,请参考以下文章

4.10/4.11/4.12 lvm讲解 4.13 磁盘故障小案例

四周第一次课 4.10/4.11/4.12 lvm讲解 4.13 磁盘故障小案例

4.10/4.11/4.12 lvm讲解 4.13 磁盘故障小案例

逻辑卷

2018-4-11

2018.1.2 4周1次课