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

  • FreePBX 17 How To Add a Trunk
  • Docker Container Onboot Policy - How to make sure a container is always running
  • FreePBX 17 How To Add Phones / Extensions and Register
  • Warning: The driver descriptor says the physical block size is 2048 bytes, but Linux says it is 512 bytes. solution
  • Cisco How To Use a Third Party SIP Phone (eg. Avaya, 3CX)
  • Cisco Unified Communication Manager (CUCM) - How To Add Phones
  • pptp / pptpd not working in DD-WRT iptables / router
  • systemd-journald high memory usage solution
  • How to Install FreePBX 17 in Linux Debian Ubuntu Mint Guide
  • How To Install Cisco's CUCM (Cisco Unified Communication Manager) 12 Guide
  • Linux Ubuntu Redhat How To Extract Images from PDF
  • Linux and Windows Dual Boot Issue NIC Won't work After Booting Windows
  • Cisco CME How To Enable ACD hunt groups
  • How to install gns3 on Linux Ubuntu Mint
  • How to convert audio for Asterisk .wav format
  • Using Cisco CME Router with Asterisk as a dial-peer
  • Cisco CME How To Configure SIP Trunk VOIP
  • Virtualbox host Only Network Error Failed to save host network interface parameter - Cannot change gateway IP of host only network
  • Cisco CME and C7200 Router Testing and Learning Environment on Ubuntu 20+ Setup Tutorial Guide
  • Abusive IP ranges blacklist