1

Installing Ubuntu Desktop 14.04.1 from scratch, onto a 128GB SSD drive, I got three partitions by the installer's autonomic decision. I have not configured partitions myself during the installation nor have I opted for LVM.

The partitions are:

  1. Bootable partition 86GB Ext4 (/dev/sda1)
  2. Extended partition 34GB (/dev/sda2)
  3. Swap partition 34 GB Swap (/dev/sda5)

Can I later remove the second partition and add its space to either the first or third ones? how disruptive would that operation be?

matanox
  • 2,293
  • 2
    The second is an extended partition, which contains the swap partition. You can't remove it without removing swap, also, it's just a container, and has no space of its own. Removing the second and third partitons is possible, and not really a problem, as long as swap is disabled. – mikewhatever Jan 09 '15 at 18:25
  • Use swapoff and then a livecd to remove the swap partition and add the rest of the partition to / – Fabby Jan 16 '15 at 01:21

1 Answers1

3

Linux use swap partition to increase RAM memory seen from applications - namely, it's the space in hard drive, where unused RAM is stored (if your computer does not have enough RAM).

Swap is also the place, where your RAM is stored during hibernation, ie, if you want to be able to hibernate, your swap partition must be at least as big as your RAM.

Now do some math. 86+34+34=154, while your SSD can only store 128GB. You do not have three partitions as such. You have one primary (the 86GB) partition, where you store your programs, data, boot info and more. You also have one extended (the 34GB) partition, which can be thought of as (virtual) drive having 34GB space to hold things. The installer have chosen to dedicate it for swap space - which may be wise decision, in case you don't have much RAM.

As for your question, removing second partition (virtual drive) would also remove the swap area inside it. Doing so may increase lag (if your computer lacks ram) and will for sure disable hibernation.

You should be free to shrink it, however (34GB swap partition is the largest I've seen or read about). Doing so will increase the space available for you main system.

Press super key (also known as Windows key) and type gparted. This will open the partitioning tool. You will be prompted for your password, type it. As no system allows shrinking/deleting partitions being used, you need first to unmount it.

Click on your Swap (third) partition, find partition menu, choose Unmount. When you unmount all partitions that are inside extended partition, it is automatically considered as unmounted.

Click on your Swap partition. In Free Space Preceding type how many megabytes do you want to free up for your system. Click Enter. Press >|Resize/Move button.

I'd rather suggest setting up a separate /home partition - a place where users' program settings and data are stored, but doing so isn't an easy task after one already installed Ubuntu.

So, you may simply add it to existing partition which stores everything. Just shrink extended partition in the same way as you just did with swap, and extend your primary partition by going to resize menu and increasing its size.

Check these links for detailed information https://en.wikipedia.org/wiki/Virtual_memory http://www.linux.com/news/software/applications/8208-all-about-linux-swap-space

and these for detailed instructions of how to setup your partition scheme http://www.howtogeek.com/howto/35676/how-to-choose-a-partition-scheme-for-your-linux-pc/ http://www.howtogeek.com/116742/how-to-create-a-separate-home-partition-after-installing-ubuntu/

julka
  • 299
  • Thanks @julka! I haven't noticed it's only two partitions. I assume the size of 34 GB was automatically selected to match the size of RAM (which is 32 GB on this machine)... – matanox Jan 09 '15 at 23:33
  • You only need that much swap if you want hibernation function. – julka Jan 10 '15 at 09:17
  • Actually, you would need more swap than the size of RAM, in case swap is already utilized by the operating system before the hibernation, won't you? – matanox Jan 10 '15 at 14:32
  • Not really. When I was young and handsome, rule of thumb was swap=(1.5-2)*RAM, cause systems didn't have enough RAM and used swap to extend it. Now it's no longer the case. I have only 4GB of RAM, but I only run out of it when I'm editing video or playing high end games (which I rarely do). So my swap 95% of time is empty. You have even more memory, so your swap is even cleaner. You may check by running system monitor application. – julka Jan 11 '15 at 15:24
  • 1
    @julka the rule 2*Ram=Swap is in use today, too. for examlṕle in servers. some kind of servers need somtimes a lot of memory and the most time only a bit. I am using my PC for operations which need a lot of memory (selfwritten ;-) )and I use the most time only about 50% of my 4 Gib Ram but sometimes I use additional 16 Gib Swap. – LittleByBlue Jan 11 '15 at 19:09