先安装完unbuntu虚拟机,然后选择add device,加两块硬盘。
运行fdisk -l显示硬盘信息,应该能看到三块了,/dev/sda,/dev/sdb, /dev/sdc.
安装lvm, sudo apt-get install lvm2。准备工作基本完成。
使用fdisk进行分区,分成/dev/sdb1, /dev/sdc1, m for help, t for change id, 8e = Linux LVM. 完成后如下:
nestor@nestor-desktop:~$ sudo fdisk -l
Disk /dev/sda: 85.8 GB, 85899345920 bytes
255 heads, 63 sectors/track, 10443 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x000d09e6
Device Boot Start End Blocks Id System
/dev/sda1 * 1 5580 44821318+ 83 Linux
/dev/sda2 5581 9957 35158252+ 83 Linux
/dev/sda3 9958 10443 3903795 82 Linux swap / Solaris
Disk /dev/sdb: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x56ac033a
Device Boot Start End Blocks Id System
/dev/sdb1 1 2610 20964793+ 8e Linux LVM
Disk /dev/sdc: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x3c1fe419
Device Boot Start End Blocks Id System
/dev/sdc1 1 1305 10482381 8e Linux LVM
接着就是LVM的配置,先上几个概念:
PV: physical volumes
VG: volume groups
LV: logical volumes
将已有的物理分区映射到PV上,供VG管理:
nestor@nestor-desktop:~$ sudo pvcreate /dev/sdc1
Physical volume "/dev/sdc1" successfully created
nestor@nestor-desktop:~$ sudo pvscan
PV /dev/sdb1 lvm2 [19.99 GB]
PV /dev/sdc1 lvm2 [10.00 GB]
Total: 2 [29.99 GB] / in use: 0 [0 ] / in no VG: 2 [29.99 GB]
nestor@nestor-desktop:~$ sudo pvdisplay /dev/sdc1
--- NEW Physical volume ---
PV Name /dev/sdc1
VG Name
PV Size 10.00 GB
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID 5MjNwr-7kdM-X0bD-hXq0-WBCt-iFDq-OeM3Yc
接着创建VG,包含需要的PV:
nestor@nestor-desktop:~$ sudo vgcreate VG1 /dev/sdc1 /dev/sdb1
Volume group "VG1" successfully created
nestor@nestor-desktop:~$ vgscan
Reading all physical volumes. This may take a while...
No volume groups found
nestor@nestor-desktop:~$ sudo vgscan
Reading all physical volumes. This may take a while...
Found volume group "VG1" using metadata type lvm2
nestor@nestor-desktop:~$ sudo vgchange -a y VG1
0 logical volume(s) in volume group "VG1" now active
nestor@nestor-desktop:~$ sudo vgscan
Reading all physical volumes. This may take a while...
Found volume group "VG1" using metadata type lvm2
nestor@nestor-desktop:~$
然后就可以在VG上分配空间,创建不同大小的LV
nestor@nestor-desktop:~$ sudo lvcreate -L 500M -n LV1 VG1
Logical volume "LV1" created
nestor@nestor-desktop:~$ sudo lvcreate -L 30000M -n LV3 VG1
Logical volume "LV3" created
nestor@nestor-desktop:~$ sudo lvscan
ACTIVE '/dev/VG1/LV1' [500.00 MB] inherit
ACTIVE '/dev/VG1/LV3' [29.30 GB] inherit
格式化LV,创建和挂载LV:
nestor@nestor-desktop:~$ sudo mkfs -t ext3 /dev/VG1/LV1
nestor@nestor-desktop:~$ sudo mkdir /mnt/LV1
nestor@nestor-desktop:~$ sudo mkdir /mnt/LV3
nestor@nestor-desktop:~$
nestor@nestor-desktop:~$
nestor@nestor-desktop:~$ mount /dev/VG1/LV1 /mnt/LV1
mount: only root can do that
nestor@nestor-desktop:~$ sudo mount /dev/VG1/LV1 /mnt/LV1
nestor@nestor-desktop:~$ sudo mount /dev/VG1/LV3 /mnt/LV3
nestor@nestor-desktop:~$ sudo mount
/dev/sda1 on / type ext3 (rw,relatime,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
/sys on /sys type sysfs (rw,noexec,nosuid,nodev)
varrun on /var/run type tmpfs (rw,noexec,nosuid,nodev,mode=0755)
varlock on /var/lock type tmpfs (rw,noexec,nosuid,nodev,mode=1777)
udev on /dev type tmpfs (rw,mode=0755)
devshm on /dev/shm type tmpfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
lrm on /lib/modules/2.6.24-19-generic/volatile type tmpfs (rw)
/dev/sda2 on /home type ext3 (rw,relatime)
securityfs on /sys/kernel/security type securityfs (rw)
none on /proc/fs/vmblock/mountPoint type vmblock (rw)
gvfs-fuse-daemon on /home/nestor/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,user=nestor)
/dev/mapper/VG1-LV1 on /mnt/LV1 type ext3 (rw)
/dev/mapper/VG1-LV3 on /mnt/LV3 type ext3 (rw)
虽然不知道之后可以做什麽,先记到这里。