Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

How to I change a Swap partition from Primary to Logical?


  • Please log in to reply
33 replies to this topic

#1 cat1092

cat1092

    Bleeping Cat


  • BC Advisor
  • 7,015 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:North Carolina, USA
  • Local time:10:04 PM

Posted 23 September 2014 - 02:30 PM

Last week, when I created this install of LInux Mint 17, on a 120GiB Samsung 840 EVO SSD removed from my PC, I made a mistake. 

 

Though I should have trusted Linux MInt to partition, I didn't & after cloning 8.1 Pro over, I used GParted from the Mint 17 install media to format (to ensure partition alignment). What I ended up with are now 4 primary partitions, with the 1024MiB Swap partition between the main and home partitions. 

 

I found out my mistake when trying to create a small logical partition afterwards, to setup Samsung's over provisioning app. Now I can't do it. 

 

Is there anyway possible to change the Swap from primary to Logical w/o reinstall? 

 

Any assistance is greatly appreciated.  :)

 

Cat


Performing full disc images weekly and keeping important data off of the 'C' drive as generated can be the best defence against Malware/Ransomware attacks, as well as a wide range of other issues. 


BC AdBot (Login to Remove)

 


#2 sflatechguy

sflatechguy

  • BC Advisor
  • 2,226 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:10:04 PM

Posted 23 September 2014 - 09:11 PM

Yep, you've reached the MBR limit with 4 partitions. :(

 

You can make the swap partition a logical partition, but first you'll have to delete it, create a new extended partition, then create a logical partition in that extended partition and designate it as the swap partition. You can add other logical partitions as well to that new extended partition.

 

These should help:

http://unix.stackexchange.com/questions/106166/how-to-change-swap-partition-from-primary-to-logical

http://www.linuxquestions.org/questions/linux-hardware-18/change-primary-partitions-to-logical-partitions-and-migrate-their-data-798463/



#3 cat1092

cat1092

    Bleeping Cat

  • Topic Starter

  • BC Advisor
  • 7,015 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:North Carolina, USA
  • Local time:10:04 PM

Posted 23 September 2014 - 11:10 PM

I didn't do myself any favors by sandwiching a Swap partition between main & home either. The first page linked, I ran across earlier today while looking around, as I read the answer, this was assuming that the Swap was the last partition. Though many does exactly as I did. 

 

The one thing I don't want to do is to slide the Home partition over, as that would likely leave me with an unbootable Linux. My luck with these things are terrible, not once have I managed to boot a Linux OS after moving the main or home partitions around. There was one time I actually deleted a Swap partition, but it was a Logical one. 

 

It would seem that with a Linux Swap partition, it would be a straightforward operation, to boot from the install media & go through the motions of an install, delete the current Swap, recreate another as Logical, then exit out of the installer & reboot. That's probably too simple though, some things has to be done after the user hits Install. 

 

From here on out, will perform my Linux installs with the default procedure, by now (5 years after MS perfected the procedure with Windows 7), it would seem that the Linux installer can detect & properly align a SSD install w/out GParted. Nick told me this & I had simply forgotten. 

 

So would the SSD controller be able to access that empty space, regardless of partitioning? That's my main concern. There has to be about 10% of unformatted space to do this with (or this is the minimum recommended amount), on my larger SSD's I give like 15-20%, and still have lots of room. On this one though, that was too much to give, I believe I left close to 12GiB at the end. It is Trimming, as I've made the tweaks for this. Plus I run a manual TRIM when I think of it, being the Administrator, I have to do the updating. Ii I knew for sure the controller is working, I won't worry with the Swap, but will be cautious in the future. The main Linux partition can be logical. I think I need to forget GParted exists.  :P

 

As long as the controller can do it's job, I don't care, but will be more aware of how I perform future installs. If this weren't the computer that my wife uses, I know what I'd do, redo the install & make both the Swap & Home logical.partitions. It's just that the computer is set to her liking, plus I went through all of the effort of tuning things, as outlined in some of the articles in regards of the first things to do on Ubuntu 14.04/Mint 17. These things takes time. Honestly, cutting down swappiness from 60 to 1, what is the purpose of a Swap partition, especially with 8GiB DDR3 1333MHz RAM installed & nothing resource intensive going on? More CPU than RAM is used (well, on Windows anyway). That's getting ready for a fix, the i3-370m is going to be replaced with a i5-480m, which will make TurboBoost available to all OS's. 

 

No virtual machines used, no photo editing, it's just a computer used for Web browsing. The 1024MiB Swap is just there for the sake of it, it was only 256MiB on my Dell, and Windows has only a 200MiB pagefile on a PC with 12GiB of RAM (which serves the same purpose). I've often wondered why Linux requires a partition for this. Maybe so the user has control of the process. Windows is a drive Hog, if there's 16GiB RAM installed, it's going to install a 32GiB pagefile. No wonder the "C" drive shrinks drastically upon proper tuning. 

 

