首页 > 系统相关 >Linux系统下创建LV(逻辑卷)并挂载

Linux系统下创建LV(逻辑卷)并挂载

时间:2023-09-27 18:35:03浏览次数:50  
标签:vdb1 bytes dev LV vdb Linux 挂载 512

1、查看磁盘情况

[root@ecs-34a8-0913916 ~]# fdisk -l

Disk /dev/vda: 107.4 GB, 107374182400 bytes, 209715200 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: 0x000bcc64

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1            2048     8390655     4194304   82  Linux swap / Solaris
/dev/vda2   *     8390656   209715166   100662255+  83  Linux

Disk /dev/vdb: 1073.7 GB, 1073741824000 bytes, 2097152000 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: 0x1f1ab182

   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1            2048  2097151999  1048574976   83  Linux

可以看到有个/dev/vdb1的磁盘分区待使用。

如果没有/dev/vdb1的分区的话,需要对磁盘/dev/vdb先进行分区。

2、系统标识符

[root@ecs-34a8-0913916 ~]# 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.


Command (m for help): p

Disk /dev/vdb: 1073.7 GB, 1073741824000 bytes, 2097152000 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: 0x1f1ab182

   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1            2048  2097151999  1048574976   83  Linux

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): p

Disk /dev/vdb: 1073.7 GB, 1073741824000 bytes, 2097152000 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: 0x1f1ab182

   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1            2048  2097151999  1048574976   8e  Linux LVM

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

输入 改变分区1的属性

输入 查看有个属性对应的命令

输入 8e 改变分区1为 Linux LVM格式

输入 p 打印分区情况,发现建立的分区 /dev/vdb1 为 Linux LVM 格式

输入w保存退出(q为不保存修改退出)

3、创建PV

[root@ecs-34a8-0913991 ~]# pvcreate /dev/vdb1
WARNING: xfs signature detected on /dev/vdb1 at offset 0. Wipe it? [y/n]: y
  Wiping xfs signature on /dev/vdb1.
  Physical volume "/dev/vdb1" successfully created.
[root@ecs-34a8-0913991 ~]# 
[root@ecs-34a8-0913991 ~]# vgcreate vg_vdb /dev/vdb1
  Volume group "vg_vdb" successfully created
[root@ecs-34a8-0913991 ~]# vgdisplay 
  --- Volume group ---
  VG Name               vg_vdb
  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               <1000.00 GiB
  PE Size               4.00 MiB
  Total PE              255999
  Alloc PE / Size       0 / 0   
  Free  PE / Size       255999 / <1000.00 GiB
  VG UUID               rnjRTf-Nwaz-vB0F-a2Yv-WK1b-QNwb-WswEf6

创建PV:pvcreate /dev/vdb1

查看PV:pvdisplay

4、创建 VG

[root@ecs-34a8-0913991 ~]# vgcreate vg_vdb /dev/vdb1
  Volume group "vg_vdb" successfully created
[root@ecs-34a8-0913991 ~]# vgdisplay 
  --- Volume group ---
  VG Name               vg_vdb
  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               <1000.00 GiB
  PE Size               4.00 MiB
  Total PE              255999
  Alloc PE / Size       0 / 0   
  Free  PE / Size       255999 / <1000.00 GiB
  VG UUID               rnjRTf-Nwaz-vB0F-a2Yv-WK1b-QNwb-WswEf6
   

创建VG:vgcreate vg_vdb /dev/vdb1

查看VG:vgdisplay

