XEN Image Datei vergrößern/erweitern

Manchmal kann es notwendig sein, die Disk eines virtuellen Images zu vergrößern.

Image (Disk) vergrößern

Wenn die Datei vs1.img heißt, und um 4GB vergrößert werden soll, so hilft der Befehl dd.

dd if...

$ time dd if=/dev/zero bs=1024 count=$((4000 * 1024)) >> vs1.img
4096000+0 records in
4096000+0 records out
4194304000 bytes (4,2 GB) copied, 62,7698 seconds, 66,8 MB/s

Dateisystem anpassen

  • resize2fs vs1.img
  • xfs_growfs vs1.img

Troubleshooting

Der Unix Befehl file vs1.img zeigt vs1.img: x86 boot sector, code offset 0×48. Damit ist es nicht möglich, ein resize2fs durchzuführen. Ein fdisk -l vs1.img zeigt, dass hier innerhalb des Disk-Images eine Partition angelegt ist.

fdisk vs1.img

read failed: Inappropriate ioctl for device
You must set cylinders.
You can do this from the extra functions menu.

Command (m for help): p

Disk vs1.img: 0 MB, 0 bytes
255 heads, 63 sectors/track, 0 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00035468

  Device Boot      Start         End      Blocks   Id  System
vs1.img1   *           1         509     4088511   83  Linux

Command (m for help): q

Ich traue mich also, alles im Gast durchzuführen und boote in den Single User Modus.

fdisk /dev/xvda

255 heads, 63 sectors/track, 1019 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

  Device Boot      Start         End      Blocks   Id  System
/dev/xvda1 *           1         509     4088511   83  Linux

Jetzt Löschen wir mittels d diese Partition, um sie mit dem gleichen Startwert wieder anzulegen.

fdisk /dev/xvda

n (neue)
p (primäre)
1 (Partitionsnummer)
1 (erster Zylinder)
[enter] (größter möglicher Zylinder, hier: 1019)
a (bootable Flag)
1 (diese Partition)
w (schreiben)

Leider hilft hier auch kein partprobe um den Kernel die neuen Größen bekannt zu machen, also reboot. Nach dem Reboot prüfen wir unsere Partitiontabelle.

fdisk -l /dev/xvda

Disk /dev/xvda: 8388 MByte, 8388606000 Byte
255 heads, 63 sectors/track, 1019 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

  Device Boot      Start         End      Blocks   Id  System
/dev/xvda1  *          1         1019     8185086  83  Linux

Jetzt versuchen wir es mit ext2online.

ext2online /dev/xvda

[root@builder64 ~]# ext2online -v /dev/xvda1
ext2online v1.1.18 - 2001/03/18 for EXT2FS 0.5b
new filesystem size 2046271
group 2 inode table has offset 2, not 253
group 4 inode table has offset 2, not 253
group 6 inode table has offset 2, not 253
group 8 inode table has offset 2, not 253
group 10 inode table has offset 2, not 253
group 11 inode table has offset 2, not 253
group 12 inode table has offset 2, not 253
group 13 inode table has offset 2, not 253
group 14 inode table has offset 2, not 253
group 15 inode table has offset 2, not 253
group 16 inode table has offset 2, not 253
group 17 inode table has offset 2, not 253
group 18 inode table has offset 2, not 253
group 19 inode table has offset 2, not 253
group 20 inode table has offset 2, not 253
group 21 inode table has offset 2, not 253
group 22 inode table has offset 2, not 253
group 23 inode table has offset 2, not 253
group 24 inode table has offset 2, not 253
group 26 inode table has offset 2, not 253
group 28 inode table has offset 2, not 253
group 29 inode table has offset 2, not 253
group 30 inode table has offset 2, not 253
group 31 inode table has offset 2, not 253
using 249 reserved group descriptor blocks
creating group  62 with 14655 blocks (rsvd = 249, newgd =  1)

cache direct hits: 32, indirect hits: 0, misses: 2

Es hat funktioniert.

df -h

Filesystem            Size  Used Avail Use% Mounted on
/dev/xvda1            7.7G  2.3G  5.1G  31% /
none                  250M     0  250M   0% /dev/shm

Dateisystem anpassen für NTFS

 
wissen/gpl/xen/xen-image-file-vergroessern-extend-img-and-filesystem.txt · Zuletzt geändert: 05.09.2010 20:31
 
Recent changes RSS feed Donate Valid XHTML 1.0 Valid CSS Recent cached RSS feed cacert-signed web site: inhalt.serviert.de