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

 

Lvm 磁盘分区

 

1 df  查看分区

2 umount /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 

  说明:将创建的 2 PV 加入到 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  查看!

 

完成