首页 > 系统相关 >centos 创建 lvm

centos 创建 lvm

时间:2023-09-21 14:15:21浏览次数:47  
标签:centos VG 创建 bytes dev LV lvm 512

查看磁盘使用

# df -h
Filesystem               Size  Used Avail Use% Mounted on
devtmpfs                 3.9G     0  3.9G   0% /dev
tmpfs                    3.9G     0  3.9G   0% /dev/shm
tmpfs                    3.9G   18M  3.9G   1% /run
tmpfs                    3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/mapper/centos-root   48G  4.8G   44G  10% /
/dev/vda1               1014M  212M  803M  21% /boot
/dev/mapper/centos-home   24G   37M   24G   1% /home
tmpfs                    799M   12K  799M   1% /run/user/42
tmpfs                    799M     0  799M   0% /run/user/1001

查看可用磁盘

# fdisk -l
Disk /dev/vda: 214.7 GB, 214748364800 bytes, 419430400 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: 0x000dc289

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048     2099199     1048576   83  Linux
/dev/vda2         2099200   167772159    82836480   8e  Linux LVM

Disk /dev/mapper/centos-root: 51.3 GB, 51308920832 bytes, 100212736 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: 8455 MB, 8455716864 bytes, 16515072 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-home: 25.1 GB, 25052577792 bytes, 48930816 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

创建分区

# fdisk /dev/vda
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.


Command (m for help): n
Partition type:
   p   primary (2 primary, 0 extended, 2 free)
   e   extended
Select (default p): p
Partition number (3,4, default 3): 
First sector (167772160-419430399, default 167772160): 
Using default value 167772160
Last sector, +sectors or +size{K,M,G} (167772160-419430399, default 419430399): 
Using default value 419430399
Partition 3 of type Linux and of size 120 GiB is set

Command (m for help): 

修改分区

