Sign in with
Sign up | Sign in
Your question
Solved

Virtual Machine linux ubuntu 12.04

Last response: in Linux/Free BSD
Share
November 14, 2012 3:28:09 AM

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?

Best solution

a b 5 Linux
November 14, 2012 5:23:07 AM

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-ubun... 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.)
Share
a b 5 Linux
November 14, 2012 2:02:54 PM

To expand on Ijacks comments, the problem stems from the fact that you cannot resize partitions that are mounted. To get around this, boot from a livecd and resize the partitions from there.
m
0
l
Related resources
November 14, 2012 10:09:27 PM

skittle said:
To expand on Ijacks comments, the problem stems from the fact that you cannot resize partitions that are mounted. To get around this, boot from a livecd and resize the partitions from there.


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.
m
0
l
a b 5 Linux
November 15, 2012 5:12:16 AM

You are running from a live CD?
m
0
l
November 15, 2012 5:40:18 AM

Ijack said:
You are running from a live CD?


Yes. I have it running from a live cd
m
0
l
a b 5 Linux
November 15, 2012 6:41:49 AM

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.
m
0
l
November 15, 2012 1:35:48 PM

Ijack said:
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.


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.
m
0
l
a b 5 Linux
November 15, 2012 1:54:32 PM

You seem to be correctly booting from the Live CD. Try

umount /dev/sda1

(note the spelling of the command) and then see if GParted will let you resize it.
m
0
l
November 15, 2012 2:26:36 PM

Ijack said:
You seem to be correctly booting from the Live CD. Try

umount /dev/sda1

(note the spelling of the command) and then see if GParted will let you resize it.


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.
m
0
l
November 15, 2012 2:34:03 PM

Ijack said:
You seem to be correctly booting from the Live CD. Try

umount /dev/sda1

(note the spelling of the command) and then see if GParted will let you resize it.


Please tell me if you have trouble viewing the pic

m
0
l
a b 5 Linux
November 15, 2012 3:07:00 PM

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.
m
0
l
November 15, 2012 3:31:00 PM

Ijack said:
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.


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?
m
0
l
a b 5 Linux
November 15, 2012 4:11:15 PM

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.
m
0
l
November 15, 2012 6:38:00 PM

Ijack said:
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.


I will take a snapshot and try to fix it and let you know how that goes.
m
0
l
November 15, 2012 9:19:20 PM

Best answer selected by Skynet928.
m
0
l
November 15, 2012 9:20:18 PM

Ok so I deleted the swap partition expanded then added a swap partition of my own. Seems to be working now and I have the space I want. Thanks!
m
0
l
!