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

  • Centos 7 how to save iptables rules like Centos 6
  • nfs tuning maximum amount of connections
  • qemu-kvm error "Could not initialize SDL(No available video device) - exiting"
  • Centos 7 tftpd will not work with selinux enabled
  • Debian Ubuntu Mint Howto Create Bridge (br0)
  • How To Control Interface that dhcpd server listens to on Debian based Linux like Mint and Ubuntu
  • LUKS unable to type password to unlock during boot on Debian, Ubuntu and Mint
  • Debian Ubuntu and Linux Mint Broken Kernel After Date - New Extra Module Naming Convention
  • Wordpress overwrites and wipes out custom htaccess rules and changes soluton
  • Apache htaccess and mod_rewrite how to redirect and force all URLs and visitors to the SSL / HTTPS version
  • python 3 pip cannot install mysql module
  • QEMU-KVM won't boot Windows 2016 or 2019 server on an Intel Core i3
  • Virtualbox vbox not starting
  • Bind / named not responding to queries solution
  • Linux Mint How To Set Desktop Background Image From Bash Prompt CLI
  • ImageMagick Convert PDF Not Authorized
  • ImageMagick Converted PDF to JPEG some files have a black background solution
  • Linux Mint Mate Customize the Lock screen messages and hide username and real name
  • Ubuntu/Gnome/Mint/Centos How To Take a partial screenshot
  • ssh how to verify your host key / avoid MIM attacks