Convert logical to primary partition without data loss

Hello,

one of my PCs has it’s home partition on an extended partition looks at Ubuntu.
Now I wanted to install openSUSE, but I can’t use that home partition, because it’s not a primary one.
I want that home partition to stay, everything else will get wiped.

fdisk -l

Gerät  boot.     Anfang        Ende     Blöcke   Id  System
/dev/sda1   *        2048   616755199   308376576   83  Linux
/dev/sda2       616757246   625141759     4192257    5  Erweiterte
/dev/sda5       616757248   625141759     4192256   82  Linux Swap / Solaris

/dev/sda2 is my extended partition and has one logical partition (/dev/sda3 => home).

How can I convert or move /dev/sda3 to a primary partition (ext4) so that openSUSE can use it?

Theoretically the following should be possible, no?

  • Delete all but /dev/sda2
  • Make new primary partition with same size as /dev/sda3, let’s say /dev/sda4
dd if=/dev/sda3 of=/dev/sda4
  • … several hours later …
  • Delete /dev/sda2
  • Install openSUSE and change home partition to /dev/sda4 and say no format
  • Successfully changed distribution without losing your home

I would test it, but I’m afraid to lose my home… :slight_smile:

If I could I would back my data up and do a complete new install, but I can’t. So please don’t tell me I should just back up my data.

Thanks.

I do not understand it. Why you can’t use it?

And you show partition table that contains sda5 but speak about sda3 everywhere. What is correct in this case?

The openSUSE installer says it’s not a valid filesystem.

Yeah, I dunno why sda3 is not there. But that’s what the openSUSE installer (what’s it’s name lol?) shows in the partition menu.

Something is confused here. “/dev/sda3” should be a primary partition, not a logical partition.

Consider that openSUSE, when doing a new installation, is not going to reuse anything, but try to make room for its self. I suggest you need to do a custom partition, remove sda1, and create a new sda1 for swap, a new sda3 (before sda2 I guess) for root / and then just mount and do not format sda5 for /home. There is no reason openSUSE can not use a logical partition for home. You can place grub into the MBR or generic boot code in the MRB and mark Primary Partition sda3 as the boot partition. In any event, you just got to take manual control of the partition creation before you can install openSUSE.

Thank You,

Okay, here are some screenshots:

What the installer shows me when I want to edit them:
http://ompldr.org/vZ3Zoaw

When I select sda3 and choose a filetype:
http://ompldr.org/vZ3ZobA

I get this error:
http://ompldr.org/vZ3Zobg

But now when I think about it… isn’t that the template that the installer creates?
That would mean that this ain’t my current partition and assuming that fdisk -l doesn’t show my home partition, does that mean I have no seperate home partition?

Come on, that’s unfair. :’(

You are severly mixing up things. You listing shows that you have:
. sda1 as a primary partion fit for a Linux file system.
. sda2 as an extended partition. Strange here is that it’s type is 5 (Extended) and not f (W95 Ext’d (LBA)) as usual here.
. sda5 is a logical partition it is given a type for Swap.

When you say that there is a functioning Linux on this setup, that can only be one file system contaning all of your data (system and personal on /home) and one swap partition. Finish.

So your remark:

/dev/sda2 is my extended partition and has one logical partition (/dev/sda3 => home).

contains a lot of nonsense:
. there is no sda3
. there is no separate partition for /home at all.

Please make up your mind and try to get grip on your situation. Because we can not give any useful help when we know only contrary information.

Yup, I mixed it up terribly. My bad.
I didn’t pay attention when I first looked at the partition table during the openSUSE install process.

Hmm, then I guess there’s nothing I can do.

Sorry, for the mess. Can a mod delete this thread? The thread title may mislead others… :slight_smile:

We normaly do not delete threads.

And as this one shows no logic from begin (the title included) to the end, I guess that everybody who even glances through untiil the end, will not find anything to bork his ystem.

BTW, if you want to sve evrything that is in your present /home directory, copy it somewhere else (USB stick or so). It can be copied back then after you did a new install.

In case you do then a complete new install, in the installer, go for changing whatever partition proposal is made. Somewhere down there you can say somehing like “use the whole disk”. This is to let the installer know that it should disregard all partitioning that is on the disk. It will then propose something that will be OK (including a separate /home partition :wink: ).

EDIT: something to read when you want to know if you know enough about the subject: http://en.opensuse.org/SDB%3ABasics_of_partitions,_filesystems,_mount_points

According to this http://ompldr.org/vZ3Zoaw
You have :

sda1 /
sda2 extended
sda3 /home
sda5 swap

My guess is, sda3 is not inside the extended space

Watch this
https://docs.google.com/open?id=0B3e0lLG3OdqEUV93Z0w1UWtTMjg

That is for sure. Logical partitions are numbered from 5 on. Regardless of the fact if the lower number are used for primary/extended ones or not.

Here’s what is theoretically possible:

1: Make careful notes of the beginning, end, size of the partition that you want to preserve.

2: Delete all partitions, leaving an empty partition table (but don’t save the changes yet).

3: Create the partition that you want in exactly the right place and size. If fdisk does not cooperate, it has some features in the advanced commands that might help.

4: If you are completely satisfied, then save the results. If you screw up in the middle, then exit without saving the changes, and nothing has been lost.

I don’t actually recommend this. Your post is sufficiently confused, that I doubt you will be able to get it right. And you really should backup first anyway, just in case you mess up.

Another, equally risky method - design your own partition table with a hex editor, then use “dd” to put it in place.

On Sat, 29 Dec 2012 19:16:02 +0000, nrickert wrote:

> And you really should backup
> first anyway, just in case you mess up.

Yes, this, 100x this. And of course, once it’s backed up, there’s no
need to muck about with the partition table, just create the new
partitions you want and restore the backup.

Jim


Jim Henderson
openSUSE Forums Administrator
Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C

Note that by default Ubuntu does not install a separate /home partition all is on the root.

Yup, I mixed it up terribly. My bad.
I didn’t pay attention when I first looked at the partition table during the openSUSE install process.

Hmm, then I guess there’s nothing I can do.

There are of course a number of things you can do, but none of them make sense without a backup of your important data.
A backup of important data is essential weather making partition changes or not.

I would check through my previous backups on other disks and delete what is no longer needed, you may be surprised by how much space becomes available for backups.
I would then go through /home and see what it is I do actually want to keep, it may not be as much as you think.
There are inexpensive options available for backing up to USB.

Once you have done this you could resize sda1 and create a partition in the free space (it would be sda3 and not in disk order), use it as a data partition and copy data that is in the category of “I would like to keep this, but I didn’t back it up because I don’t realy need it.” then delete sda1, sda5 then sda2 and create new partitions to suit yourself. You have the important backups, you can now make a mistake and it does not mater.

But my preferred option, with the backups made, would be to delete all partitions on the disk and start again.