0

Okay so, I've got Ubuntu 16 running in a virtual machine (on a Windows 10 host but I don't think that is relevant). Right now my partition looks like that :

Current partition state

What I want to do is shrink my /dev/sda1 partition because my virtual image takes up 50GB of my host's space and that's much more than what I need. Problem is, when I try to, GParted won't let me shrink it below around 46GB, although it looks perfectly aware that only 25GB are used atm. I even tried deleting /dev/sda2 to have unallocated space on the right but it doesn't work.

Cannot shrink /dev/sda1

I tried to use google but all I can find are problems where GParted thinks that a partition is full while it's not, which is obviously not the case here.

Thanks for your help !

PS : I start GParted using "sudo gparted" in my terminal if that is of any help.

TheOdd
  • 3,012
Kishlin
  • 103
  • 1
    Virtualbox uses dynamic disks, that only take the actual amount of space needed, and can grow to the maximum space specified. If you ACTUALLY look at the size of your disk image in Windows, I think you'll see that it's less than 50GB. Cheers, Al – heynnema Oct 07 '16 at 01:56
  • Indeed. I thought the disk image was 50GB no matter what. Thanks for pointing it out to me. :) – Kishlin Oct 07 '16 at 02:01
  • 1
    You also cannot shrink a drive that is mounted. You would have to boot your VM to a Live Media, then unmount it to shrink it. In your image there, you have a Key right after the /dev/sda1 which means it is mounted and it will not let you shrink that because it is in use. It's a safety thing. – Terrance Oct 07 '16 at 02:03
  • But like they have said here that it could be dynamic, and if that is the case, the dynamic size will not shrink less than the size of the data that you have in your VM when you're not running it. – Terrance Oct 07 '16 at 02:06

1 Answers1

0

Assuming that you are using Virtualbox,

Since your goal is to actually shrink the .vdi file on the host system, if you selected Dynamic when you created it, nothing you do on the guest system will work. A virtualbox dynamic volume only expands dynamically. Even if you delete all the partitions on your guest system, the .vdi file will not shrink. It will remain the same.

Additional information

Check these instructions over here if you like, on how a .vdi file shrinking can be accomplished. The parameter you need is --compact. It can be done in a completely different way.

Stormlord
  • 6,317