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.

Good evening everyone , I got a little issue with Swap Partitions. Due to some issues after installing Ubuntu first time, I reinstalled it and now I have 3 Swaps. Here is sudo fdisk -l result

Disk /dev/sda: 750.2 GB, 750156374016 bytes
255 heads, 63 sectors/track, 91201 cylinders, total 1465149168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0xaa9693fe

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048    52430847    26214400   1c  Hidden W95 FAT32 (LBA)
/dev/sda2   *    52430848   540677076   244123114+   7  HPFS/NTFS/exFAT
/dev/sda3       540678142  1465147391   462234625    5  Extended
Partition 3 does not start on physical sector boundary.
/dev/sda5      1452750848  1465147391     6198272   82  Linux swap / Solaris
/dev/sda6      1440352256  1452742655     6195200   82  Linux swap / Solaris
/dev/sda7       540678144  1427951615   443636736   83  Linux
/dev/sda8      1427953664  1440339967     6193152   82  Linux swap / Solaris

So Swaps in /dev/sda5 and /dev/sda6 are no longer in use as far as I understand and thus I was planning to delete them, however faced a problem. What I did is download and burn Gparted Live CD and boot it up, tried to delete those partitions but I have no idea how to add 12GB unallocated memory to the existing OS partition in this case to /dev/sda7 Is there anyway I can delete 2 swaps and extend unallocated memory to /dev/sda7 partion?

Thank you in advance!

share|improve this question
add comment

3 Answers 3

up vote 2 down vote accepted

I find using gparted much easier for this, since it shows the actual layout order for the partitions. Using gparted, I would probably delete sda8 and sda6, and leave sda5, which is already at the end, and edit fstab to use sda5. Then it's easy to grow sda7 to use the space above it that was being used by the swap drives.

To edit /etc/fstab is not hard; if you don't know how, I can tell you the details, but the basic drill is to run sudo blkid -c /dev/null in a terminal to get a list of all the UUIDs. The addition of the "-c /dev/null" just insures that it doesn't use a cache, so you get any recent changes. Once you get the UUID for sda5, simply substitute it for the existing on in your fstab file. You will need to edit it using sudo, and a text editor such as gedit or vim.

Lines starting with "#" are comments. The line to change will look something like this:

# swap was on /dev/sda8 during installation

UUID=000-0000-0000-0000-00000000 none swap sw 0 0.

The UUID (shown as all zeros) is made up of hexadecimal digits (the letters A-F, plus numbers). The results of blkid will look similar

To delete the swap file, you may need to disable it (right-click and select swapoff in gparted).

EDIT: More details for user.

You will need to use a live CD with gparted. Either the gparted lived CD or the install CD will work. It's pretty easy, actually. The first thing to do after running gparted is to select your disk drive in the upper-right, if it's not shown. It may be

You will see a representation of your disk layout at the top of the window. You should have all 3 swap drives at the end, on the right, labeled sda8, sda6, sda5. The numbering isn't by position. To grow sda7, you need to have space adjacent to it, so you will not delete the swap drive furthest to the right.

All you have to do is click on the partition, either on the top graphic, or the list below. The swap drive will say "Linux-swap" in the column for File System, and there's really no danger of deleting the wrong swap drive, unless you're really low on memory, possibly. In fact, I just discovered my swap drive has been disabled for a while.

So, right-click on each of the two near, but not at, the end (leave the one at the end) and select "Swapoff". You should then be able to delete them when you right-click. Then, right click on the main sda7 partition, and select "resize/move", and then grab the right-hand side and drag it as far to the right as you can.

This doesn't do anything yet. You have to select "Apply all operations" from the Edit menu, or click the checkmark toolbar button. That's it.

share|improve this answer
    
Can you please explain it more detail, cause this is my first time a mess with Ubuntu partitions and thus beware of braking something. –  Nikki Kononov Apr 13 '12 at 18:23
    
OK, I will edit my main answer now. –  Marty Fried Apr 14 '12 at 1:40
    
Alright, Thank everyone who replied to my Issue I really appreciate that. One more question left thou, should I edit /etc/fstab to use it new Swap or not ? Gparted will do everything ? –  Nikki Kononov Apr 14 '12 at 7:59
    
I think you will need to, assuming it was not using sda5 originally. All you need to do is replace the old UUID with the one for sda5. It really isn't at all hard to do, and once you understand how it works, you will know how to do some more interesting things with your system. Lines starting with "#" are comments. The line to change will look something like this: ` UUID=000-0000-0000-0000-00000000 none swap sw 0 0`. The UUID is made up of hexadecimal digits (the letters A-F, plus numbers). The results of blkid will look similar –  Marty Fried Apr 14 '12 at 15:21
1  
Thank you very much! And ALL people who posted here useful information as well. –  Nikki Kononov Apr 14 '12 at 16:39
add comment

Please, before do this, I recomend to wait until someone validate this answer. If somethign go wrong, tell me and I will help you.

Use the program gparted, it will do the work for you. If you haven't got the program, install it from software center.

when you open the program this is shown: enter image description here

Then, you will have a lot of "linux-swap" partitions.

Then right click and delete If you can not delete the partitions: In a terminal put:

sudo swapoff

And now your swap partitions are unmounted. So in gparted, delete the partitions you want to delete. After that, type in terminal:

sudo swapon

And the swap partitions not deleted will be mounted.

If an error is get by the swapon, you have to change the fstab like the answer above mine told you. I can explain in more details if it is necessary.

share|improve this answer
    
Mostly correct. But you can swapon and swapoff via gparted, with right-click and "Swap off" and "Swap On" and the likes. Note though I'd strongly recommend doing this from a LiveCD or LiveUSB, but that's just me (I don't like modifying my partitions on disk while that disk is booted to) –  Thomas W. Apr 13 '12 at 20:42
    
He already said he has a gparted live cd. This is not a recommendation, but a necessity, since you can't resize a mounted partition. –  Marty Fried Apr 14 '12 at 1:40
add comment

For the other ask. You want to allocate the swap partitions that are deleted to you sda7 partition... If the partitions is in use (when your data or your programs are installed) you have to do this in a liveCD or liveUSB.) Then, in gparted (installing it in a livecd session) right click in the partition you want to resize (sda7) and click move/resizze, then put the maximun size. Make a back up first of your important data, I'm not sure if this can delete your data in sda7. Also, you can make a mistake deleting the wrong partition (I did this mistake one time..)

share|improve this answer
add comment

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.