LVM逻辑卷


LVM逻辑卷
逻辑卷管理LVM是一个多才多艺的硬盘系统工具。无论在Linux或者其他类似的系统,都是非常的好用。传统分区使用固定大小分区,重新调整大小十分麻烦。但是,LVM可以创建和管理“逻辑”卷,而不是直接使用物理硬盘。可以让管理员弹性的管理逻辑卷的扩大缩小,操作简单,而不损坏已存储的数据。可以随意将新的硬盘添加到LVM,以直接扩展已经存在的逻辑卷。LVM并不需要重启就可以让内核知道分区的存在。 在这里插入图片描述

优点

a. 使用方便

缺点

a. 误删除数据恢复更加困难
b. LVM缩减分区大小风险较大

命令

LVM逻辑卷的使用

查看系统磁盘

使用lsblk命令,查看系统磁盘,命令如下:

[root@lvm ~]# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
vda    253:0    0  40G  0 disk 
└─vda1 253:1    0  40G  0 part /
vda1   253:1    0  20G  0 disk /mnt

创建物理卷

在创建物理卷之前,需要对磁盘进行分区。首先使用fdisk命令对vdb进行分区操作,分出两个大小为5 GB的分区,命令如下:

[root@lvm ~]# umount /dev/vdb
[root@lvm ~]# 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 0x23122c56.

Command (m for help): p
Disk /dev/vdb: 21.5 GB, 21474836480 bytes, 41943040 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: 0x23122c56

   Device Boot      Start         End      Blocks   Id  System
Command (m for help): n                            //输入n进行创建分区
Partition type:
   p   primary (0 primary, 0 extended, 4 free)          
   e   extended
Select (default p): p                                  //输入p创建主分区
Partition number (1-4, default 1):                       //默认按回车
First sector (2048-41943039, default 2048):               //默认按回车
Using default value 2048
Last sector, +sectors or +size{
   K,M,G} (2048-41943039, default 41943039): +5G
Partition 1 of type Linux and of size 5 GiB is set
Command (m for help): n
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p): p
Partition number (2-4, default 2): 
First sector (10487808-41943039, default 10487808): 
Using default value 10487808
  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值