LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   How to map partitions to a specific device (https://www.linuxquestions.org/questions/linux-kernel-70/how-to-map-partitions-to-a-specific-device-859352/)

jghalam 01-28-2011 11:22 PM

How to map partitions to a specific device
 
Hi everyone,
I have a filesytem with 4 primary partitions already:
Device Boot Start End Blocks Id System
/dev/hda1 1 2 15655 83 Linux
/dev/hda2 3 4 15686 83 Linux
/dev/hda3 5 512 3984244 83 Linux
/dev/hda4 513 1020 3984244 83 Linux

I need to split the /dev/hda4 partition into two partitions without affecting partitions 1-3. I know that I have reached the maximum primary partitions already. So, I decided to delete /dev/hda4, and create an extended partition, and the add two logical partitions inside. Here is how it looks:
Device Boot Start End Blocks Id System
/dev/hda1 1 2 15655 83 Linux
/dev/hda2 3 4 15686 83 Linux
/dev/hda3 5 512 3984244 83 Linux
/dev/hda4 513 1020 3984244 5 Extended
/dev/hda5 513 960 3513633 83 Linux
/dev/hda6 961 1020 470549 83 Linux

Here is my problem... I need the partition mapped to /dev/hda5 to be mapped to /dev/hda4 instead. Does anyone know how or what tool to use to create partitions and specify device to map it to? Basically, I need the new partitions to be mapped like the following, without affecting the first 3 partitions:
Device Boot Start End Blocks Id System
/dev/hda1 1 2 15655 83 Linux
/dev/hda2 3 4 15686 83 Linux
/dev/hda3 5 512 3984244 83 Linux
/dev/hda5 513 1020 3984244 5 Extended
/dev/hda4 513 960 3513633 83 Linux
/dev/hda6 961 1020 470549 83 Linux

Any ideas as how to do this? Is that event possible?
Thanks for any help.

tommylovell 01-28-2011 11:32 PM

Can't be done.

An extended partition is sometimes called a "primary extended partition".

Partitions 1-4, the primary partitions, actually are mapped by four "slots" or structures in the Master boot record. Any one of them can be set up to be an extended partition.

Within an extended partition the logical partitions are numbered starting at 5 and nowadays can only go to 15. (They once could theoretically go to 63.) The logicals are all chained together and their position in the chain determines what the partition number is.

Out of curiosity, why do you need to do what you are asking about?

jghalam 01-28-2011 11:41 PM

This is an embedded system, and the older software running on the machine only knows about hda3 and hda4 partitions. I'm trying to change it to create partitions for swap and logs, without breaking the old software. The new software uses cmdline to figure partitions, but the old one was hardcoded.
Thanks for your quick reply. It helps me to make a quick decision.
cheers.

tommylovell 01-28-2011 11:45 PM

Ouch. Sorry I couldn't give you better news.

justboo2u 02-18-2011 09:40 PM

This may be newbie-ignorance,
(and I apologize for reopening a 'solved' thread)
but...

Would it not be possible to change the /dev settings?

such as (numbers used for example ONLY)
(are actually /dev/sd*)

/dev/hda1 b 8 1
/dev/hda2 b 8 2
/dev/hdb1 b 16 1
/dev/hdb2 b 16 2

changed to

/dev/hda1 b 8 1
/dev/hda2 b 16 1
/dev/hdb1 b 8 2
/dev/hdb2 b 16 2

and that, I think, would access the partitions 'correctly'?

as I said, wild-azz guess here. :rolleyes:
:)

tommylovell 02-19-2011 12:33 PM

You'd be better off posting that question as a new thread.

You need to mention that your system is an embedded system. What distro it is based on. Whether is has a monolithic kernel or modular kernel. Whether it uses an initial ramdisk. How initialization is done. Whether it uses UDEV. Etc.

Things that are well beyond my expertise.

And posting it under "Linux - Embedded" might be the most appropriate place for it.

I have a tendency to think that it can be done, but it might be extremely difficult and lead to a system that is difficult to understand.

justboo2u 02-19-2011 08:18 PM

Quote:

Originally Posted by tommylovell (Post 4264009)
You'd be better off posting that question as a new thread.

You need to mention that your system is an embedded system. What distro it is based on. Whether is has a monolithic kernel or modular kernel. Whether it uses an initial ramdisk. How initialization is done. Whether it uses UDEV. Etc.

Things that are well beyond my expertise.

And posting it under "Linux - Embedded" might be the most appropriate place for it.

I have a tendency to think that it can be done, but it might be extremely difficult and lead to a system that is difficult to understand.

(Presuming you were directing this toward me...)
I was not posting a question... more of a question-based answer.
Thus, no details.
:)

tommylovell 02-20-2011 10:04 AM

oops. sorry. I didn't look closely enough and just assumed you were the original poster.

your suggestion to the OP has some potential. it might be easy to do, but is way beyond me.

justboo2u 02-20-2011 03:39 PM

Quote:

Originally Posted by tommylovell (Post 4264794)
oops. sorry. I didn't look closely enough and just assumed you were the original poster.

your suggestion to the OP has some potential. it might be easy to do, but is way beyond me.

Not really that difficult...

document the info for the 2 devices:

/dev/hda4 b x1 y1
/dev/hda5 b x2 y2

UNMOUNT THE PARTITIONS if they are mounted (likely hda5 only)
then rm /dev/hda4 /dev/hda5

then mknod /dev/hda4 b x2 y2
and. mknod /dev/hda5 b x1 y1

then he should be able to mount /dev/hda4 and have it be the proper filesystem...
:D


All times are GMT -5. The time now is 06:07 AM.