-新增三個LVM的partition,各100M
-新增三個PV
-新增一個VG,size=100M
-新增一個LV,size=50M
-動態放大VG,size+200M
-動態放大LV,size+50M
-新增三個LVM的partition,各100M
root@new-host-6:~^G[root@new-host-6 ~]# fdisk /dev/hda
The number of cylinders for this disk is set to 1044.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): n
First cylinder (908-1044, default 908):
Using default value 908
Last cylinder or +size or +sizeM or +sizeK (908-1044, default 1044): +100M
Command (m for help): n
First cylinder (921-1044, default 921):
Using default value 921
Last cylinder or +size or +sizeM or +sizeK (921-1044, default 1044): +100M
Command (m for help): n
First cylinder (934-1044, default 934):
Using default value 934
Last cylinder or +size or +sizeM or +sizeK (934-1044, default 1044): +100M
Command (m for help): p
Disk /dev/hda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 13 104391 83 Linux
/dev/hda2 14 778 6144862+ 83 Linux
/dev/hda3 779 843 522112+ 82 Linux swap / Solaris
/dev/hda4 844 1044 1614532+ 5 Extended
/dev/hda5 844 907 514048+ 83 Linux
/dev/hda6 908 920 104391 83 Linux
/dev/hda7 921 933 104391 83 Linux
/dev/hda8 934 946 104391 83 Linux
Command (m for help): t
Partition number (1-8): 6
Hex code (type L to list codes): 8e
Changed system type of partition 6 to 8e (Linux LVM)
Command (m for help): t
Partition number (1-8): 7
Hex code (type L to list codes): 8e
Changed system type of partition 7 to 8e (Linux LVM)
Command (m for help): t
Partition number (1-8): 8
Hex code (type L to list codes): 8e
Changed system type of partition 8 to 8e (Linux LVM)
Command (m for help): p
Disk /dev/hda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 13 104391 83 Linux
/dev/hda2 14 778 6144862+ 83 Linux
/dev/hda3 779 843 522112+ 82 Linux swap / Solaris
/dev/hda4 844 1044 1614532+ 5 Extended
/dev/hda5 844 907 514048+ 83 Linux
/dev/hda6 908 920 104391 8e Linux LVM
/dev/hda7 921 933 104391 8e Linux LVM
/dev/hda8 934 946 104391 8e Linux LVM
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
重新開機,讓它生效!
[root@new-host-6 ~]# reboot
-新增三個PV
[root@new-host-6 ~]# pvcreate /dev/hda6
Physical volume "/dev/hda6" successfully created
[root@new-host-6 ~]# pvcreate /dev/hda7
Physical volume "/dev/hda7" successfully created
[root@new-host-6 ~]# pvcreate /dev/hda8
Physical volume "/dev/hda8" successfully created
驗證一下
[root@new-host-6 ~]# pvdisplay
--- NEW Physical volume ---
PV Name /dev/hda6
VG Name
PV Size 101.94 MB
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID NPXgcU-Pad8-EsG7-gFtI-hK66-8ua8-H0c78U
--- NEW Physical volume ---
PV Name /dev/hda7
VG Name
PV Size 101.94 MB
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID NeXk3q-RKtl-Ias2-TIO0-0gbq-IdU9-XuL5DC
--- NEW Physical volume ---
PV Name /dev/hda8
VG Name
PV Size 101.94 MB
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID Y9ERKn-oo61-mWj3-IOIZ-ba2p-QJID-UGzi4Q
-新增一個VG,size=100M
[root@new-host-6 ~]# vgcreate rootvg /dev/hda6
Volume group "rootvg" successfully created
驗證一下
[root@new-host-6 ~]# vgdisplay
--- Volume group ---
VG Name rootvg
System ID
Format lvm2
Metadata Areas 1
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 1
Act PV 1
VG Size 100.00 MB
PE Size 4.00 MB
Total PE 25
Alloc PE / Size 0 / 0
Free PE / Size 25 / 100.00 MB
VG UUID 2XpLIi-L1Cp-IbbB-cJ38-id6b-U6Qh-K4j3Gu
-新增一個LV,size=50M
[root@new-host-6 ~]# lvcreate -L +50M -n lv01 rootvg
Rounding up size to full physical extent 52.00 MB
Logical volume "lv01" created
驗證一下
[root@new-host-6 ~]# lvdisplay
--- Logical volume ---
LV Name /dev/rootvg/lv01
VG Name rootvg
LV UUID zWA1PJ-iy4L-PZcG-NgNw-eSue-7xmP-Tw2HNs
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 253:0
建立一個mount point: /mnt/lvm,並將其格式化成ext3檔案格式,掛載於/mnt/lvm下
[root@new-host-6 ~]# mkdir /mnt/lvm
[root@new-host-6 ~]# mke2fs -j /dev/rootvg/lv01
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
13328 inodes, 53248 blocks
2662 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=54525952
7 block groups
8192 blocks per group, 8192 fragments per group
1904 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 20 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@new-host-6 ~]# mount /dev/rootvg/lv01 /mnt/lvm/
[root@new-host-6 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/hda2 5.7G 2.9G 2.6G 53% /
/dev/hda1 99M 9.8M 84M 11% /boot
tmpfs 125M 0 125M 0% /dev/shm
/dev/hda5 487M 11M 451M 3% /home
/dev/mapper/rootvg-lv01
51M 4.9M 43M 11% /mnt/lvm
Copy一些檔案到此目錄下,以供等會驗證動態放大檔案系統時,資料不會消失
[root@new-host-6 ~]# cp -r /boot/ /mnt/lvm/
[root@new-host-6 ~]# cd /mnt/lvm/
[root@new-host-6 lvm]# ll
total 13
drwxr-xr-x 4 root root 1024 Apr 10 20:17 boot
drwx------ 2 root root 12288 Apr 10 20:15 lost+found
[root@new-host-6 lvm]#
-動態放大VG,size+200M
[root@new-host-6 lvm]# vgextend rootvg /dev/hda7 /dev/hda8
Volume group "rootvg" successfully extended
驗證一下
[root@new-host-6 lvm]# vgdisplay
--- Volume group ---
VG Name rootvg
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 300.00 MB
PE Size 4.00 MB
Total PE 75
Alloc PE / Size 13 / 52.00 MB
Free PE / Size 62 / 248.00 MB
VG UUID 2XpLIi-L1Cp-IbbB-cJ38-id6b-U6Qh-K4j3Gu
-動態放大LV,size+50M
[root@new-host-6 lvm]# lvextend -L +50M /dev/rootvg/lv01
Rounding up size to full physical extent 52.00 MB
Extending logical volume lv01 to 104.00 MB
Logical volume lv01 successfully resized
驗證一下
[root@new-host-6 lvm]# lvdisplay
--- Logical volume ---
LV Name /dev/rootvg/lv01
VG Name rootvg
LV UUID zWA1PJ-iy4L-PZcG-NgNw-eSue-7xmP-Tw2HNs
LV Write Access read/write
LV Status available
# open 1
LV Size 104.00 MB
Current LE 26
Segments 2
Allocation inherit
Read ahead sectors 0
Block device 253:0
[root@new-host-6 lvm]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/hda2 5.7G 2.9G 2.6G 53% /
/dev/hda1 99M 9.8M 84M 11% /boot
tmpfs 125M 0 125M 0% /dev/shm
/dev/hda5 487M 11M 451M 3% /home
/dev/mapper/rootvg-lv01
51M 9.1M 39M 20% /mnt/lvm
此時因為還沒執行線上更新大小的動作,所以磁區大小還不會放大喔!
這裡跟RHEL4不同,改用resize2fs 來線上更新
[root@new-host-6 lvm]# resize2fs /dev/rootvg/lv01
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/rootvg/lv01 is mounted on /mnt/lvm; on-line resizing required
Performing an on-line resize of /dev/rootvg/lv01 to 106496 (1k) blocks.
The filesystem on /dev/rootvg/lv01 is now 106496 blocks long.
[root@new-host-6 lvm]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/hda2 5.7G 2.9G 2.6G 53% /
/dev/hda1 99M 9.8M 84M 11% /boot
tmpfs 125M 0 125M 0% /dev/shm
/dev/hda5 487M 11M 451M 3% /home
/dev/mapper/rootvg-lv01
101M 9.5M 87M 10% /mnt/lvm
[root@new-host-6 lvm]# cd /mnt/lvm/
[root@new-host-6 lvm]# ll
total 13
drwxr-xr-x 4 root root 1024 Apr 10 20:17 boot
drwx------ 2 root root 12288 Apr 10 20:15 lost+found
資料沒有遺失,磁區確成功放大了!
摘自:http://hi.baidu.com/yep0213/blog/item/42445eedb50bbcd72e2e215b.html
上面為完成文章,我想要在Xenserver中新增空間,我的完整做法如下(註:我新增了一顆HDD - hdb):
#fdisk -l
#fdisk /dev/hdb
The number of cylinders for this disk is set to 1044.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): n
First cylinder (908-1044, default 908):
Using default value 908
Last cylinder or +size or +sizeM or +sizeK (908-1044, default 1044): +100000M
Command (m for help): t
Partition number (1-8): 6
Hex code (type L to list codes): 8e
Changed system type of partition 6 to 8e (Linux LVM)
Command (m for help): w
The partition table has been altered!
#reboot
#lvextend -L +100G /dev/mapper/VolGroup00-LogVol00
#resize2fs /dev/VolGroup00/LogVol00
# sync;sync;sync;shutdown -r now
PS : Delete Physical / Logical Volumes
#lvremove /dev/VolGroup00/LogVol03
以下是我在原本10G的VM加入100G的步驟:
1.shutdown VM
2.Add Storage 100G
3.start VM
4.fdisk /dev/hdb
Command (m for help): n
First cylinder (934-1044, default 934):
Using default value 934
Last cylinder or +size or +sizeM or +sizeK (934-1044, default 1044): +100000M
Command (m for help): p #看cylinder狀況
Command (m for help): t
Partition number (1): 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)
Command (m for help): w
The partition table has been altered!
5.sync;sync;sync;reboot
6.pvcreate /dev/hdb1
7.vgextend VolGroup00 /dev/hdb1
8.vgextend VolGroup00 /dev/hdb1
9.lvextend -L +99G /dev/mapper/VolGroup00-LogVol00
10.lvdisplay
11.resize2fs /dev/VolGroup00/LogVol00
完成~
沒有留言:
張貼留言