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. 跟着兄弟连系统学习Linux-【day07】

    day07-20200604 p25.vim常用操作 vim需要经常练习,一般用于修改配置文件.

  2. webapi上传图片的两种方式

    /// <summary>        /// App上传图片        /// </summary>        /// <returns>返回上传图片的 ...

  3. C004:要求用户输入一个美元数量,然后显示出增加5%税率后的相应金额

    程序: #include "stdafx.h" int _tmain(int argc, _TCHAR* argv[]) { float amount; do{ printf(&q ...

  4. nginx系列(七)静态文件合并combo

    根据雅虎性能优化准则,可以将大量的小型JS文件进行合并,用来提高WEB服务器的性能.下面就是笔者的一个实践. 目前必须安装在1.4.+才可以 官方:http://wiki.nginx.org/Http ...

  5. UI自动化页面需要选择上传文件

    UI自动化页面上传文件,百度查的时候说有4中方法,简便的方法是安装SendKeys,但是百度说这个只支持python2.7的 我的python版本是3.7的,目前还只碰到了非<input typ ...

  6. django之models报错

    django 执行python manage.py makemigrations报错:TypeError: __init__() missing 1 required positional argum ...

  7. k8s service对象

    k8s service对象   概述 service服务也是Kubernetes里核心字眼对象之一,Kubernetes里的每一个service其实就是我们经常提起的微服务架构中的一个微服务,之前讲解 ...

  8. python中的运动控制函数

    运动控制函数:控制海龟走直线&走曲线 海龟向前行进,海龟走直线,参数d表示行进距离,也可以为负数,单位是像素 根据半径r绘制extent角度的弧形 r : 默认圆心在海龟左侧r 距离的位置 e ...

  9. hystrix熔断器之线程池

    隔离 Hystrix有两种隔离方式:信号量和线程池. 线程池隔离:对每个command创建一个自己的线程池,执行调用.通过线程池隔离来保证不同调用不会相互干扰和每一个调用的并发限制. 信号量隔热:对每 ...

  10. Win10环境下Hadoop(单节点伪分布式)的安装与配置--bug(yarn的8088端口打不开+)

    一.本文思路 [1].配置java环境–JDK12(Hadoop的底层实现语言是java,hadoop运行需要JDK环境) [2].安装Hadoop 1.解压hadop 2.配置hadoop环境变量 ...