这样我们就创建了一个 1000G(255999 个PE,要记住这个数字)的VG(名字为vg_vdb

 

5、创建LV

[root@ecs-34a8-0913991 ~]# lvcreate -l 255999 -n lv_vdb vg_vdb
  Logical volume "lv_vdb" created.

创建LV:lvcreate -l 255999 -n lv_vdb vg_vdb (255999是VG中PE的个数)

查看LV:lvdisplay

[root@ecs-34a8-0913991 ~]# lvdisplay 
  --- Logical volume ---
  LV Path                /dev/vg_vdb/lv_vdb
  LV Name                lv_vdb
  VG Name                vg_vdb
  LV UUID                HNgtI1-OSYg-GRmk-xBMB-VwxR-CdJv-pWyBMq
  LV Write Access        read/write
  LV Creation host, time ecs-34a8-0913991, 2023-09-27 18:07:35 +0800
  LV Status              available
  # open                 1
  LV Size                <1000.00 GiB
  Current LE             255999
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           252:0
   

6、格式化刚刚创建的LV

# mkfs -t ext4 /dev/vg_vdb/lv_vdb
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
65536000 inodes, 262142976 blocks
13107148 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2409627648
8000 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

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

7、挂载磁盘

[root@ecs-34a8-0913991 ~]# mkdir /data01
[root@ecs-34a8-0913991 ~]# mount /dev/vg_vdb/lv_vdb /data01

8、加入开机自启/etc/fstab

标签:vdb1,bytes,dev,LV,vdb,Linux,挂载,512
From: https://www.cnblogs.com/justtosee/p/17733391.html

相关文章

  • Linux vi替换字符串
     1.基本的替换 :s/vivian/sky/替换当前行第一个vivian为sky :s/vivian/sky/g替换当前行所有vivian为sky :n,$s/vivian/sky/替换第n行开始到最后一行中每一行的第一个vivian为sky :n,$s/vivian/sky/g替换第n行开始到最后一行中每一行所有vivian为sky......
  • [转载] linux下 GCC编译链接静态库&动态库
    转载自:https://www.cnblogs.com/thechosenone95/p/10605172.html#_label0静态库有时候需要把一组代码编译成一个库,这个库在很多项目中都要用到,例如libc就是这样一个库,我们在不同的程序中都会用到libc中的库函数(例如printf),也会用到libc中的变量(例如以后要讲到的environ变量)。......
  • linux上如何使用docker部署前后端分离项目(含部署多个前端页面的方法)
    (目录)前言使用前一段时间写的前后端分离开发的简单小项目,确保本地可以启动部署所需镜像汇总mysql镜像2.后端工程自定义镜像3.nginx镜像<fontcolor=red>下面介绍部署过程</font>一、mysql镜像(1)拉取mysql镜像选择使用的mysql版本,我用的是8.0.33dockerpullmysql......
  • 10 分钟学会Linux常用 bash命令
    目录1.基本操作1.1.文件操作1.2.文本操作1.3.目录操作1.4.SSH,系统信息&网络操作2.基本Shell编程2.1.变量2.2.字符串替换2.3.函数2.4.条件2.5.循环3.技巧4.调试1.BasicOperationsa.export显示所有的环境变量,如果你想获取某个变量的详细信息,使用echo......
  • 怎么修改linux的root@后面的名称
    场景.登录服务器,root后面的名称是随机的,想自定义名称建议,直接使用命令执行hostnamectlset-hostnamerdd-test重新连接即可生效,实际也是修改了/etc/hostname名称需要重启机子输入命令:vim/etc/hostname进入文件,修改并保存;只有重启之后,更改的主机名才可以生效。......
  • linux中backport printk和front printk的区别
    在Linux内核中,"backportprintk"和"frontprintk"都是用于记录内核消息和调试信息的机制,但它们的工作方式和使用场景有一些区别。"backportprintk"是一种在内核中记录消息和调试信息的机制,可以将这些信息输出到控制台、串口、网络等目标。它通常用于在内核启动过程中的早期阶段,......
  • 深入浅出Ret2dlresolve
    深入浅出探究Ret2dlreslove前言  这个手法是国外作者在2015年提出的,当时的的漏洞利用通常包含两个阶段:第一步先通过信息泄露获得程序的内存布局;第二步才进行实际的漏洞利用。但就是有时候获得不到程序的内存布局,或者获得的被破坏的内存有时不可靠。于是作者提出了ret2dl-res......
  • Linux0.11代码浅析
    Linux0.11"pulloneselfupbyone'sbootstraps"......
  • Linux Bash 提示符的一些骚操作
    如何设置Bash提示符Bash提示符是通过环境变量PS1(提示符字符串1PromptString1)来设置的,它用于交互式shell提示符。当然如果你需要更多的输入才能完成一个Bash命令时,PS2环境变量就是用来设置多行提示符的:[dneary@dhcp-41-137~]$exportPS1="[LinuxRulez]$"[Lin......
  • 50、linux修改虚拟机的时间
    1、查看当前时区与电脑端实际时间不一致 2、修改时区 再次查看发现时间已同步时区 ......