对LVM的详细介绍:LVM(Logical Volume Manager)就是逻辑卷管理器,它将多个物理分区整合在一起,让这些分区看起来像一个磁盘一样,第一就是实现系统快照,这样就可以是备份和还原就变的很简单。另一个作用是实现一个可以弹性调整容量的文件系统;下面来我们分别详细说明LVM这两个重要作用
二、逻辑卷(LV)的扩展和缩减
1、将/dev/sda5制作成LV。其步骤如下:
(1)创建分区并将其卷标改为8e。
[root@localhost ~]# fdisk /dev/sda
The number of cylinders for this disk is set to 15665.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): n
First cylinder (5367-15665, default 5367):
Using default value 5367
Last cylinder or +size or +sizeM or +sizeK (5367-15665, default 15665): +10G
Command (m for help): t
Partition number (1-5): 5
Hex code (type L to list codes): 8e
Changed system type of partition 5 to 8e (Linux LVM)
Command (m for help): n
First cylinder (6584-15665, default 6584):
Using default value 6584
Last cylinder or +size or +sizeM or +sizeK (6584-15665, default 15665): +5G
Command (m for help): t
Partition number (1-6): 6
Hex code (type L to list codes): 8e
Changed system type of partition 6 to 8e (Linux LVM)
Command (m for help): p
Disk /dev/sda: 128.8 GB, 128849018880 bytes
255 heads, 63 sectors/track, 15665 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device BootStartEndBlocksIdSystem
/dev/sda1*11310439183Linux
/dev/su盘装win8da2145235419457158eLinux LVM
/dev/sda3523653661052257+82Linux swap / Solaris
/dev/sda453671566582726717+5Extended
/dev/sda55367658397755218eLinux LVM
/dev/sda66584719248917618eLinux LVM
Command (m for help): w
以上创建了两个分区/dev/sda5和/dev/sda6其卷标都为8e
(2)将/dev/sda5创建成pv(物理卷)。
[root@localhost ~]# pvcreate /dev/sda5
Writing physical volume data to disk "/dev/sda5"
Physical volume "/dev/sda5" successfully created
[root@localhost ~]# pvdisplay /dev/sda5
"/dev/sda5" is a new physical volume of "9.32 GB"
--- NEW Physical volume ---
PV Name/dev/sda5
VG Name
PV Size9.32 GB
AllocatableNO
PE Size (KByte)0
Total PE0
Free PE0
Allocated PE0
PV UUIDX1mEFY-Hk3e-LT10-ori0-Dpz9-2ucd-VktkXg
(3)将/dev/sda5创建卷组myvg。
[root@localhost ~]# vgcreate myvg1 /dev/sda5
Volume group "myvg1" successfully created
[root@localhost ~]# vgdisplay myvg1
--- Volume group ---
VG Namemyvg1
System ID
Formatlvm2
Metadata Areas1
Metadata Sequence No1
VG Accessread/write
VG Statusresizable
MAX LV0
Cur LV0
Open LV0
Max PV0
Cur PV1
Act PV1
VG Size9.32 GB
PE Size4.00 MB
Total PE2386
Alloc PE / Size0 / 0
FreePE / Size2386 / 9.32 GB
VG UUIDwHo82H-hk3K-gK8j-vMY3-X83q-Fcof-SqT88x
(4)在myvg1上创建创建2G的LV(逻辑卷)。
[root@localhost ~]# lvcreate -L 2G -n mylv1 myvg1
Logical volume "mylv1" created
[root@localhost ~]# lvdisplay /dev/myvg1/mylv1
--- Logical volume ---
LV Name/dev/myvg1/mylv1
VG Namemyvg1
LV UUIDHIVsSx-X318-RbZl-fcTs-jy82-I59N-1Z4pre
LV Write Accessread/write
LV Statusavai怎么用u盘装系统lable
# open0
LV Size2.00 GB
Current LE512
Segments1
Allocationinherit
Read ahead sectorsauto
- currently set to256
Block device253:3
这样一个逻辑卷就创建成功了。
2、放大LV的容量。
放大LV要先扩展卷组的容量,再来扩展
[root@localhost ~]# pvcreate /dev/sda7
Writing physical volume data to disk "/dev/sda7"
Physical volume "/dev/sda7" successfully created
[root@localhost ~]# vgextend myvg1 /dev/sda7
Volume group "myvg1" successfully extended
[root@localhost ~]# vgs
VG#PV #LV #SN AttrVSizeVFree
myvg110 wz--n-4.66G3.66G
myvg1210 wz--n- 14.91G 12.91G
vol0120 wz--n- 40.00G5.84G
[root@localhost ~]# lvresize -L +1G /dev/myvg1/mylv1
Extending logical volume mylv1 to 3.00 GB
Logical volume mylv1 successfully resized
这样就将LV的容量扩大到3G了。
3、缩小LV的容量。
待续……
本文出自 “Redhat学习交流” 博客,请务必保留此出处http://qingmu.blog.51cto.com/4571483/907317
u盘装机 本文由www.upzxt.com整理!