|
发表于 2005-8-22 14:21:55
|
显示全部楼层
决定从头再来一次:
如下.
[root@redhat ~]# fdisk -l
Disk /dev/hda: 40.0 GB, 40020664320 bytes
255 heads, 63 sectors/track, 4865 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 3824 30716248+ 83 Linux
/dev/hda2 3825 4865 8361832+ 5 Extended
/dev/hda5 3825 3947 987966 82 Linux swap
/dev/hda6 3948 4070 987966 fd Linux raid autodetect
/dev/hda7 4071 4193 987966 fd Linux raid autodetect
/dev/hda8 4194 4316 987966 fd Linux raid autodetect
/dev/hda9 4317 4439 987966 fd Linux raid autodetect
/dev/hda10 4440 4865 3421813+ 83 Linux
其中/dev/hda6 /dev/hda7 已raid成/dev/md0
mdadm -C /dev/md0 -l1 --raid-devices=2 /dev/hda6 /dev/hda7 -v
其中/dev/hda8 /dev/hda9 已raid成/dev/md1
mdadm -C /dev/md1 -l1 --raid-devices=2 /dev/hda8 /dev/hda9 -v
1.我的想法是先pvcreate /dev/md0 /dev/md1 /dev/hda10后
2.vgcreate vg0 /dev/md0 /dev/md1
3.将
lvcreate -L 1.88G -n lv0 vg0 故意把vg0空间用完它后.
mkefs -j /dev/vg0/lv0将其格式化
mount /dev/vg0/lv0 /data
4.
vgextend vg0 /dev/hda10 (这个时候vg0大小应该应该加上/dev/hda10的了)
5.
然后从vg0中拿空间给lv0
lvextend -L 5.14G /dev/vg0/lv0 (回楼上的,我此时并非用lvextend -L +5.14G /dev/vg0/lv0)
df 此时看/data应该大小不变为1.88G左右.
ext2online /dev/vg0/lv0
df
应该为5.14G左右..
这样才对.
稍会做实验..
[root@redhat ~]# pvcreate -ff /dev/md0 /dev/md1 /dev/hda10
Physical volume "/dev/md0" successfully created
Physical volume "/dev/md1" successfully created
Physical volume "/dev/hda10" successfully created
习惯两遍才会漂亮OK..
[root@redhat ~]# pvdisplay
--- NEW Physical volume ---
PV Name /dev/md0
VG Name
PV Size 964.50 MB
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID Z17kIH-JyUM-zrfh-xbWe-26fB-PrH9-V6tlkO
....
只是PV建立了,其VG没有的时候,注意Free PE是为0
[root@redhat ~]# vgcreate vg0 /dev/md0 /dev/md1
Volume group "vg0" successfully created
[root@redhat ~]# pvdisplay
--- Physical volume ---
PV Name /dev/md0
VG Name vg0
PV Size 964.00 MB / not usable 0
Allocatable yes
PE Size (KByte) 4096
Total PE 241
Free PE 241
Allocated PE 0
PV UUID CMGKo5-ueqF-kIuD-fkCX-quue-R50A-aCon7w
.....
此时建立了VG后其Free PE就为了..
[root@redhat ~]# vgdisplay
--- Volume group ---
VG Name vg0
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 2
Act PV 2
VG Size 1.88 GB
PE Size 4.00 MB
Total PE 482
Alloc PE / Size 0 / 0
Free PE / Size 482 / 1.88 GB
这是vg0的相关信息其Total PE 为482个.
[root@redhat ~]# lvcreate -L 1.88G -n lv0 vg0
Rounding up size to full physical extent 1.88 GB
Logical volume "lv0" created
[root@redhat ~]# mke2fs -j -b 4096 -R stride=8 /dev/vg0/lv0
[root@redhat ~]# mount /dev/vg0/lv0 /data
[root@redhat ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/hda1 30233896 23635892 5062192 83% /
none 124060 0 124060 0% /dev/shm
/dev/mapper/vg0-lv0 1943248 35712 1808824 2% /data
我的想法是要将/dev/hda10的空间给加到/data中去..
[root@redhat ~]# vgextend vg0 /dev/hda10
Volume group "vg0" successfully extended
此时正常哦..哈哈,其VG空间忆是我想要的了,但是lv呢...
[root@redhat ~]# vgdisplay
--- Volume group ---
VG Name vg0
System ID
Format lvm2
Metadata Areas 3
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 3
Act PV 3
VG Size 5.14 GB
PE Size 4.00 MB
Total PE 1317
Alloc PE / Size 482 / 1.88 GB
Free PE / Size 835 / 3.26 GB
VG UUID QL269u-YPXO-gUH8-yp47-iyxJ-OC8B-VYvPd8
[root@redhat ~]# lvextend -L +3.26G /dev/vg0/lv0
Rounding up size to full physical extent 3.26 GB
Extending logical volume lv0 to 5.14 GB
Logical volume lv0 successfully resized
[root@redhat ~]# ext2online /dev/vg0/lv0
ext2online v1.1.18 - 2001/03/18 for EXT2FS 0.5b
[root@redhat ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/hda1 30233896 23635900 5062184 83% /
none 124060 0 124060 0% /dev/shm
/dev/mapper/vg0-lv0 5313056 36672 5012848 1% /data
成功了...
不知道我如果在lvextend之前/data写了数据还是否可以安全的加了.
这样是不是就说明了,如果有一个区之前为lvm作过准备,今后就可以加加加了..
谢谢版主,不然这些命令我一定要翻书,现在都记下来了. |
|