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

  • 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
  • Cisco IP Phone CP-8845 8800/8900 Series How To Reset To Factory Settings Instructions
  • ls how to list ONLY directories
  • How to encrypt your SSH private key file id_rsa
  • Linux Mint 18 Disable User Name List from showing on Login Screen
  • Firefox Cannot Hit Enter Key In Address Bar and Location History Not Working
  • Cisco Unified Communications Manager / CUCM IP 8.6,10,12 Install Error Solution
  • Ubuntu Debian Mint Linux SSHD OpenSSH Server Not Starting After Reboot Solution
  • nmap how to scan for all ports and not just the 1000 most common ports
  • Windows 7,8,10 and Server 2008, 2012, 2016, 2019 Read Only Attribute Won't Go Away
  • bind / named how to make a wildcard record and retain defined A records
  • Cisco Unified Communications Manager 12 Install Errors on Proxmox/KVM
  • Local Vs Universally Administered MAC Address NIC Refuses to come up
  • Cisco Unified Communications Manager 12 CUCM 12 - How To Enable Video Calling
  • Windows 7, 8, 10, Windows Server 2008, 2012, 2016, 2019 How To AC97 Audio Drivers and Other Unsigned Drivers
  • Cisco Unified Communications Manager / CUCM IP Telephony Definitions