Изменение размера раздела виртуальной машины Linux на Xen.


Вот, простой порядок действий:
xl shutdown -w VPStest
cp /xen/domains/VPStest/VPStest.img /xen/domains/VPStest/VPStest.img_back
qemu-img resize /xen/domains/VPStest/VPStest.img 10G

kpartx -a /xen/domains/VPStest/VPStest.img

kpartx -l /xen/domains/VPStest/VPStest.img

—————————————————————————————

fdisk’ом пересоздать раздел

Удаляем:

# fdisk /dev/loop1

WARNING: DOS-compatible mode is deprecated. It’s strongly recommended to
switch off the mode (command ‘c’) and change display units to
sectors (command ‘u’).

Command (m for help): p

Disk /dev/loop1: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000acc8b

Device Boot Start End Blocks Id System
/dev/loop1p1 * 1 3917 31456256 83 Linux

Command (m for help): d
Selected partition 1

Command (m for help): p

Disk /dev/loop1: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000acc8b

Device Boot Start End Blocks Id System

Command (m for help): w
The partition table has been altered!

 

Создаем:

# fdisk /dev/loop1

WARNING: DOS-compatible mode is deprecated. It’s strongly recommended to
switch off the mode (command ‘c’) and change display units to
sectors (command ‘u’).

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-3916, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-3916, default 3916):
Using default value 3916

Command (m for help): p

Disk /dev/loop1: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000acc8b

Device Boot Start End Blocks Id System
/dev/loop1p1 1 3916 31455238+ 83 Linux

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 22: Недопустимый аргумент.
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.

Делаем раздел загрузочным:

Command (m for help): a
Partition number (1-4): 1

Command (m for help): p

Disk /dev/loop1: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000acc8b

Device Boot Start End Blocks Id System
/dev/loop1p1 * 1 3916 31455238+ 83 Linux

Command (m for help): q

———————————————————————————

kpartx -d /xen/domains/VPStest/VPStest.img

kpartx -a /xen/domains/VPStest/VPStest.img

e2fsck -f /dev/mapper/loop0p1

resize2fs /dev/mapper/loop0p1

kpartx -d /xen/domains/VPStest/VPStest.img

xl create /etc/xen/auto/VPStest.conf