xen how to resize an image properly

The best way I could figure out is to use another guest of some sort to do this, while assigning the disk that needs to be resized to the same guest.

So say we have /dev/xvda as the guests drive and we've booted it up.

We also have /dev/xvdb (this is going to be the image/disk to be resized).

In this case it's based on an ext3/4 image.

Run e2fsck on it to ensure there are no filesystem errors.

e2fsck /dev/xvdb
e2fsck 1.41.12 (17-May-2010)
root: recovering journal
root: clean, 20868/656640 files, 250543/2621440 blocks

Remove the journal so it really becomes an ext2 filesystem (this is because it cannot be resized directly as an ext3/4)
 

tune2fs -O ^has_journal /dev/xvdb
tune2fs 1.41.12 (17-May-2010)
 

Run e2fsck again just to make sure there are no errors after removing the journal

e2fsck /dev/xvdb
e2fsck 1.41.12 (17-May-2010)
root: clean, 20868/656640 files, 217775/2621440 blocks
 

Run e2fsck on the resized image (this seems silly but you'll get an error otherwise)

resize2fs /dev/xvdb 5120M
resize2fs 1.41.12 (17-May-2010)
Please run 'e2fsck -f /dev/xvdb' first.


e2fsck -f /dev/xvdb
e2fsck 1.41.12 (17-May-2010)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
root: 20868/656640 files (0.1% non-contiguous), 217775/2621440 blocks


Resize the image to whatever you would like (if this is a template make sure you don't resize it to something smaller than the currently used space or obviously you'll have a corrupt template/image)


resize2fs /dev/xvdb 5120M
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/xvdb to 1310720 (4k) blocks.
The filesystem on /dev/xvdb is now 1310720 blocks long.

*Re-enable the journal

tune2fs -O has_journal /dev/xvdb


Tags:

xen, resize, properlythe, assigning, disk, resized, dev, xvda, ve, booted, xvdb, ext, fsck, ensure, filesystem, errors, recovering, fs, has_journal, removing, ll, inodes, sizes, directory, connectivity, reference, summary, contiguous, template, currently, corrupt, resizing, enable,

Latest Articles

  • QEMU / KVM How To Manually Create Basic Virtual Machine VM
  • Linux wlan0 check all wireless clients
  • PHP Issues With Decoding Strange Smart Quotes And Non-Standard ASCII Characters
  • /etc/iproute2/rt_tables default settings file in Linux Centos 6,7 and most other NIX's
  • bind named error solutions named[2169]: error (no valid DS) resolving / error (broken trust chain) resolving / : error (no valid RRSIG) resolving 'com/DS/IN':
  • iptables how to log ALL dropped incoming packets
  • How To Edit Linux Based NM Network Manager Connection Settings Without GUI
  • Linux Disable IPV6 Centos / Debian / Mint Howto
  • Linux use growisofs to burn a larger file on a BD-R / Bluray Disc
  • Linux partprobe/partx cannot access last and 4th partition
  • DRBD Errors Caused By Physical Corruption
  • mdadm: add new device failed for /dev/sdb4 as 3: Invalid argument solution
  • Linux named / bind how to dump, view and clear the cache!
  • Centos 6 / 7 / 8 How To Change Default nameservers in /etc/resolv.conf when using DHCP / dhclient
  • Adobe Acrobat Reader for Linux to use and view XFA Fillable Forms
  • Debian Linux Mint Ubuntu iptables save and restore settings automatically onboot and reboot
  • Why SMART is not smart at all and doesn't properly predict disk errors that cause a kernel panic or crash
  • scp: ambiguous target error and solution
  • VirtualBox How To Add iSCSI Storage using VBoxManage
  • iSCSI on Centos 7 Configuration and Setup Guide for Initiator and Target