制作LVM

本文详细介绍了如何在Linux上创建和管理LVM,包括gdisk分区、建立Physical Volume(PV)、Volume Group(VG)、Logical Volume(LV),以及格式化、挂载、调整LV容量、使用thin Volume和快照区等操作。
摘要由CSDN通过智能技术生成

一、需求

  • 使用4个partition,每个partition的容量均在1GB左右,且systemID需要为8e;
  • 全部的partition整合成为一个VG,VG名称设定为vbirdvg;且PE的大小为16GB;
  • 建立一个名为vbirdlv的LV,容量大约为2G;
  • 最终这个LV格式化为xfs的文件系统,且挂载在/srv/lvm中

二、gdisk分区

[root@study ~]# gdisk /dev/sda   #使用gdisk进行分区
GPT fdisk (gdisk) version 0.8.10

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.

Command (? for help): n
Partition number (4-128, default 4):                                       #默认值
First sector (34-83886046, default = 65026048) or {+-}size{KMGTP}: +1gb    #1gb大小
Last sector (67123200-83886046, default = 83886046) or {+-}size{KMGTP}: +1gb
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): 8e00                     #8e00:Linux LVM
Changed type of partition to 'Linux LVM'

#重复4次,w写入并退出
Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/sda.
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot.
The operation has completed successfully.

三、建立PV(Physical Volume)

  • pvcreate                                将实体partition建立成为PV
  • pvscan                                  搜寻目前系统里面任何具有PV的磁盘
  • pvdisplay                              显示出目前系统上面的PV状态
  • pvremove                              将PV属性移除,让该partition不具有PV属性
#1.将/dev/sda{4-7}建立成PV格式
[root@study ~]# pvcreate /dev/sda{4,5,6,7}
  Physical volume "/dev/sda4" successfully created.
  Physical volume "/dev/sda5" successfully created.
  Physical volume "/dev/sda6" successfully created.
  Physical volume "/dev/sda7" successfully created.


#2.查看一下里面具有PV状态的磁盘
[root@study ~]# pvscan
  PV /dev/sda3   VG centos          lvm2 [30.00 GiB / 14.00 GiB free]
  PV /dev/sda6                      lvm2 [1.00 GiB]
  PV /dev/sda7                      lvm2 [1.00 GiB]
  PV /dev/sda5                      lvm2 [1.00 GiB]
  PV /dev/sda4                      lvm2 [1.00 GiB]
  Total: 5 [34.00 GiB] / in use: 1 [30.00 GiB] / in no VG: 4 [4.00 GiB]

#3.更详细列出系统上每个PV的信息
[root@study ~]# pvdisplay /dev/sda4
  "/dev/sda4" is a new physical volume of "1.00 GiB"
  --- NEW Physical volume ---
  PV Name               /dev/sda4
  VG Name               
  PV Size               1.00 GiB
  Allocatable           NO
  PE Size               0   
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               1hANDP-PL30-wed0-3Z61-8VG0-jfwf-NEqfBb

 

四、建立VG(Volume Groups)

  • vgcreate                                                       建立vg的指令
  • vgscan       
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值