I was recently setting up a new test environment (BackTrack 5) inside a VirtualBox VM. Half way down the road of my project I realized that I was way to stingily with the amount of space I assigned to the virtual drive. Well, I thought no problem – I am going to enlarge the virtual drive. The steps would be easy:
- Enlarging the virtual drive
- Enlarging the partition holding the root file system with parted
- Enlarging the file system with resize2fs
Easy in theory. In reality it was still a little bit tricky.
Note, that everything that I describe in steps 2 and 3 also applies to a real linux machine. Step 1 is only necessary, because I happened to work inside a VM. On a real machine, step 1 would be something like copying the data of the old physical drive onto a newer bigger drive with dd or the likes.
I also realize that there may be more professional programs like partition magic, which would have saved me some trouble. But I wanted to make it work right here and there with the things I had at hand. Which was parted. Or even the plain old fdisk would have done I guess.
It also goes without saying, that before you do things like this, that you need to make a backup if the data is of any value to you at all.