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):
創建第二個分區
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):
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 查看!