Command (m for help): t
Partition number (1-3, default 3): 
Hex code (type L to list all codes): L

 0  Empty           24  NEC DOS         81  Minix / old Lin bf  Solaris        
 1  FAT12           27  Hidden NTFS Win 82  Linux swap / So c1  DRDOS/sec (FAT-
 2  XENIX root      39  Plan 9          83  Linux           c4  DRDOS/sec (FAT-
 3  XENIX usr       3c  PartitionMagic  84  OS/2 hidden C:  c6  DRDOS/sec (FAT-
 4  FAT16 <32M      40  Venix 80286     85  Linux extended  c7  Syrinx         
 5  Extended        41  PPC PReP Boot   86  NTFS volume set da  Non-FS data    
 6  FAT16           42  SFS             87  NTFS volume set db  CP/M / CTOS / .
 7  HPFS/NTFS/exFAT 4d  QNX4.x          88  Linux plaintext de  Dell Utility   
 8  AIX             4e  QNX4.x 2nd part 8e  Linux LVM       df  BootIt         
 9  AIX bootable    4f  QNX4.x 3rd part 93  Amoeba          e1  DOS access     
 a  OS/2 Boot Manag 50  OnTrack DM      94  Amoeba BBT      e3  DOS R/O        
 b  W95 FAT32       51  OnTrack DM6 Aux 9f  BSD/OS          e4  SpeedStor      
 c  W95 FAT32 (LBA) 52  CP/M            a0  IBM Thinkpad hi eb  BeOS fs        
 e  W95 FAT16 (LBA) 53  OnTrack DM6 Aux a5  FreeBSD         ee  GPT            
 f  W95 Ext'd (LBA) 54  OnTrackDM6      a6  OpenBSD         ef  EFI (FAT-12/16/
10  OPUS            55  EZ-Drive        a7  NeXTSTEP        f0  Linux/PA-RISC b
11  Hidden FAT12    56  Golden Bow      a8  Darwin UFS      f1  SpeedStor      
12  Compaq diagnost 5c  Priam Edisk     a9  NetBSD          f4  SpeedStor      
14  Hidden FAT16 <3 61  SpeedStor       ab  Darwin boot     f2  DOS secondary  
16  Hidden FAT16    63  GNU HURD or Sys af  HFS / HFS+      fb  VMware VMFS    
17  Hidden HPFS/NTF 64  Novell Netware  b7  BSDI fs         fc  VMware VMKCORE 
18  AST SmartSleep  65  Novell Netware  b8  BSDI swap       fd  Linux raid auto
1b  Hidden W95 FAT3 70  DiskSecure Mult bb  Boot Wizard hid fe  LANstep        
1c  Hidden W95 FAT3 75  PC/IX           be  Solaris boot    ff  BBT            
1e  Hidden W95 FAT1 80  Old Minix      
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.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.

重启主机

# reboot

VG

查看 VG

# vgdisplay
  --- Volume group ---
  VG Name               centos
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               3
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               <79.00 GiB
  PE Size               4.00 MiB
  Total PE              20223
  Alloc PE / Size       20222 / 78.99 GiB
  Free  PE / Size       1 / 4.00 MiB
  VG UUID               bdtChH-hul3-Jxdj-9Fnv-LFB3-h9vK-CuuPcF

扩展 VG

# vgextend centos /dev/vda3
  Physical volume "/dev/vda3" successfully created.
  Volume group "centos" successfully extended

确认 VG

# vgdisplay
  --- Volume group ---
  VG Name               centos
  System ID             
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  5
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               3
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               198.99 GiB
  PE Size               4.00 MiB
  Total PE              50942
  Alloc PE / Size       20222 / 78.99 GiB
  Free  PE / Size       30720 / 120.00 GiB
  VG UUID               bdtChH-hul3-Jxdj-9Fnv-LFB3-h9vK-CuuPcF

PV

查看 PV

# pvdisplay
  --- Physical volume ---
  PV Name               /dev/vda2
  VG Name               centos
  PV Size               <79.00 GiB / not usable 3.00 MiB
  Allocatable           yes 
  PE Size               4.00 MiB
  Total PE              20223
  Free PE               1
  Allocated PE          20222
  PV UUID               AyTSDi-pW22-0FLO-5GcH-7zQP-65Fn-qX09y6
   
  --- Physical volume ---
  PV Name               /dev/vda3
  VG Name               centos
  PV Size               120.00 GiB / not usable 4.00 MiB
  Allocatable           yes 
  PE Size               4.00 MiB
  Total PE              30719
  Free PE               30719
  Allocated PE          0
  PV UUID               8ziWLx-jUZb-pGUn-PJX9-tStg-CyKY-WRJC6i

LV

查看 LV

# lvdisplay
  --- Logical volume ---
  LV Path                /dev/centos/swap
  LV Name                swap
  VG Name                centos
  LV UUID                1xMGhi-MFKx-PRpc-iGXB-1AyU-iGIW-0X0fho
  LV Write Access        read/write
  LV Creation host, time localhost, 2022-10-09 20:39:28 +0800
  LV Status              available
  # open                 2
  LV Size                <7.88 GiB
  Current LE             2016
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:1
   
  --- Logical volume ---
  LV Path                /dev/centos/home
  LV Name                home
  VG Name                centos
  LV UUID                inLLZg-h6au-5yKr-NbOP-yDr3-VBpe-BX3v30
  LV Write Access        read/write
  LV Creation host, time localhost, 2022-10-09 20:39:28 +0800
  LV Status              available
  # open                 1
  LV Size                23.33 GiB
  Current LE             5973
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:2
   
  --- Logical volume ---
  LV Path                /dev/centos/root
  LV Name                root
  VG Name                centos
  LV UUID                s09z9e-n1gA-N6wS-Nwaj-bd0s-KVD3-FRqwCf
  LV Write Access        read/write
  LV Creation host, time localhost, 2022-10-09 20:39:29 +0800
  LV Status              available
  # open                 1
  LV Size                <47.79 GiB
  Current LE             12233
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:0

创建 LV

# lvcreate -l 100%Free -n /dev/centos/data

or

# lvcreate -l 120G -n /dev/centos/data
  Logical volume "data" created.

确认 LV

# lvdisplay
--- Logical volume ---
  LV Path                /dev/centos/swap
  LV Name                swap
  VG Name                centos
  LV UUID                1xMGhi-MFKx-PRpc-iGXB-1AyU-iGIW-0X0fho
  LV Write Access        read/write
  LV Creation host, time localhost, 2022-10-09 20:39:28 +0800
  LV Status              available
  # open                 2
  LV Size                <7.88 GiB
  Current LE             2016
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:1
   
  --- Logical volume ---
  LV Path                /dev/centos/home
  LV Name                home
  VG Name                centos
  LV UUID                inLLZg-h6au-5yKr-NbOP-yDr3-VBpe-BX3v30
  LV Write Access        read/write
  LV Creation host, time localhost, 2022-10-09 20:39:28 +0800
  LV Status              available
  # open                 1
  LV Size                23.33 GiB
  Current LE             5973
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:2
   
  --- Logical volume ---
  LV Path                /dev/centos/root
  LV Name                root
  VG Name                centos
  LV UUID                s09z9e-n1gA-N6wS-Nwaj-bd0s-KVD3-FRqwCf
  LV Write Access        read/write
  LV Creation host, time localhost, 2022-10-09 20:39:29 +0800
  LV Status              available
  # open                 1
  LV Size                <47.79 GiB
  Current LE             12233
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:0
   
  --- Logical volume ---
  LV Path                /dev/centos/data
  LV Name                data
  VG Name                centos
  LV UUID                JXHfb5-hWzs-UP94-3F1G-xvI0-2yAY-lDv78a
  LV Write Access        read/write
  LV Creation host, time uat-digitalreg-oss, 2023-09-21 13:34:15 +0800
  LV Status              available
  # open                 0
  LV Size                120.00 GiB
  Current LE             30720
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:3

格式化分区

# mkfs.xfs /dev/centos/data
meta-data=/dev/centos/data       isize=512    agcount=4, agsize=7864320 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=31457280, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=15360, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

创建挂载点

# mkdir /data

查看分区UID

# blkid 
/dev/vda1: UUID="817a90fc-6e73-4734-a0e5-234acbe5b5a1" TYPE="xfs" 
/dev/vda2: UUID="AyTSDi-pW22-0FLO-5GcH-7zQP-65Fn-qX09y6" TYPE="LVM2_member" 
/dev/mapper/centos-root: UUID="981cf489-bc87-4784-9472-bdd1330d5a1b" TYPE="xfs" 
/dev/mapper/centos-swap: UUID="547a4bfd-557f-4f64-98b1-e1e4ce931923" TYPE="swap" 
/dev/mapper/centos-home: UUID="f83f85b3-7b4e-42b8-a4a9-69806e455414" TYPE="xfs" 
/dev/vda3: UUID="8ziWLx-jUZb-pGUn-PJX9-tStg-CyKY-WRJC6i" TYPE="LVM2_member" 
/dev/mapper/centos-data: UUID="84b53504-7eaa-4e48-96e2-7dfe4bedb854" TYPE="xfs" 

开机自动挂载

# echo `blkid |grep /dev/mapper/centos-data | awk '{print $2}'` /data xfs defaults 0 0 >> /etc/fstab

挂载分区

# mount -a

查看挂载

# df -h
Filesystem               Size  Used Avail Use% Mounted on
devtmpfs                 3.9G     0  3.9G   0% /dev
tmpfs                    3.9G     0  3.9G   0% /dev/shm
tmpfs                    3.9G  9.3M  3.9G   1% /run
tmpfs                    3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/mapper/centos-root   48G  4.6G   44G  10% /
/dev/vda1               1014M  212M  803M  21% /boot
/dev/mapper/centos-home   24G   37M   24G   1% /home
tmpfs                    799M   12K  799M   1% /run/user/42
tmpfs                    799M     0  799M   0% /run/user/1001
/dev/mapper/centos-data  120G   33M  120G   1% /data

 

标签:centos,VG,创建,bytes,dev,LV,lvm,512
From: https://www.cnblogs.com/wangguishe/p/17719758.html

相关文章

  • CentOS环境 nginx配置vue项目
    ps:这里使用ruoyi-vue-plus项目举例,官网:https://plus-doc.dromara.org/一、配置不带应用路径的vue项目1、打包。首先将vue项目生产配置文件的的应用访问路径设为'/',然后命令行输入runrunbuild:prod进行打包。2、导入环境。将打包文件(dist)拖入CentOS中/usr/local/nginx/html......
  • 进程注入之Portable Executable Injection,PE注入的核心是创建远程线程,注意重定位表修
     PE(Portable Executable)注入是一种常见的代码注入技术,主要用于在目标进程中执行恶意代码。以下是PE注入的基本流程:1. 获取当前PE映像的基地址:使用GetModuleHandle(NULL)函数获取当前PE映像(即要注入的代码)的基地址。2. 复制PE映像:使用VirtualAlloc函数在当前进程中分配一块新......
  • CentOS7共享文件夹设置
    故障现象:使用VMwareWorkstation10在CentOS7上安装VMwareTools工具,总是出错,更换成VMwareWorkstation12Pro共享成功。软件环境:主机:windows7、虚拟机:VMwareWorkstation12Pro、客户机: CentOS7一、设置共享文件夹1、在VMwareWorkstation12Pro虚拟......
  • Oracle 数据库11g版本dataguard创建的简单方法
    作者:ArupNanda DataGuard了解ActiveDataGuard如何通过实时查询,同时应用归档的的日志、将物理备用数据库转换为快照备用数据库以及对基础架构的一系列改进措施,让您对备份环境的投资物有所值。下载Oracle数据库11gOracle数据库11g对DataGuard功能进行了多方面的增强,......
  • centos中自带java的路径配置
    centos自带的java,可以直接运行java,但不知道是怎么访问到的,所以就查了一下[root@aaa]#java-versionopenjdkversion"1.8.0_262"OpenJDKRuntimeEnvironment(build1.8.0_262-b10)OpenJDK64-BitServerVM(build25.262-b10,mixedmode)查看版本号,可以看到能访问ja......
  • 4.5 Java创建一个学生类
    创建一个表示学生的实体类Student,其中有学生姓名、性别和年龄信息。要求使用属性来表示学生信息,最终编写测试代码。首先定义一个名为Student的类,代码如下: 1publicclassStudent{2//学生类3} 在类中通过属性定义学生、性别和年龄,代码如下:1publicclassSt......
  • 在线问诊 Python、FastAPI、Neo4j — 创建 饮食节点
    目录饮食数据创建节点根据疾病、症状,判断出哪些饮食不能吃,哪些建议多吃饮食数据foods_data.csv建议值用“”引起来。避免中间有,号造成误识别饮食"辣椒""大蒜""芥末""海鲜""胡萝卜""核桃仁""菠菜""西红柿""香蕉"创建节点重构代码,将defexecute_write(sel......
  • 使用tkinter创建复选框
       tkinter库在开发客户端软件中应用广泛。今天介绍使用tkinter库中的checkbutton控件创建复选框。直接用实例来演示它的用法。#encoding=utf-8#Author:HaiFeng#Date:2023.09.20'''多复选框应用'''#引入第三方库fromtkinterimport*#创建调用功能函数deff......
  • openGauss学习笔记-75 openGauss 数据库管理-创建和管理序列
    openGauss学习笔记-75openGauss数据库管理-创建和管理序列75.1背景信息序列Sequence是用来产生唯一整数的数据库对象。序列的值是按照一定规则自增的整数。因为自增所以不重复,因此说Sequence具有唯一标识性。这也是Sequence常被用作主键的原因。通过序列使某字段成为唯一标识......
  • Centos7 编译安装MySQL-5.6
       CMAKE编译安装编译命令make读取makefile里面的指令,编译程序,makefile文件里调用gcc命令去编译源文件cmake命令也是一个编译命令,用于一些跨平台的编译设置编译步骤编译安装需要下载源码包、可以定制化编译参数,路径等信息,缺点就是对新手不友好。 #编译参数如......