1. 登录到XenServer。
2. 修改虚拟机磁盘大小
3. 启动虚拟机
4. 修改分区大小
[root@iskytest04db ~]#df
-h
Filesystem Size
Used Avail Use% Mounted on
/dev/xvda2 86G
57G 29G 67% /
devtmpfs 2.8G
0 2.8G 0% /dev
tmpfs 2.8G 0
2.8G 0% /dev/shm
tmpfs 2.8G
8.6M 2.8G 1% /run
tmpfs 2.8G 0
2.8G 0% /sys/fs/cgroup
tmpfs 570M 0
570M 0% /run/user/0
[root@iskytest04db ~]#fdisk /dev/xvda
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until
you decide to write them.
Be careful before using the write command.
Command (m for help):p
Disk /dev/xvda: 322.1 GB, 322122547200
bytes, 629145600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes /
512 bytes
I/O size (minimum/optimal): 512 bytes / 512
bytes
Disk label type: dos
Disk identifier: 0x0009a7e1
Device Boot Start End Blocks
Id System
/dev/xvda1 2048
30722047 15360000 82
Linux swap / Solaris
/dev/xvda2
* 30722048 209715199
89496576 83 Linux
Command (m for help):d
Partition number (1,2, default 2):2
Partition 2 is deleted
Command (m for help):n
Partition type:
p primary (1 primary, 0
extended, 3 free)
e extended
Select (default p):p
Partition number (2-4, default 2):2
First sector (30722048-629145599, default
30722048):
Using default value 30722048
Last sector, +sectors or +size{K,M,G} (30722048-629145599,
default 629145599):
Using default value 629145599
Partition 2 of type Linux and of size 285.4
GiB is set
Command (m for help):t
Partition number (1,2, default 2):2
Hex code (type L to list all codes):8e
Changed type of partition 'Linux' to 'Linux
LVM'
Command (m for help):p
Disk /dev/xvda: 322.1 GB, 322122547200
bytes, 629145600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes /
512 bytes
I/O size (minimum/optimal): 512 bytes / 512
bytes
Disk label type: dos
Disk identifier: 0x0009a7e1
Device Boot Start End Blocks
Id System
/dev/xvda1 2048 30722047
15360000 82 Linux swap / Solaris
/dev/xvda2 30722048 629145599
299211776 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 or after you run
partprobe(8) or kpartx(8)
Syncing disks.
[root@iskytest04db ~]#reboot
[root@iskytest04db ~]# xfs_growfs /dev/xvda2
[root@iskytest04db ~]#df -h
Filesystem Size
Used Avail Use% Mounted on
/dev/xvda2 286G
57G 229G 20% /
devtmpfs 2.8G
0 2.8G 0% /dev
tmpfs 2.8G 0
2.8G 0% /dev/shm
tmpfs 2.8G
8.6M 2.8G 1% /run
tmpfs 2.8G 0
2.8G 0% /sys/fs/cgroup
tmpfs 570M 0
570M 0% /run/user/0