Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm running Ubuntu Server as a virtual machine with VirtualBox in Windows. Because I've ran out of space I resized the virtual machine size from 6 GB to 8 GB. But those 2 GB appear as "Free space" inside the Ubuntu OS.

I suspect I have to use "parted" to reallocate the "Free space".

Typing parted, then help, shows a list of commands. I want to list all partitions first so I type print free:

(parted) print free
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sda: 8590MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type      File system     Flags
        32.3kB  1049kB  1016kB            Free Space
 1      1049kB  5638MB  5637MB  primary   ext4            boot
        5638MB  5639MB  1048kB            Free Space
 2      5639MB  6441MB  802MB   extended
 5      5639MB  6441MB  802MB   logical   linux-swap(v1)
        6441MB  8590MB  2149MB            Free Space

So I want to append all Free space to number 1. How would I do that? I'm clueless :(

share|improve this question
    
You will need to move partition 2 (and 5) to the end of the disk before being able to resize 1 into the free space. –  Javier Rivera Feb 5 at 17:31
    
its better if you upload gparted screenshot. –  Avinash Raj Feb 5 at 17:33
    
Javier 2 is an extended partition.5 was present inside that extended partition.I want to know one thing whether the free space present below the extended partition or inside the extended partition. –  Avinash Raj Feb 5 at 17:35
    
if I try the move command it tells me Error: Partition /dev/sda5 is being used. You must unmount it before you modify it with Parted. –  Alexandra Feb 5 at 17:56
    
It is outside the extended partition. You can check it looking at the Start and End column in parted output. For you extended goes from 5639 to 6441, and the free space starts in 6441. You will need to do it booting from a LiveCD iso, you can't move the partition the OS is running from. –  Javier Rivera Feb 6 at 7:55

3 Answers 3

up vote 2 down vote accepted
+50

1) You need to run gparted from Live CD/USB otherwise it can't unmount your Ubuntu partitions.

2) You can then resize the primary partition to include the free space behind it (2149MB).

The remaining 2 small free sections are parted's partitioning requirement I guess, you don't need to touch these.

share|improve this answer

The free space is to the right corner. you cannot simply add extra space present somewhere on the hdd to any partitions. for your case, you need to shift 2gb adjoining your partition. this means that you have to delete your swap and the extended partition and then resize your main partition to accomodate for the extra space.. then you have to create a new partition for swap. after this is done, you have to edit the entry in /etc/fstab to change the uuid to the new swap partition.

this cannot be done within your server. you have to live boot into ubuntu desktop(preferrably), use gparted to delete partitions. note that swap cannot be deleted unless you first right click it and select swapoff. then perform the procedure.

share|improve this answer

A simple way that can stress a bit the hardware is to create a raid (1 maybe) array with mdadm with all free partition. This way you don't need to move partition but you are asking your hard drive to work a lot more.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.