linux-逻辑卷

本文详细介绍了Linux系统中逻辑卷的管理,从物理卷开始,经过卷组的创建,最终到逻辑卷的设置,包括如何添加分区。内容涵盖Linux磁盘扩展的基础知识,适合系统管理员学习。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

              物理卷-》卷组-》逻辑卷

   添加分区      

Command (m for help): n
All primary partitions are in use
Adding logical partition 9
First sector (50341888-62914559, default 50341888): 
Using default value 50341888
Last sector, +sectors or +size{K,M,G} (50341888-62914559, default 62914559): +1G
Partition 9 of type Linux and of size 1 GiB is set


修改分区格式

Command (m for help): t
Partition number (1-9, default 9): 9
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'

Command (m for help): p

/dev/sda7        46143488    48240639     1048576   8e  Linux LVM
/dev/sda8        48242688    50339839     1048576   8e  Linux LVM
/dev/sda9        50341888    52439039     1048576   8e  Linux LVM
保存退出

Command (m for help): w

    系统识别:

[root@localhost Desktop]# partprobe 

   创建物理卷:

[root@localhost Desktop]# pvcreate /dev/sda{8,9}
  Physical volume "/dev/sda8" successfully created
  Physical volume "/dev/sda9" successfully created

详细查看

[root@localhost Desktop]# pvdisplay 
  "/dev/sda8" is a new physical volume of "1.00 GiB"
  --- NEW Physical volume ---
  PV Name               /dev/sda8
  VG Name               
  PV Size               1.00 GiB
  Allocatable           NO
  PE Size               0  PE大小显示为0 
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               ttpcEb-kAXo-hbJP-wzRq-Xzr5-Ggu4-O0K9Jm

查看个数

[root@localhost Desktop]# pvscan 
  PV /dev/sda8         lvm2 [1.00 GiB]
  PV /dev/sda9         lvm2 [1.00 GiB]
  Total: 2 [2.00 GiB] / in use: 0 [0   ] / in no VG: 2 [2.00 GiB]

删除物理卷

[root@localhost Desktop]# pvremove /dev/sda{9,8}
  Labels on physical volume "/dev/sda9" successfully wiped
  Labels on physical volume "/dev/sda8" successfully wiped

创建查看卷组

[root@localhost Desktop]# vgcreate -s 8M myvg  /dev/sda{8,9}
  Volume group "myvg" successfully created
[root@localhost Desktop]# vgs
  VG   #PV #LV #SN Attr   VSize VFree
  myvg   2   0   0 wz--n- 1.98g 1.98g

添加删除卷组

[root@localhost Desktop]# vgreduce myvg /dev/sda8
  Removed "/dev/sda8" from volume group "myvg"
[root@localhost Desktop]# vgextend myvg /dev/sda10
  Physical volume "/dev/sda10" successfully created
  Volume group "myvg" successfully extended

创建查看逻辑卷

[root@localhost Desktop]# lvcreate -n testlv -L 1G myvg
WARNING: dos signature detected on /dev/myvg/testlv at offset 510. Wipe it? [y/n]: y
  Wiping dos signature on /dev/myvg/testlv.
  Logical volume "testlv" created.
[root@localhost Desktop]# lvs
  LV     VG   Attr       LSize Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  testlv myvg -wi-a----- 1.00g                                                    

删除逻辑卷

[root@localhost Desktop]# lvremove /dev/myvg/testlv 
Do you really want to remove active logical volume testlv? [y/n]: y
  Logical volume "testlv" successfully removed

格式化,挂载

[root@localhost Desktop]# mount /dev/myvg/testlv test7
[root@localhost Desktop]# ls /test7
ls: cannot access /test7: No such file or directory
[root@localhost Desktop]# ls test7/
lost+found

创建快照卷

[root@localhost Desktop]# cp test6 test7
[root@localhost Desktop]# ls test7
lost+found  test6
[root@localhost Desktop]# lvcreate -s -p r -L 20M -n testlv-na /dev/myvg/testlv
  Rounding up size to full physical extent 24.00 MiB
  Logical volume "testlv-na" created.

挂载快照卷

[root@localhost Desktop]# mkdir test8
[root@localhost Desktop]# mount /dev/myvg/testlv test8
[root@localhost Desktop]# ls test8
lost+found  test6
[root@localhost Desktop]# 

必须删除快照卷才可以增加逻辑卷 物理增加

[root@localhost Desktop]# lvextend -L +200M /dev/myvg/testlv 
  Size of logical volume myvg/testlv changed from 1.00 GiB (128 extents) to 1.20 GiB (153 extents).
  Logical volume testlv successfully resized.

[root@localhost Desktop]# df -lh
Filesystem               Size  Used Avail Use% Mounted on
/dev/sda3                 18G  4.7G   14G  27% /
devtmpfs                 475M     0  475M   0% /dev
tmpfs                    489M  156K  489M   1% /dev/shm
tmpfs                    489M  7.1M  482M   2% /run
tmpfs                    489M     0  489M   0% /sys/fs/cgroup
/dev/sda1                297M  144M  154M  49% /boot
tmpfs                     98M   28K   98M   1% /run/user/1000
/dev/mapper/myvg-testlv  976M  1.3M  924M   1% /home/hzk/Desktop/test7

逻辑增加

[root@localhost Desktop]# lvresize -p /dev/myvg/testlv 
[root@localhost Desktop]# df -lh

/dev/mapper/myvg-testlv  1.2G  1.6M  1.1G   1% /home/hzk/Desktop/test7


 

 





                
评论 22
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值