I've been trying to get Ubuntu installed over the last few days and I'm almost there. My problem now is that I can only have one more primary partition because I already have three others. I have 28GB of unallocated space and have tried going into the Ubuntu installer and under the "something else" option creating an ext4 primary partition with mount as "/". However, once I do that the rest of the free space I set aside for swap turns into "unusable" and from then on I can't create a swap partition. So how can I get a partition for "/" and a swap area on one primary partition?

  • Can you share your disk details/partition details/snapshot of the my computer devices? do you get what I asked. //I do not have reputation to comment, probably I will try to edit the answer – user3217310 Apr 22 '14 at 1:39
  • Here's a snapshot of my partitions @user3217310 : i30.photobucket.com/albums/c340/wyattowen1/… – Mixx Apr 22 '14 at 1:44
  • can you add your unallocated 28GB to 670.34GB, it's easy and then at the time of installation make a new partition of 28 to 30 GB and do side by side installation (the 1 st option). – user3217310 Apr 22 '14 at 2:04
  • @user3217310 I would absolutely love to install it with the automatic side by side option, but the message "there is no detected operating system" shows up on the installer. – Mixx Apr 22 '14 at 2:11

You have already 3 primary partitions as you said you can create just one more primary in that case why not create a logical partition for the unallocated then split it for swap and Ubuntu

To create logical partition install Gparted when running on Ubuntu live Usb

In Gparted use the shrink option by right clicking unallocated space then create swap and os space

After this start the installation and choose something else

  • So I would boot into the LiveUSB and go into the live desktop, in Gparted shrink my C: drive, then create a new extended partition, then create two logical partitions within it? One for Ubuntu and the other for swap? @Sudheer – Mixx Apr 22 '14 at 2:18
  • not c drive ur unallocated 28 GB space if u shrink c drive ur windows will be gone – Sudheer Apr 22 '14 at 2:19
  • if u want to shrink c drive to get space shrink it from the windwos not from ubuntu, but from windows that wont work u already have 3 primary partitions – Sudheer Apr 22 '14 at 2:21
  • I'll go try it @Sudheer – Mixx Apr 22 '14 at 2:22
  • What do you mean shrinking from the windows partition won't work? I got the current unallocated space from shrinking my windows partition. @Sudheer – Mixx Apr 22 '14 at 2:35

You can create a swap file on the main partition after installation if you need to stuff Ubuntu on one partition. Please keep in mind this is an advanced topic and you can break Ubuntu if you do not do this correctly. Here is a quick summarization from Digital Ocean.

  • You can use swap on whats called a swap file instead of a swap partition so you will need to create a swap file on your Ubuntu partition (after installation of course). You create a blank un-formatted swapfile by opening terminal (Ctrl-Alt-T) and typing:

    sudo dd if=/dev/zero of=/swapfile bs=1024 count=1024k
  • Make sure to replace 1024k with how many megabytes large you want your swap file to be. Ubuntu usually makes this the size of you RAM so if you had 4 gigs of ram you would type 4096k. Also note typing sudo basically tells Ubuntu to run the dd program to run as root in other words the administrator.

  • Now we need to format the swap file so it is a proper swap file by typing:

    sudo mkswap /swapfile
  • Now if you have no errors your should be able to activate it by typing:

    sudo swapon /swapfile
  • If no errors occur at all we need to make sure to enable it at bootup. Now this involves editing a config file called fstab which can mess things up if you do not put the following information in correctly. You can open the fstab file by typing:

    sudo nano /etc/fstab
  • You can move the cursor with the arrow keys and type to edit the fstab file. We want to paste this line at the end by moving the cursor down to the end and by right clicking on terminal and pasting this:

    /swapfile       none    swap    sw      0       0
  • Now before we finish we need to set the swappiness value so Ubuntu knows when to store memory in swap. We are going to set it to 10 in this case by typing:

    echo 10 | sudo tee /proc/sys/vm/swappiness
    echo vm.swappiness = 10 | sudo tee -a /etc/sysctl.conf
  • And set the permissions so that no one but root (the administrator) can read the swap file for security purposes (optional but recommended).

    sudo chown root:root /swapfile
    sudo chmod 0600 /swapfile

Now restart to see if Ubuntu boots and swap should be set up now!

  • Thanks for the answer. However, I would much prefer a swap area partition instead of a swap file. Is this possible? @Reshurum – Mixx Apr 22 '14 at 2:13
  • It might be possible with an extended ext4 partition (which lets you have multiple partitions in one) which the Ubuntu automatic installer does with swap, but I have not done that, you can try it in the "something else" category. – Reshurum Apr 22 '14 at 2:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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