Chinaunix首页 | 论坛 | 博客
  • 博客访问: 9982493
  • 博文数量: 1669
  • 博客积分: 16831
  • 博客等级: 上将
  • 技术积分: 12594
  • 用 户 组: 普通用户
  • 注册时间: 2011-02-25 07:23
个人简介

柔中带刚,刚中带柔,淫荡中富含柔和,刚猛中荡漾风骚,无坚不摧,无孔不入!

文章分类

全部博文(1669)

文章存档

2023年(4)

2022年(1)

2021年(10)

2020年(24)

2019年(4)

2018年(19)

2017年(66)

2016年(60)

2015年(49)

2014年(201)

2013年(221)

2012年(638)

2011年(372)

分类:

2012-12-25 15:30:39

怎样调整XenServer下面Linux虚拟机的磁盘大小+Citrix中文技术博客  

2012-12-24 19:41:11|  分类: 虚拟化-XenServer |  标签: |字号 

 

(2011-10-10 12:09)
   Xenserver6.0 ,Vsphere5.0的虚拟磁盘只能增加容量,不能减少!

 

登录到XenServer。
修改虚拟机磁盘大小
xe vdi-resize uuid=17e350e3-1528-4e8f-965b-d33d352e73ed disk-size=40GiB
启动虚拟机
修改分区大小
fdisk /dev/xvda
The number of cylinders for this disk is set to 5221.
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): p
Disk /dev/xvda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/xvda1 * 1 13 104391 83 Linux
/dev/xvda2 14 2610 20860402+ 8e Linux LVM



Command (m for help): Command (m for help): p
DOS Compatibility flag is not set
Command (m for help): d
Partition number (1-4): 2
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (14-5221, default 14):
Using default value 14
Last cylinder or +size or +sizeM or +sizeK (14-5221, default 5221):
Using default value 5221
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
Disk /dev/xvda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/xvda1 * 1 13 104391 83 Linux
/dev/xvda2 14 5221 41833260 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.
重启虚拟机:reboot
调整PV大小
pvs
PV VG Fmt Attr PSize PFree
/dev/xvda2 VolGroup00 lvm2 a- 19.88G 0
pvresize -v /dev/xvda2
Using physical volume(s) on command line
Archiving volume group "VolGroup00" metadata (seqno 3).
Resizing physical volume /dev/xvda2 from 636 to 1276 extents.
Resizing volume "/dev/xvda2" to 83666136 sectors.
Updating physical volume "/dev/xvda2"
Creating volume group backup "/etc/lvm/backup/VolGroup00" (seqno 4).
Physical volume "/dev/xvda2" changed
1 physical volume(s) resized / 0 physical volume(s) not resized
pvs
PV VG Fmt Attr PSize PFree
/dev/xvda2 VolGroup00 lvm2 a- 39.88G 20.00G
调整LV大小
lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
LogVol00 VolGroup00 -wi-ao 17.84G
LogVol01 VolGroup00 -wi-ao 2.03G
lvextend -l +100%FREE /dev/VolGroup00/LogVol00
Extending logical volume LogVol00 to 37.84 GB
Logical volume LogVol00 successfully resized
lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
LogVol00 VolGroup00 -wi-ao 37.84G
LogVol01 VolGroup00 -wi-ao 2.03G
调整分区大小
df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
5.7G 4.5G 950M 83% /
/dev/xvda1 99M 22M 73M 24% /boot
tmpfs 2.0G 0 2.0G 0% /dev/shm
resize2fs /dev/mapper/VolGroup00-LogVol00
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/mapper/VolGroup00-LogVol00 is mounted on /; on-line resizing required
Performing an on-line resize of /dev/mapper/VolGroup00-LogVol00 to 9920512 (4k) blocks.
The filesystem on /dev/mapper/VolGroup00-LogVol00 is now 9920512 blocks long.
df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
37G 4.5G 31G 13% /
/dev/xvda1 99M 22M 73M 24% /boot
tmpfs 2.0G 0 2.0G 0% /dev/shm
任务完成

 

 

1.添加虚拟机硬盘,首先查看所新建硬盘所在sr-uuid:

1 xe sr-list


新建VDI:

1 2 xe vdi-create sr-uuid= type=user virtual-size=1GiB name-label= b9fa32eb-3041-4f82-8e67-f2e2fa8baf8f #新建的vdi-uuid


新建VBD:

1 2 xe vbd-create vdi-uuid= vm-uuid= device=1 VM硬盘编号,从0开始 2f25f904-24c9-bf2b-eca4-86fab90f769e #新建的vbd-uuid


应用VBD:

1 xe vbd-plug uuid=


VDI与VBD的关系:http://blog.onovps.com/archives/xenserver-sr-vdi.html
2.扩充虚拟机硬盘,首先关闭要扩充硬盘的虚拟机.

1 xe vm-shutdown vm=


查看要增加容量的vdi-uuid:

1 xe vm-disk-list vm=


扩充容量:

1 xe vdi-resize uuid= disk-size=30GiB


扩充完成,然后重新启动虚拟机,进入系统将硬盘扩充到虚拟机

 

 



Citrix中文技术博客:
阅读(1245) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~