LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   Change primary partitions to logical partitions AND migrate their data? (https://www.linuxquestions.org/questions/linux-hardware-18/change-primary-partitions-to-logical-partitions-and-migrate-their-data-798463/)

chickenlinux 03-28-2010 12:44 PM

Change primary partitions to logical partitions AND migrate their data?
 
I've installed Arch Linux onto my Western Digital SATA drive. I love it, best ever, however, I need the fglrx proprietry driver for better 3-d performace, and decided to create a new partition. I decided to install Linux Mint.

Sadly, in all my noobishness, I forgot about the 4 primary partition limit (oops!) and as I have /, /home, swap, and /boot partitions (all primary) already installed, I have run into a bit of a problem.

I resized my /home partition (almost 500GB) to about 225, and was then told I have over 200GB unusable space. :(

Is it possible for me to change at least 1 of my primary partitions to logical partitions AND keep all the data intact (AND edit the arch configuration so that it'll still work) so I can install a second linux? I sincerely doubt it, but if there's a way, could someone tell me how?

mpier 03-28-2010 02:02 PM

Hi,
should be painless. Create a partition at the end of the drive, move any data into them and delete or modify opening partitions. This could be done without data movement by editing only the partitions table, but don't recommended if you are out of knowledge. Difficult to say, depends on actually arrangement.

chickenlinux 03-28-2010 02:47 PM

Firstly, thank you very very much. Secondly, I'm not entirely sure how to do this. I feel really stupid, and I hope I'm not wasting your time, but could you walk me through this step by step? I've backed up my data, but I'm still scared to death that I'll screw up really badly; I don't want to lose my system.

Here's a partitioning layout as given by "sudo sfdisk -d /dev/sda > partitions":
Code:

# partition table of /dev/sda
unit: sectors

/dev/sda1 : start=        1, size=  931769, Id=83, bootable
/dev/sda2 : start=  931770, size=  8353800, Id=82
/dev/sda3 : start=  9285570, size= 30732345, Id=83
/dev/sda4 : start= 40017915, size=488295675, Id=83

Thank you so much for your help so far.
If you have the time, please tell me what to do step by step like I'm a 6 year old.

(This is sort of pathetic -- A fellow installs Gentoo Linux from stage 3 by chrooting from a puppy cd, but cannot partition a hard drive -.-)

syg00 03-28-2010 05:10 PM

Short answer, no.
Delete sda4 (after backup), allocate all free space as an extended partition. Allocate a new logical partition at the beginning of the extended (the extended is just a container for logical partitions). Make this new (logical) partition slightly larger than what sda4 was, just to be safe. With luck you'll be able to mount it as sda5 and use it as if nothing had happened. Else restore your data.
Adjust grub and fstab, and you'll be fixed up.

Do all the above from a liveCD.

mpier 03-28-2010 05:37 PM

Yes, but resize sda3 down a little (resize filesystem first) and then create extended sda4 and logical sda5 at the same position as sda4 was before (fdisk -lu /dev/sda shows you). Otherwise the new sda5 will be shifted right, and wouldn't mount.

chickenlinux 03-28-2010 09:00 PM

So, I delete sda4 (muh... worse could happen :P) and then add a new sda4 as a logical volume of sda3, then create sda5 as the new primary that will house my Linux Mint as one big partition? Is that right?

mpier 03-29-2010 12:50 PM

No,
sda4 isn't logical, it is primary like sda1,2,3. Sda4 may be extended with logical sda5,6,7... Some programs doesn't show extended partition, only just logical (sda1, sda2, sda3, sda4 (not shown), sda5, ...). If you have data from sda4 backuped, just delete them, and create extended allocating all free space. Samthink like this:
fdisk /dev/sda, d, 4, n, e, 4, Enter, Enter, n, l, ... ;)

chickenlinux 04-02-2010 02:00 PM

But, if I'm only allowed 4 primary partitions, and only primary partitions are bootable, do I delete sda4, create a new _extended_ sda4, & make a logical sda5 for the new OS?

Clearly, I need to brush up on fdisk. I've only been using cfdisk, but it's obviously limited.

johnsfine 04-02-2010 02:06 PM

Unless you have a suspend to disk pending, you have nothing useful in your swap partition.

Converting a primary to logical would be quite hard, but deleting the swap, moving the other primary partitions and later recreating swap as logical should be easy.

To mess around with the partitions, you need to be booted in a liveCD rather than in any of the partitions you are resizing or moving.

Your liveCD might automatically do a swapon to enable use of the swap partition. In that case you need to use swapoff or equivalent command to disable use of swap before deleting it.

chickenlinux 04-04-2010 03:15 PM

I'll go with deleting swap. Sounds simplest. 2 GB of RAM ought to be plenty. I can use a logical volume as swap, correct?

johnsfine 04-04-2010 04:31 PM

Quote:

Originally Posted by chickenlinux (Post 3924084)
I can use a logical volume as swap, correct?

Correct.


All times are GMT -5. The time now is 01:20 AM.