Ironically, I have essentially the same setup on a MSI notebook, only all 4 primaries on the 180GiB Intel 330 SSD are for Windows. The system partition, then Windows 7 Recovery, the the OS install (7 Pro), followed by 8.1 Pro. There is 10% of free space at the end there also, whether it's doing it's job or not is what I don't know, nor how to detect/measure. But that's about to change, as I've ordered another SSD for my main PC, the 250GiB one in there is headed for the MSI & 8.1 is getting cloned onto that one. Room is needed & I can then set over provisioning at 15% to hopefully clean it up, will simply boot it & leave it at the login screen for 24-48 hours. 

 

What does the community think? All I care about on this install is if the controller is doing it's job. The space doesn't need formatting, actually it's supposed to be left blank. Samsung simply has it's way to set OP. Many users doesn't bother with the software. 

 

Cat


Performing full disc images weekly and keeping important data off of the 'C' drive as generated can be the best defence against Malware/Ransomware attacks, as well as a wide range of other issues. 


#4 sflatechguy

sflatechguy

  • BC Advisor
  • 2,226 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:10:04 PM

Posted 23 September 2014 - 11:21 PM

Only issue with no swap partition is if you are doing something memory intensive and you run out of RAM, the kernel will start picking processes it thinks aren't necessary and kill them.

 

How big are the other three partitions? Any chance you could shrink one or more down and install a small extended partition at the end?



#5 cat1092

cat1092

    Bleeping Cat

  • Topic Starter

  • BC Advisor
  • 7,015 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:North Carolina, USA
  • Local time:10:04 PM

Posted 24 September 2014 - 12:47 AM

Here's the SSD as shown by GParted. 

 

Screenshot-9.png

 

Yes, it would be great to install a 1024MiB partition on the very end for Samsung over provisioning. 

 

But why can't the Linux Swap just can't be deleted & restored as Logical? All it's doing is removing & adding back. 

 

The GParted developers could do a better job, actually I've installed several Linux OS's with no Primary partition. Problem is, if one creates these with GParted, it looks all messed up. Which is why I'll now go with the native installer. GParted has outlived it's usefulness as far as I'm concerned. I tried to do this Swap as Logical, but it wouldn't align. There would have been a 1MiB gap. With SSD's, there's supposed to be no gaps. Messes up alignment. 

 

Cat


Performing full disc images weekly and keeping important data off of the 'C' drive as generated can be the best defence against Malware/Ransomware attacks, as well as a wide range of other issues. 


#6 sflatechguy

sflatechguy

  • BC Advisor
  • 2,226 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:10:04 PM

Posted 24 September 2014 - 01:25 AM

But why can't the Linux Swap just can't be deleted & restored as Logical? All it's doing is removing & adding back. 

 

Remember, in order to create a logical partition, you first have to create an extended partition, and then create a logical partition inside the extended partition. There's no good way to convert a primary partition to an extended partition -- some third party tools exist that can supposedly do this. And there's no point in creating a 1GB extended partition, because the whole idea is to use it to create multiple logical partitions, thus getting around the 4 partition limit.

 

There's no reason you can't just delete the swap partition, create a backup of the /home directory, delete the sda4 partition as well, create a new sda3 ext4 partition that aligns over what used to be the swap partition, and reinstall the /home directory there from the backup. That would then give you another gigabyte of unallocated space for the new extended partition.



#7 cat1092

cat1092

    Bleeping Cat

  • Topic Starter

  • BC Advisor
  • 7,015 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:North Carolina, USA
  • Local time:10:04 PM

Posted 24 September 2014 - 01:52 AM

That's probably what I'll do, is just backup the /home directory (Nick provided a better tool in another Topic last night) & redo. That way, I can make the /home Logical & I'll likely add back a Swap for the reason you mention above, but will do it at the end of the /home partition. Better to have it & not need it. As long as I can squeeze a 1024MiB NTFS Logical at the end of that, the Magician software will have the 10% it needs. 

 

Thanks for the advice given on this & it's a lesson learned. With Linux, there's always something new to learn. I'll be sure not to make this mistake again. 

 

Cat


Performing full disc images weekly and keeping important data off of the 'C' drive as generated can be the best defence against Malware/Ransomware attacks, as well as a wide range of other issues. 


#8 wizardfromoz

wizardfromoz

  • Banned
  • 2,799 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:12:04 PM

Posted 24 September 2014 - 02:29 AM

Mate have you tried rodsbooks.com site ?

 

Cheers

 

Wiz



#9 Al1000

Al1000

  • Global Moderator
  • 7,731 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Scotland
  • Local time:03:04 AM

