lvm的磁盘管理知识点整理

首先感谢参考的博客网址: http://blog.51cto.com/dreamfire/1084729

https://www.cnblogs.com/kevingrace/p/5825963.html

rpm -e --nodeps python-crypto-2.0.1-22.el6.i686

http://www.dwhd.org/20150521_225146.html

lvm的磁盘管理知识点整理

词汇解析

PV 物理卷

VG 卷组

LV 逻辑卷

直接上命令:

echo '- - -' >/sys/class/scsi_host/host0/scan

echo '- - -' >/sys/class/scsi_host/host1/scan

echo '- - -' >/sys/class/scsi_host/host2/scan

# 制作pv物理卷 将磁盘/dev/sdb转换成pv

pvcreate /dev/sdb

#创建vg 卷组 将/dev/sdb添加到vgdata中 vgdata是卷组的名称

vgcreate vgdata /dev/sdb

#对卷组vgdata进行划分9G的空间给LV 逻辑卷

lvcreate -L 9G -n lvdata1 vgdata

#对逻辑卷进行ext4格式化

mkfs.ext4 /dev/vgdata/lvdata1

#进行挂载给对应目录 挂载完毕后可以进行查看df –h

mkdir /data

mount /dev/vgdata/lvdata1 /data

###假定lv空间用完了快进行动态扩容###

第一步: 将新增的硬盘/dev/sdc制作成pv物理卷

pvcreate /dev/sdc

第二步:给卷组加入新的PV

vgextend vgdata /dev/sdc

vgs

第三步:将空间加给对应的LV

lvextend -L +3G /dev/vgdata/lvdata1

第四步:同步文件系统

resize2fs /dev/vgdata/lvdata1

查看lv对应的vg名称

lvm的磁盘管理知识点整理

lvm的磁盘管理知识点整理

lvm的磁盘管理知识点整理

对应的命令参数补充

lvm的磁盘管理知识点整理

查看uuid的命令

blkid

lvm的磁盘管理知识点整理

永久挂载磁盘方式/etc/fstab进行处理

关于/etc/fstab的解析可以看博文:https://blog.csdn.net/duyiwuer2009/article/details/8644753/

lvm的磁盘管理知识点整理

修改后重启也会挂载目录

关于目录的挂载卸载部分

[root@mapper ~]# umount /data

[root@mapper ~]# df -h

Filesystem Size Used Avail Use% Mounted on

/dev/sda2 48G 1.7G 47G 4% /

devtmpfs 479M 0 479M 0% /dev

tmpfs 489M 0 489M 0% /dev/shm

tmpfs 489M 6.8M 482M 2% /run

tmpfs 489M 0 489M 0% /sys/fs/cgroup

tmpfs 98M 0 98M 0% /run/user/0

[root@mapper ~]# mount -a

[root@mapper ~]# df -h

Filesystem Size Used Avail Use% Mounted on

/dev/sda2 48G 1.7G 47G 4% /

devtmpfs 479M 0 479M 0% /dev

tmpfs 489M 0 489M 0% /dev/shm

tmpfs 489M 6.8M 482M 2% /run

tmpfs 489M 0 489M 0% /sys/fs/cgroup

tmpfs 98M 0 98M 0% /run/user/0

/dev/mapper/vgdata-lvdata1 12G 41M 12G 1% /data

--add by nod at 19-01-09

fdisk /dev/sda
fdisk -l
partx -a /dev/sda
pvcreate /dev/sda3
vgextend VolGroup /dev/sda3
lvextend -L +197G /dev/VolGroup/lv_root
resize2fs /dev/VolGroup/lv_root

=================================add by nod at 19-03-20

[BEGIN] 2019/3/20 9:31:48
###格式化磁盘/dev/sda
[root@test ~]# mkfs.ext4 /dev/sda
mke2fs 1.41.12 (17-May-2010)
/dev/sda is entire device, not just one partition!
Proceed anyway? (y,n) y
Discarding device blocks: done
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
122101760 inodes, 488378646 blocks
24418932 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
14905 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000, 214990848

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 22 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@test ~]# fdisk -l
Disk /dev/sda: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/sdb: 128.0 GB, 128035676160 bytes
255 heads, 63 sectors/track, 15566 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xffebf10a

Device Boot Start End Blocks Id System
/dev/sdb1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sdb2 64 15567 124521472 8e Linux LVM

Disk /dev/mapper/vg_nodtest-lv_root: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/vg_nodtest-lv_swap: 12.8 GB, 12801015808 bytes
255 heads, 63 sectors/track, 1556 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/vg_nodtest-lv_home: 61.0 GB, 61018734592 bytes
255 heads, 63 sectors/track, 7418 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

[root@test ~]# pvcreate /dev/sda
Physical volume "/dev/sda" successfully created
[root@test ~]# vgs
VG #PV #LV #SN Attr VSize VFree
vg_nodtest 1 3 0 wz--n- 118.75g 0

[root@test ~]# vgextend vg_nodtest /dev/sda
Volume group "vg_nodtest" successfully extended
[root@test ~]# vgs
VG #PV #LV #SN Attr VSize VFree
vg_nodtest 2 3 0 wz--n- 1.94t 1.82t
[root@test ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_nodtest-lv_root 50G 4.3G 43G 10% /
tmpfs 32G 72K 32G 1% /dev/shm
/dev/sdb1 485M 39M 421M 9% /boot
/dev/mapper/vg_nodtest-lv_home 56G 180M 53G 1% /home

[root@test ~]# lvextend -L +1800G /dev/vg_nodtest/lv_root
Extending logical volume lv_root to 1.81 TiB
Logical volume lv_root successfully resized

[root@test ~]# lvextend -L +60G /dev/vg_nodtest/lv_root
Extending logical volume lv_root to 1.87 TiB
Logical volume lv_root successfully resized
[root@test ~]# vgs
VG #PV #LV #SN Attr VSize VFree
vg_nodtest 2 3 0 wz--n- 1.94t 3.02g
[root@test ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_nodtest-lv_root 50G 4.3G 43G 10% /
tmpfs 32G 72K 32G 1% /dev/shm
/dev/sdb1 485M 39M 421M 9% /boot
/dev/mapper/vg_nodtest-lv_home 56G 180M 53G 1% /home

[root@test ~]# resize2fs /dev/vg_nodtest/lv_root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/vg_nodtest/lv_root is mounted on /; on-line resizing required
old desc_blocks = 4, new_desc_blocks = 120
Performing an on-line resize of /dev/vg_nodtest/lv_root to 500695040 (4k) blocks.
The filesystem on /dev/vg_nodtest/lv_root is now 500695040 blocks long.

[END] 2019/3/20 9:49:46

上一篇:Firefly Http通信简单介绍


下一篇:hdu - 6281,2018CCPC湖南全国邀请赛F题,快排