RAW filesystem resize

  • Thread starter Thread starter Tuxxin
  • Start date Start date
T

Tuxxin

Guest
We have some templates that are 10Gb. When you deploy a VM with say a 15Gb hard disk, deploy the RAW onto that disk and start the VM the partitions are still only 10Gb, with fdisk showing 15Gb's. I have tried "qemu-img resize centos.tester-5.8.raw +5G" which made the images 15Gb's but still only had a 10Gb partition.

How can we resize the partition on the RAW file before dumping it into the allocated virtual disk drive?

Thanks.
 
You are confused with disk images and partition. A disk image (.img, .raw, .qcow, whatever) is "a harddisk in a file". You create one or multiple filesystems on that "virtual harddisk" just as you would on a real harddisk. So, if you create a 15 GB "virtual harddisk" and deploy a 10 GB partition on it, yes that partition will still be 10G when its done. You are deploying a raw image, which I assume means that you are duplicating a raw disk image onto your new disk image. That means your partition table is also copied. The end result is that your 15G harddisk has 5G free space at the end of the "drive".

To expand the partition to 15GB, you need resize2fs. See: http://linux.die.net/man/8/resize2fs

Keep in mind, resize2fs (afaik) only resizes to the extend where it doesn't need to shift partitions. So, eg:

You have a 15GB drive:
- /dev/vda1 is 10G and starts at the beginning of the drive
- /dev/vda2 is 1G (swap) and starts after /dev/vda1
- There is 4G free starting from the end of /dev/vda2 to the end of the drive.

With the above setup (which is quite common, as most Linux installers make the swap partition the secondary partition) you cannot simply resize /dev/vda1 to 14G, because /dev/vda2, your swap partition, is in the way. You would have to remove /dev/vda2, recreate it at the end of the drive. Only then can you resize2fs your /dev/vda1.
 
You are confused with disk images and partition. A disk image (.img, .raw, .qcow, whatever) is "a harddisk in a file". You create one or multiple filesystems on that "virtual harddisk" just as you would on a real harddisk. So, if you create a 15 GB "virtual harddisk" and deploy a 10 GB partition on it, yes that partition will still be 10G when its done. You are deploying a raw image, which I assume means that you are duplicating a raw disk image onto your new disk image. That means your partition table is also copied. The end result is that your 15G harddisk has 5G free space at the end of the "drive".

To expand the partition to 15GB, you need resize2fs. See: http://linux.die.net/man/8/resize2fs

Keep in mind, resize2fs (afaik) only resizes to the extend where it doesn't need to shift partitions. So, eg:

You have a 15GB drive:
- /dev/vda1 is 10G and starts at the beginning of the drive
- /dev/vda2 is 1G (swap) and starts after /dev/vda1
- There is 4G free starting from the end of /dev/vda2 to the end of the drive.

With the above setup (which is quite common, as most Linux installers make the swap partition the secondary partition) you cannot simply resize /dev/vda1 to 14G, because /dev/vda2, your swap partition, is in the way. You would have to remove /dev/vda2, recreate it at the end of the drive. Only then can you resize2fs your /dev/vda1.

I get that - the issue is we didn't have a swap partition ... AT ALL ... and it still won't resize. I ran cfdisk and tried to maximize the partition. Finally I just got it to work now with fdisk manually and then resize2fs

not sure why though
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!