- 论坛徽章:
- 0
|
to create:
1. fdisk sdc, sdd, sde, set file type to 8e.
/dev/sdc1 1 62 497983+ 8e Linux LVM
/dev/sdc2 63 130 546210 8e Linux LVM
2. create physical volume
[email=root@vm]root@vm[/email]
:~# pvcreate /dev/sdc1 /dev/sdc2 /dev/sdd1 /dev/sde1
Physical volume "/dev/sdc1" successfully created
Physical volume "/dev/sdc2" successfully created
Physical volume "/dev/sdd1" successfully created
Physical volume "/dev/sde1" successfully created
[email=root@vm]root@vm[/email]
:~# pvscan
No matching physical volumes found
3.create volume group.
[email=root@vm]root@vm[/email]
:~# vgcreate test /dev/sdc1 /dev/sdc2 /dev/sdd1 /dev/sde1
Volume group "test" successfully created
[email=root@vm]root@vm[/email]
:~# pvdisplay
--- Physical volume ---
PV Name /dev/sdc1
VG Name test
PV Size 484.00 MB / not usable 0
Allocatable yes
PE Size (KByte) 4096
Total PE 121
Free PE 121
Allocated PE 0
PV UUID 7VkY0C-ENAP-aJgM-c3Ft-J7dK-SJBL-Mbf4hQ
...
4.create logical volume
[email=root@vm]root@vm[/email]
:~# lvcreate -L 50m -n test_lv1 test
Rounding up size to full physical extent 52.00 MB
Logical volume "test_lv1" created
[email=root@vm]root@vm[/email]
:~# lvdisplay
--- Logical volume ---
LV Name /dev/test/test_lv1
VG Name test
LV UUID CsQqLG-Qsyp-TDUb-Fdv1-Hpgx-irRm-NjT8XT
LV Write Access read/write
LV Status available
# open 0
LV Size 52.00 MB
Current LE 13
Segments 1
Allocation inherit
Read ahead sectors 0
Block device 254:4
5. make file system on lvm
[email=root@vm]root@vm[/email]
:~# mke2fs /dev/test/test_lv1
[email=root@vm]root@vm[/email]
:~# mount /dev/test/test_lv1 /mnt/
6. management
pvmove, ext2resize, lvextend...
7. remove
[email=root@vm]root@vm[/email]
:~# umount /dev/test/test_lv1
[email=root@vm]root@vm[/email]
:~# lvremove /dev/test/test_lv1
Do you really want to remove active logical volume "test_lv1"? [y/n]: y
Logical volume "test_lv1" successfully removed
[email=root@vm]root@vm[/email]
:~# vgremove test
Volume group "test" successfully removed
[email=root@vm]root@vm[/email]
:~# pvscan
PV /dev/sdc1 lvm2 [486.31 MB]
PV /dev/sdc2 lvm2 [533.41 MB]
PV /dev/sdd1 lvm2 [2.00 GB]
PV /dev/sde1 lvm2 [4.00 GB]
Total: 4 [6.99 GB] / in use: 0 [0 ] / in no VG: 4 [6.99 GB]
[email=root@vm]root@vm[/email]
:~# lvdisplay
[email=root@vm]root@vm[/email]
:~# vgdisplay
[email=root@vm]root@vm[/email]
:~# pvdisplay
--- NEW Physical volume ---
PV Name /dev/sdc1
VG Name
PV Size 486.31 MB
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID 7VkY0C-ENAP-aJgM-c3Ft-J7dK-SJBL-Mbf4hQ
...
8. code
1) kernel. in linux/driver/md/, there are several parts.
- md. for multi disk and volume management.
- dm-. device mapper, it is the interface for system calls.
- dm-crypt. for block encryption.
2) user space.
- device-mapper.1.02.19 is the library to communicate with the kernel for lvm and other applications.
- LVM2.2.02.25.
9. reference
http://sources.redhat.com/dm/
http://www.chinaunix.net/jh/4/72921.html
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/38597/showart_303331.html |
|