PDA

View Full Version : [SOLVED] how to grab extra space in extended partition



eddski
May 14th, 2010, 06:00 AM
I have my ubuntu distro in an extended partition and i have some room at the end of the extended partition. is there a way to use some of that room for other partitions inside the extended partition? can i only add size if it directly adjacent to the empty space?. Ex. my /home is 60% full and I give it more space, can it be done? thanks in advance

Paqman
May 14th, 2010, 06:05 AM
You can slide partitions across so that the empty space is anywhere, but it will be very slow, because it basically involves copying the whole partition from one place to another.

To make any changes to partitions that your system is on, you'll need to boot up into your LiveCD. Partitions can't be modified while they're in use. By default the LiveCD also mounts your swap partition to improve performance. To unmount it, simply right click on it in Gparted and "swapoff".

BoneKracker
May 14th, 2010, 06:29 AM
Back up your data first.

srs5694
May 14th, 2010, 06:53 AM
Another option is to create a new partition wherever it's convenient in partition/physical layout terms and then mount that partition where it's convenient in directory structure terms. For instance, if you've got 50GB of free space that's not adjacent to your /home partition but you want to expand /home space to store digital photos, you could create a 50GB partition, mount it at /home/yourname/photos, and then create or copy digital photos into /home/yourname/photos. This is not as flexible as expanding /home because you'll be limited to 50GB for /home/yourname/photos and you won't be able to use that space for other purposes. (Well, not without employing other workarounds, such as additional partition splits or symbolic links.)

FWIW, it's awkward changes like this that make me like Logical Volume Management (LVM). (http://tldp.org/HOWTO/LVM-HOWTO/) Instead of putting filesystems on inflexible partitions, you put them on logical volumes, which can be added, deleted, expanded, and shrunk much like files, without concern for where they exist on a disk, in a sector-by-sector sense.

BoneKracker
May 14th, 2010, 07:23 AM
I started to say that but was feeling lazy. :)

That's also a good way to have an encrypted directory for sensitive stuff, to put more restrictive mount options on a subset of your files, or to use a different filesystem for a particular type of file (e.g. a whole lot of small files or huge files).

LVM makes sense on a stable system or one with rolling release (where you're not rebuilding it every six months because somebody dropped the "upgrade" bomb on you).

Elfy
May 14th, 2010, 07:27 AM
I would +1 the make a new partition and mount it option.

What you need to remember as well is that to add space to a logical partition inside the extended - you need to resize the extended before it will be there for to add to the logical.

+1 to back up as well ;)

eddski
May 15th, 2010, 11:30 PM
thanks guys, it worked exactly to what I wanted and more(a complete backup)! The only problem is it took a very long time. I had to move the swap file, maybe that's why ,but thanks again for the instructions.

BoneKracker
May 16th, 2010, 12:12 AM
Glad you succeeded.

For future reference, moving the swapfile was a waste of time. Swap is throw-away.

Assuming you were booted from a CD, your on-disk swap filesystem is trash. You could have just deleted the partition and made a new one in the new location (with the command 'mkswap /dev/whatever'. Much faster.

Even if you were using some kind of live cd that's too smart for its own good and automatically making use of your on-disk swap partition, you just say 'swapoff /dev/whatever' and then delete the partition.

eddski
May 16th, 2010, 11:50 PM
for bonekracker, could you give me a little more info on those commands, im still new, sorry about that.

BoneKracker
May 17th, 2010, 03:44 AM
Some live cds will look for a swap partition on the disk and activate it. Some won't. I don't know if yours does. If you boot up from the cd, open gparted, and can delete the swap partition, then you don't need to know any of this for now (unless you're just interested).

More information on those commands:
Open a terminal and type
man swapoff
(press q to exit)

Then type
man mkswap

For some other time: There is a man page for virtually every command on a Unix-like system. (Try 'man man' first, to learn about the man pages (manuals). Then to learn some command-line basics, explore 'man cd', 'man ls', 'man less', 'man cp', 'man mv', 'man chown', 'man chmod'. To edit a file in the terminal, you can just type 'nano filename'.

As a quick example for above:

To see what you're swap partition is, just type:
grep swap /etc/fstab

(see 'man grep'; grep is how you search for a line in a file; grep is very useful and fast)

Let's say that says your swap parition is "/dev/sda8".

To turn off swap, you can type:

swapoff /dev/sda8

Or, to turn off all swap, you can just do

swapoff -a

Then you would proceed with what you were doing (I think you were using gparted). After you had deleted the swap partition, made the extended partition larger, and created a new partition to hold swap, you would put a swap filesystem on that partition. I gave you a command to do that (mkswap), but it occurs to me now that you can also put filesystems on partitions using gparted, so you don't really need it. Anyway, it works just like the above:

mkswap /dev/sda8

eddski
May 17th, 2010, 07:38 AM
thanks, i need to remember to look at man pages