Virtual Machine linux ubuntu 12.04

Skynet928

Distinguished
Jan 20, 2012
44
0
18,530
So I have an Ubuntu Machine that is running on my windows seven 64 bit machine. It is using virtual box and I set it for 8 gigs by mistake so I increased the size using the resize function in the command line and now the hdd is set to 30 like it was suppose to be but the internal machine still only sees 8. Is there a way for me to get linux to recognize that there is a bigger HDD now without having to reinstall and such?
 
Solution
There are a couple of ways to do this. The easiest is to boot from a live CD or USB stick and use GParted to resize the partition. http://www.howtogeek.com/114503/how-to-resize-your-ubuntu-partitions/ Just to be on the safe side you may want to take a snapshot of the VM before doing this; that way you can quickly restore it should anything go wrong.

The alternative is to create a new partition, or partitions, and mount parts of the filesystem on these. (For example, you could mount /home on its own partition.)
There are a couple of ways to do this. The easiest is to boot from a live CD or USB stick and use GParted to resize the partition. http://www.howtogeek.com/114503/how-to-resize-your-ubuntu-partitions/ Just to be on the safe side you may want to take a snapshot of the VM before doing this; that way you can quickly restore it should anything go wrong.

The alternative is to create a new partition, or partitions, and mount parts of the filesystem on these. (For example, you could mount /home on its own partition.)
 
Solution

Skynet928

Distinguished
Jan 20, 2012
44
0
18,530


I tried that but gpart won't let me do it. I can boot into it but for some reason I see three things. A 7 gig partition, a swap partition, then 22 gigs of unallocated space. I don't know how to get it to expand. The resize option only lets me shrink the partition. I can't get it to expand.
 
It may stil be mounting the file system. Check with the "mount" or "df" commands. If "/dev/sda1" (or something similar) is mounted try using "amount" to unmount it.

You might try a GParted Live CD rather than a Ubuntu one. GParted ought to be able to resize the file system unless you have used an unusual one like XFS. Ubuntu uses ext4 (or possibly ext3) by default, which GParted can handle.
 

Skynet928

Distinguished
Jan 20, 2012
44
0
18,530


How exactly would I go about unmounting it if it was that? Forgive me, I may be a tech but when it comes to linux, I'm computer stupid.

As for Gparted. I downloaded the ISO and mounted it within the VMware settings and it booted that way into the CD. Is it not the same? If so, then curse me for being lazy.

To address your other statement, yes, it says something along the lines of /dev/sda1 and it is using the ext4 system on this one.
 

Skynet928

Distinguished
Jan 20, 2012
44
0
18,530


It is saying that it was never mounted to begin with. Let me see if I can take a screenshot of it so you know what I'm dealing with.
 

Skynet928

Distinguished
Jan 20, 2012
44
0
18,530


Please tell me if you have trouble viewing the pic

Linuxpic.png
 
OK, the problem is clear now. You can't extend sda1 because of sda5 (your swap partition) immediately after it. Further complicated because it is in an extended partition. You need to move sda5 to the end of the extended partition, shrink the extended partition (sda2), and then you should have space to expand sda1.

I'm not 100% sure if GParted lets you do this. An alternative is to delete sda5 and sda2 (the extended partition), then expand sda1 to all but 1GB of the disk and create a new swap partition at the end of the disk. This will now be /dev/sda2, so you will have to edit /etc/fstab to reflect the change. I hope this makes sense.

Just to reiterate, I would recommend that you take a snapshot of the VM before doing this so that you can restore it if things go wrong.
 

Skynet928

Distinguished
Jan 20, 2012
44
0
18,530


I think I see where you are going with that but my question now is, what the heck is that swap partition doing there and what function does it serve?
 
I'm not quite sure why Ubuntu creates the swap partition in an extended partition. It serves the same purpose as the swap file in Windows. Should the system run out of RAM it will swap some data out to the swap partition. Even if you have plenty of RAM a swap partition, or file, is a good idea.
 

Skynet928

Distinguished
Jan 20, 2012
44
0
18,530


I will take a snapshot and try to fix it and let you know how that goes.