LVM创建及管理

安装lvm

yum install -y lvm

查看磁盘

[root@template ~]# fdisk -l

Disk /dev/vda: 10.7 GB, 10737418240 bytes, 20971520 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 label type: dos
Disk identifier: 0x000beec6 Device Boot Start End Blocks Id System
/dev/vda1 * 2048 2099199 1048576 83 Linux
/dev/vda2 2099200 20971519 9436160 8e Linux LVM Disk /dev/vdb: 53.7 GB, 53687091200 bytes, 104857600 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/centos-root: 8585 MB, 8585740288 bytes, 16769024 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/centos-swap: 1073 MB, 1073741824 bytes, 2097152 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

  

初始化

[root@template ~]# fdisk /dev/vdb
Welcome to fdisk (util-linux 2.23.2). Changes will remain in memory only, until you decide to write them.
Be careful before using the write command. Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0xda419f51. Command (m for help): o
Building a new DOS disklabel with disk identifier 0x01d037f1. Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p):
Using default response p
Partition number (1-4, default 1):
First sector (2048-104857599, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-104857599, default 104857599):
Using default value 104857599
Partition 1 of type Linux and of size 50 GiB is set
Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM' Command (m for help): w
The partition table has been altered! Calling ioctl() to re-read partition table.
Syncing disks.

  

将磁盘添加到LVM PV

[root@template ~]# pvcreate /dev/vdb1
Physical volume "/dev/vdb1" successfully created.

  

列出所有PV

[root@template ~]# pvscan
PV /dev/vda2 VG centos lvm2 [<9.00 GiB / 0 free]
PV /dev/vdb1 lvm2 [<50.00 GiB]
Total: 2 [<59.00 GiB] / in use: 1 [<9.00 GiB] / in no VG: 1 [<50.00 GiB]

  

显示pv更多信息

[root@template ~]# pvdisplay /dev/vdb1
"/dev/vdb1" is a new physical volume of "<50.00 GiB"
--- NEW Physical volume ---
PV Name /dev/vdb1
VG Name
PV Size <50.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID 4kmSEn-kBZG-vMJc-T03x-aWfO-dEes-5prCUL

  

创建卷组:使用尽可能多的PV来创建VG

[root@template ~]# vgcreate share /dev/vdb1
Volume group "share" successfully created

  

列出所有VG

[root@template ~]# vgscan
Reading volume groups from cache.
Found volume group "share" using metadata type lvm2
Found volume group "centos" using metadata type lvm2

  

显示vg更多信息

[root@template ~]# vgdisplay share
--- Volume group ---
VG Name share
System ID
Format lvm2
Metadata Areas 1
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 1
Act PV 1
VG Size <50.00 GiB
PE Size 4.00 MiB
Total PE 12799
Alloc PE / Size 0 / 0
Free PE / Size 12799 / <50.00 GiB
VG UUID t9gVEp-02O6-IK40-oNxs-fdFC-nuA3-Y5NgNU

  

创建逻辑卷:使用VG创建任意数量的LV

[root@template ~]# lvcreate --size 49G --name vg_data share
Logical volume "vg_data" created.

  

列出所有LV

[root@template ~]# lvscan
ACTIVE '/dev/share/vg_data' [49.00 GiB] inherit
ACTIVE '/dev/centos/swap' [1.00 GiB] inherit
ACTIVE '/dev/centos/root' [<8.00 GiB] inherit

  

格式化

[root@template ~]# mkfs.ext4 /dev/share/vg_data
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
3211264 inodes, 12845056 blocks
642252 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2162163712
392 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 Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

  

创建需要挂载到的目录

[root@template ~]# mkdir -p /data

  

挂载

[root@template ~]# mount /dev/mapper/share-vg_data /data

  

查看

