<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

 

Lvm 磁盘分区

 

1df  查看分区

2umount /dev/sda5

3,mkfs.ext3 /dev/sda5

4,[root@test ~]# fdisk /dev/sda5

Command (m for help): n

Command action

   e   extended

   p   primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-504, default 1): 1

Last cylinder or +size or +sizeM or +sizeK (1-504, default 504):

 

<?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />300m

创建第二个分区

Command (m for help): n

Command action

   e   extended

   p   primary partition (1-4)

p

Partition number (1-4): 2

First cylinder (301-504, default 301): 2

Value out of range.

First cylinder (301-504, default 301): 301      

Last cylinder or +size or +sizeM or +sizeK (301-504, default 504):

350m    

Command (m for help): p

 

     Device Boot      Start         End      Blocks   Id  System

/dev/sda5p1               1         300     2409718+  83  Linux

/dev/sda5p2             301         350      401625   83  Linux

 

Command (m for help): w   (保存)

[root@test ~]#

[root@test ~]#

Command (m for help): t

Partition number (1-4): 1

Hex code (type L to list codes): 8e  

Changed system type of partition 1 to 8e (Linux LVM)

 

 

 

Command (m for help): t

Partition number (1-4): 2

Hex code (type L to list codes): 8e

Changed system type of partition 2 to 8e (Linux LVM)

 

Command (m for help): p

 

     Device Boot      Start         End      Blocks   Id  System

/dev/sda5p1               1         300     2409718+  8e  Linux LVM

/dev/sda5p2             301         350      401625   8e  Linux LVM

 

Command (m for help): w  (保存)

 

[root@test ~]# fdisk -l /dev/sda5

 

Disk /dev/sda5: 4153 MB, 4153734144 bytes

255 heads, 63 sectors/track, 504 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

     Device Boot      Start         End      Blocks   Id  System

/dev/sda5p1               1         300     2409718+  8e  Linux LVM

/dev/sda5p2             301         350      401625   8e  Linux LVM

 

 

5,建立的分区转换成PV,使用指令:pvcreate

[root@test ~]# pvcreate /dev/sda5p1

Physical volume "/dev/sda5p1" successfully created

[root@test ~]# pvcreate /dev/sda5p2

Physical volume "/dev/sda5p2" successfully created

[root@test ~]#

 

6,创建VG

然后将这些PV加入到一个VG中:

使用指令vgcreate

[root@test ~]#vgcreate vgdata /dev/sda5p1 /dev/sda5p2 

 说明:将创建的2PV加入到vg中,为这个vg取一个名字vgdate

VolUME group "vgdate"  successfully created

 

7,创建LV

创建完成VG之后,才能从VG中划分一个LV

使用指令:lvcreate

[root@test ~]#lvcreate -L 500M -n lv01 vgdate

 

创建了一个名字为lv01,容量大小是500M的分区

-L:指定LV的大小

-n:指定LV的名称

vgdate:表示从这个VG中划分LV

 

8,格式化lv

只有格式化lv之后,LV才能存储资料

使用指令:

mke2fs -j /dev/vgdate/lv01

 

9、挂载LV

mkdir /vgdate

mount /dev/vgdate/lv01 /vgdate

df -h  查看!

 

完成