Posted 24 September 2014 - 03:15 AM

The GParted developers could do a better job, actually I've installed several Linux OS's with no Primary partition. Problem is, if one creates these with GParted, it looks all messed up.

 

Both of my computers have only one primary partition. On my desktop pc it contains Windows (and the (Grub4Dos) boot files), and on my laptop the primary partition is just a small partition for the Grub4Dos boot files. On both computers, the rest of the HDD is an extended partition, in which I have various partitions for Kubuntu, Puppy, swap, and file storage. Excepting the Windows partition on my desktop pc, everything else was created with GParted (on Precise Puppy 5.7.1).


Edited by Al1000, 24 September 2014 - 03:19 AM.


#10 Al1000

Al1000

  • Global Moderator
  • 7,731 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Scotland
  • Local time:03:04 AM

Posted 24 September 2014 - 09:35 AM

The one thing I don't want to do is to slide the Home partition over, as that would likely leave me with an unbootable Linux. My luck with these things are terrible, not once have I managed to boot a Linux OS after moving the main or home partitions around.


Come to think of it, I once moved my Kubuntu partition on my laptop using GParted when I reorganised the HDD, which was motivated by having run out of swap space on one occasion. It used to look like this:

image-gparted_zps83db7667.jpg

...and now it looks like this:

partitions1_zpsd194036f.jpg

Everything went smoothly and I had no problems booting up after. In fact the only problem I recall ever having had with partitioning, was using the partitioning tool on XP, which deleted my Kubuntu installation on my desktop pc.

#11 pcpunk

pcpunk

  • Members
  • 5,876 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Florida
  • Local time:10:04 PM

Posted 24 September 2014 - 03:39 PM

Very interesting guys, one question for the newb: Is ext. always Primary?  I think not, as Al1000 said that he only has "one" Primary on each pc.

So which is Primary, extended or Fat32, and how would a person tell while looking at gparted?  Trying to get a grasp on all this.

 

Al1000, if you have time would you explain your partitions again in simple terms, like:

1. What is sda5, puppy, root and home.

2. What is sda7, Kubuntu root and home?

3. What is sda8 "Files" used for?  Does this serve as /home for both OS's?

I believe, as I understand it Swap is used by both.

 

cat1092, I was reading this post as you might have also, quite a bit of successful partition moving without re-install going on there, perhaps it would be of help:  http://forums.linuxmint.com/viewtopic.php?f=46&t=177638


Edited by pcpunk, 24 September 2014 - 03:51 PM.

sBCcBvM.png

Created by Mike_Walsh

 

KDE, Ruler of all Distro's

eps2.4_m4ster-s1ave.aes_pcpunk_leavemehere

 


#12 sflatechguy

sflatechguy

  • BC Advisor
  • 2,226 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:10:04 PM

Posted 24 September 2014 - 03:46 PM

Primaries can be ext, FAT, NTFS or any other recognizable file system type.

Extended partitions are a special type that contain one or more logical partitions, like a swap logical partition and an ext4 logical partition -- so extended partitions themselves don't have any one filesystem type.

Based on your question, a primary partition could be FAT32, but it can't be an extended partition. Primary and extended partitions are mutually exclusive.

#13 pcpunk

pcpunk

  • Members
  • 5,876 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Florida
  • Local time:10:04 PM

Posted 24 September 2014 - 04:08 PM

sflatechguy

That was very helpful, but can Primary be pointed out in the above gparted screenshot?  Or is it not always labeled in gparted?  Thanks!


Edited by pcpunk, 24 September 2014 - 04:11 PM.

sBCcBvM.png

Created by Mike_Walsh

 

KDE, Ruler of all Distro's

eps2.4_m4ster-s1ave.aes_pcpunk_leavemehere

 


#14 sflatechguy

sflatechguy

  • BC Advisor
  • 2,226 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:10:04 PM

Posted 24 September 2014 - 04:15 PM

In Linux, logical partitions begin at sda5. Note also that sda2 is listed as an extended partition. So in the above image sda5, sda6 and sda7 are all logical partitions in the sda2 extended partition.

#15 pcpunk

pcpunk

  • Members
  • 5,876 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Florida
  • Local time:10:04 PM

Posted 24 September 2014 - 05:32 PM

O geez, are you trying to make me think lol.  This must mean that Primary is FAT32? because that was the question.  Also, that would be the extent of the Logical partitions for that "extended" partition, four right?  

 

Then, one would have to start another extended partition if one wanted more Logical partitions right?

 

cat, sorry for the Hijack.


Edited by pcpunk, 24 September 2014 - 05:34 PM.

sBCcBvM.png

Created by Mike_Walsh

 

KDE, Ruler of all Distro's

eps2.4_m4ster-s1ave.aes_pcpunk_leavemehere

 





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users