[root@template ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 5.7G 0 5.7G 0% /dev
tmpfs 5.7G 0 5.7G 0% /dev/shm
tmpfs 5.7G 8.6M 5.7G 1% /run
tmpfs 5.7G 0 5.7G 0% /sys/fs/cgroup
/dev/mapper/centos-root 8.0G 1.8G 6.3G 22% /
/dev/vda1 1014M 231M 784M 23% /boot
tmpfs 1.2G 0 1.2G 0% /run/user/0
/dev/mapper/share-vg_data 49G 53M 46G 1% /data

  

开机自动挂载

[root@template ~]# vim /etc/fstab

/dev/mapper/share-vg_data  /data               ext4     defaults        0 0

  

增加100G到/data

[root@vmhost2 ~]# lvextend --size +500G --resizefs /dev/mapper/VGsdb1T-vm_main
Size of logical volume VGsdb1T/vm_main changed from 400.00 GiB (102400 extents) to 900.00 GiB (230400 extents).
Logical volume VGsdb1T/vm_main successfully resized.
resize2fs 1.42.9 (28-Dec-2013)
Filesystem at /dev/mapper/VGsdb1T-vm_main is mounted on /data; on-line resizing required
old_desc_blocks = 50, new_desc_blocks = 113
The filesystem on /dev/mapper/VGsdb1T-vm_main is now 235929600 blocks long.

  

查看

df -h

  

LVM创建及管理的更多相关文章

  1. 【Linux卷管理】LVM创建与管理

    安装LVM 首先确定系统中是否安装了lvm工具: [root@jetsen ~]# rpm -qa|grep lvm system-config-lvm-1.1.5-1.0.el5 lvm2-2.02 ...

  2. linux的存储管理(RALD) LVM 逻辑卷管理 虚拟阵列

    磁盘存储管理 LVM 逻辑卷 虚拟阵列 1.Linux系统中 磁盘使用 存在3个大问题: 1.灵活性 2.安全性 3.性能 2.解决办法RAID独立磁盘冗余阵列 RAID(Redundant Arra ...

  3. LVM逻辑卷管理测试——创建逻辑卷

    虚拟机里再添加两块硬盘,如下所示: 启动系统后,我们可以看到新添加的两块硬盘为/dev/sdb和/dev/sdc.每个2GB. [root@lxjtest ~]# fdisk -l Disk /dev ...

  4. LVM的创建与管理

    LVM的创建与管理1.创建物理分区  fdisk 或者 parted 工具分区. LVM分区的类型ID为8e2.创建物理卷  pvcreate 磁盘分区或整个磁盘3.创建卷组  vgcreate 卷组 ...

  5. LVM的创建及管理

    创建及管理LVM分区. Lvm(logical  volume  manager)逻辑卷管理 作用:动态调整磁盘容量,提高磁盘管理的灵活性. 注意:/boot分区用于存放引导文件,不能基于LVM创建. ...

  6. LVM逻辑卷管理

    一.LVM简介 LVM(Logic Volume Manager)逻辑卷管理,简单理解就是将一块或多块硬盘的分区在逻辑上集合,当一块大硬盘来使用. 其特点是: 1.可以实现在线动态扩展,也可以缩减 2 ...

  7. Linux LVM卷组管理

    Linux LVM卷组管理 由于传统的磁盘管理不能对磁盘进行磁盘管理,因此诞生了LVM技术,LVM技术最大的特点就是对磁盘进行动态管理. 由于LVM的逻辑卷的大小更改可以进行动态调整,且不会出现丢失数 ...

  8. 18 LVM逻辑卷管理

    根据上一节的内容,我们知道md这个内核模块可以用来做软RAID的管理.同时RAID实现了两个功能:1.提高了磁盘的读写能力:2.对于数据进行了冗余备份: 但是,如果是管理员手动误删的数据,则一样无法找 ...

  9. LVM逻辑卷管理测试——逻辑卷扩展、收缩、快照及删除

    一.逻辑卷扩展 [root@lxjtest /]# umount /testLVM/ [root@lxjtest /]# df -h Filesystem Size Used Avail Use% M ...

随机推荐

  1. 20190923-03Linux时间日期类 000 011

    1.基本语法 date [OPTION]... [+FORMAT] 2.选项说明 表1-20 选项 功能 -d<时间字符串> 显示指定的“时间字符串”表示的时间,而非当前时间 -s< ...

  2. 不用写代码也能做表单 —— 加载meta即可

    做增删改查要写多少代码? 一个表单一套代码,十个表单十套代码吗? 我这么懒,怎么会写这么多代码? 我想做到:即使一百个表单也只需要一套代码(而且不需要复制粘贴).实现多个表单,只需要加载不同的meta ...

  3. Promise核心实现

    核心 构造函数核心 维护状态变量,只能由pending变为resolve或者reject 维护一个存储结果的变量 维护一个回调数组,执行到then,如果我们传入的立即执行函数没有立即执行resolve ...

  4. md5命令

    AIX 系统md5命令之csum #csum filename (默认使用md5算法) #csum -h SHA1 filename (使用sha1算法)Linux系统命令之md5sum 1. 背景 ...

  5. python3 变量

    python 3变量名不能以数字开头但能数字结尾 变量名大小写敏感 在多个单词组成的变量名中以下划线间隔

  6. [计算机网络]图解HTTP阅读笔记

    总述 书的定位:一本十分浅显的HTTP书籍,主要介绍了HTTP与HTTPS.适合入门了解,很多地方都是蜻蜓点水,但稍微深入的地方能让人了解重点在哪,后面应该有针对性地阅读深入书籍. 主要内容:介绍了T ...

  7. CentOS7使用PackageCloud安装RabbitMQ

    环境:CentOS Linux release 7.6.1810 (Core) RabbitMQ:3.7.17Erlang: 22.0.7 使用PackageCloud安装RabbitMQ是最简单的安 ...

  8. Shell编程(5)

    文本处理三剑客 在 Shell 下使用这些正则表达式处理文本最多的命令有下面几个工具:                 命令                描述 grep 默认不支持扩展表达式,加-E ...

  9. openstack核心组件——nova计算服务(7)

    云计算openstack核心组件——nova计算服务(7)   一.nova介绍:       Nova 是 OpenStack 最核心的服务,负责维护和管理云环境的计算资源.OpenStack 作为 ...

  10. Java线程阻塞方法sleep()和wait()精炼详解

    版权声明:因为个人水平有限,文章中可能会出现错误,如果你觉得有描述不当.代码错误等内容或者有更好的实现方式,欢迎在评论区告诉我,即刻回复!最后,欢迎关注博主!谢谢 https://blog.csdn. ...