LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   How do I switch the labels "/dev/sda1" with "/dev/sda3" (https://www.linuxquestions.org/questions/linux-general-1/how-do-i-switch-the-labels-dev-sda1-with-dev-sda3-448922/)

vonst 05-26-2006 08:43 PM

How do I switch the labels "/dev/sda1" with "/dev/sda3"
 
I don't quite know how to phrase this to google it without getting a billion off topic answers. LQ Search gave me a billion off-topic answers.

I partitioned 4 disks so that I can RAID0 them. To get the partition sizes right, I ended up needing to put the identical partitions at the "end" and the leftovers at the "beginning." So, for example, I have (/dev/'s removed):

sda3 20G, sdb3 90G (90 gigabyte partition)
sda2 100G, sdb2 100G
sda1 110G, sdb1 110G

Well, it just so happened that I put WinXP onto what was originally sdb3, the 90 gig partition. It switched my numbers!

sda3 20G, sdb1 90G
sda2 100G, sdb2 100G
sda1 110G, sdb3 110G

OK, that's fine. I don't know how or why that happened, but it did. But I'm having some problems and one of the tests I'd like to try (to fix my problems) is changing the numbers for sda. How can I make it so that the sda numbers change too?:

sda1 20G, sdb1 90G
sda2 100G, sdb2 100G
sda3 110G, sdb3 110G

--vonSt
PS: I'm pretty sure that responders will say "it doesn't matter one wit," but this is a test, and it'll help me learn more about the way Linux runs, so I'm interested in knowing if and how this procedure can be done, since somehow it got done for my WinXP install on what is now "sdb1".

pixellany 05-27-2006 06:46 AM

you say that you have four disks, but you only describe the contents of two....Please post the output of "fdisk -l" (run as root).

When you say you want to "change the numbers for sda", how were you thinking of doing that? Normally, when you make a partition and put stuff on it, you can't then change the partition number.....(I think)

vonst 05-27-2006 07:57 AM

I only posted 2 disk partition schemes as an example. It's a mess for me to post the whole thing. The gist of it is above.

Quote:

When you say you want to "change the numbers for sda", how were you thinking of doing that? Normally, when you make a partition and put stuff on it, you can't then change the partition number.....(I think)
That is exactly the question I am posting here. Somehow or another it did happen. I fdisk'd /dev/sdb such that the 3rd and final partition got the leftovers (90 gigs), was placed at the beginning of the disk, typed NTFS, and assigned "sdb3." I installed WinXP on top of it and somehow or another, that very partition became /dev/sdb1.

My thought is that if WinXP can renumber my partitions, then I can too!

--vonSt

rkelsen 05-27-2006 08:40 AM

Quote:

Originally Posted by vonst
I installed WinXP on top of it and somehow or another, that very partition became /dev/sdb1.

This is physically impossible. You must be confusing yourself somewhere.

PTrenholme 05-27-2006 09:31 AM

Does Slack use udev? If it does, you can assign your own locations in /dev to specific devices (by model, serial number, etc.) which would be another solution for your problem.

It's very handy is you change USB devices frequently, but want to refer to them with the same /dev id without having to know where or when they're plugged in.

pixellany 05-27-2006 09:51 AM

Quote:

Originally Posted by pixellany
y...Please post the output of "fdisk -l" (run as root)

PRETTY please...?

vonst 05-27-2006 02:41 PM

Slackware does indeed use udev... at some point or another. Oh no, does that mean I have to become the master of udev too?

OK, in response to pixellany's plea, I've learned a little bit more about lsmod, rmmod, and modprobe. I think I can load and unload the modules to attach a thumb drive to my new box when I need to. Up to now, it's been totally and confusingly random. It either decides to allow me to load /dev/sde or it refuses [blah... blah...].

Code:

fdisk -l
Disk /dev/sda: 320.0 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

  Device Boot      Start        End      Blocks  Id  System
/dev/sda1  *          1      10951    87963876    7  HPFS/NTFS
/dev/sda2          10952      24324  107418622+  7  HPFS/NTFS
/dev/sda3          24325      38913  117186142+  fd  Linux raid autodetect

Disk /dev/sdb: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

  Device Boot      Start        End      Blocks  Id  System
/dev/sdb1          15813      30401  117186142+  fd  Linux raid autodetect
/dev/sdb2            2440      15812  107418622+  7  HPFS/NTFS
/dev/sdb3              1        2439    19591236    c  W95 FAT32 (LBA)

Partition table entries are not in disk order

Disk /dev/sdc: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

  Device Boot      Start        End      Blocks  Id  System
/dev/sdc1          15813      30401  117186142+  fd  Linux raid autodetect
/dev/sdc2            2440      15812  107418622+  7  HPFS/NTFS
/dev/sdc3  *          1        2439    19591236  83  Linux

Partition table entries are not in disk order

Disk /dev/sdd: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

  Device Boot      Start        End      Blocks  Id  System
/dev/sdd1          15813      30401  117186142+  fd  Linux raid autodetect
/dev/sdd2            2440      15812  107418622+  7  HPFS/NTFS
/dev/sdd3              1        2439    19591236  82  Linux swap

Partition table entries are not in disk order

Disk /dev/sde: 1026 MB, 1026555904 bytes
16 heads, 32 sectors/track, 3916 cylinders
Units = cylinders of 512 * 512 = 262144 bytes

  Device Boot      Start        End      Blocks  Id  System
/dev/sde1  *          1        3916    1002480    b  W95 FAT32

Sigh, see? Now it looks like crap. This posting software doesn't respect tabs and spaces. It shortens everything to save space. I'll just say that here in the edit screen, it looked great! edit: excellent! learned something new. code tags it is!

So, what does it mean "Partition table entries are not in disk order?" Just that I assigned my partitions from back to front?

Oh, and it's time to admit I lied. Windows didn't reassign /dev/sdb. It assigned /dev/sda. Interestingly, and maybe it relates specifically to udev, I switched the cables around. Windows used to be on /dev/sdc. It did the same to /dev/sdc. Now, however /dev/sdc is 321. It didn't stay as 123.

Also, as you can see, sda3 + sdb1 + sdc1 + sdd1 make up a raid partition. sdc3 is my /boot. sdd3 is my swap. sdb3 is my dos partition to link me to everything.

--vonSt

haertig 05-27-2006 02:58 PM

Quote:

Originally Posted by vonst
Sigh, see? Now it looks like crap. This posting software doesn't respect tabs and spaces. It shortens everything to save space. I'll just say that here in the edit screen, it looked great!

If you want stuff to look the way you laid it out, don't surround it with quote tags. Surround it with code tags instead. This is the way every kind of forum software works, that I've come across recently.

Example (text surrounded with code tags):
Code:

$ sudo fdisk -l

Disk /dev/hda: 200.0 GB, 200049647616 bytes
255 heads, 63 sectors/track, 24321 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

  Device Boot      Start        End      Blocks  Id  System
/dev/hda1              1          34      273073+  b  W95 FAT32
/dev/hda2              35        799    6144862+  7  HPFS/NTFS
/dev/hda3            2272      24321  177116625    f  W95 Ext'd (LBA)
/dev/hda5            2272      22939  166015678+  8e  Linux LVM
/dev/hda6          22940      24214    10241406  8e  Linux LVM
/dev/hda7          24215      24278      514048+  82  Linux swap / Solaris
/dev/hda8          24279      24317      313236  83  Linux
/dev/hda9  *      24318      24321      32098+  83  Linux
$

Example (exact same text, but surrounded with quote tags):
Quote:

$ sudo fdisk -l

Disk /dev/hda: 200.0 GB, 200049647616 bytes
255 heads, 63 sectors/track, 24321 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hda1 1 34 273073+ b W95 FAT32
/dev/hda2 35 799 6144862+ 7 HPFS/NTFS
/dev/hda3 2272 24321 177116625 f W95 Ext'd (LBA)
/dev/hda5 2272 22939 166015678+ 8e Linux LVM
/dev/hda6 22940 24214 10241406 8e Linux LVM
/dev/hda7 24215 24278 514048+ 82 Linux swap / Solaris
/dev/hda8 24279 24317 313236 83 Linux
/dev/hda9 * 24318 24321 32098+ 83 Linux
$

jiml8 05-27-2006 06:19 PM

First of all, forget about renumbering the partitions. You can't.

You can relabel the hard drives. It could be that you have some dynamic addressing set up on your SCSI bus and after Windows was installed on one drive, it set that drive as the boot drive - which most controllers will by default make sda. This would cause the reordering of drives (not partitions) that you are experiencing.

I would suggest you let it go as far as Windows is concerned. Windows is pretty unfriendly about a lot of things pertaining to hardware configuration once it is convinced of how things are, and you will just buy trouble. Note: Windows is NOT referring to the drives as /dev/sda etc... you are being sloppy in your notation when you claim that.

Your SCSI controller will have a utility that lets you look at what is mounted where. You will access this utility through a keypress combination during the boot procedure, at the time when the SCSI controller is initializing. I suggest you take a look at that, and write down the addresses/sizes of the hard drives that are connected.

Then, in Linux, you will find what drive has been labeled which in /var/log/dmesg. Take a look at this and compare it to what you got from your SCSI controller, and you will know which bus address has been assigned to which drive.

Now it depends on your boot loader. I can't help you with LILO because I have made very little use of it; I use grub. In grub, if you take a look at the contents of /boot/grub/device.map, you will see a mapping of grub's understanding of your physical drives to the Linux device mapping.

Grub will number your SCSI drives based upon their physical address on the bus; the lowest address will be hd0, the next highest address is hd1, and so forth.

What you need to do is compare this physical layout to the logical layout that you want to have assigned, and you then assign it as you want it.

As a specific example, my system (which I am presently typing this message on) has four SCSI hard drives on an Adaptec 29160 controller. I don't run RAID and for various historical reasons, my drives are out of order and I have to remap them. Here is the contents of my device.map file:
Code:

(fd0) /dev/fd0
(hd0) /dev/sdc
(hd1) /dev/sda
(hd2) /dev/sdb
(hd3) /dev/sdd

Note that I allow this kind of remapping because I, too, have a Windows installation on this system though I never boot into it any more. My actual Windows boot drive is sda (hd1) and the boot partition is sda1. There is only the minimum necessary boot files present for Windows on sda1; the actual installation is found on sdc1. Also, my Linux root is on sdc2.

The reasons for this labeling are historical and the only time it matters is when I upgrade my Linux installation, which inevitably hoses up the mapping. I just keep an archival copy and after the installation messes me up, I do a manual reinstallation of grub and restore the map I need.

rkelsen 05-27-2006 06:33 PM

Quote:

Originally Posted by vonst
I switched the cables around.

Why?

What happens when you switch them back?

vonst 05-27-2006 10:48 PM

Jim18 was right. I was being sloppy. I know WinXP had nothing to do with the numbering/ordering of my partitions. In fact, when I switched around the cables, I didn't reload XP. XP asks the BIOS which disk is first. I changed it around in the BIOS and kept XP as first disk. Everything still loaded, but the partition numbers changed on the two different disks. Dynamically, I guess.

** NOTE: I highlighted the disk partitions with cylinder #1. I did NOT assign cylinder #1 to /dev/sda1. I assigned cylinder #1 to /dev/sda3. (Actually, when I assigned it, it was /dev/sdc3... which turned into /dev/sdc1 when I loaded XP on it... and then that disk became /dev/sda when I switched the cables.)

I don't actually want to switch the cables back. I predict that if I did, the numbers would change again.

So, taking a cue from this thread, and given that I'm learning how to install RAID (and I don't actually have to use it for anything yet), I erased everything and started over. I took the "fdisk -l", learned how to assign my partition sizes as cylinders, and assigned all my disk partitions in the orders that I wanted them.

I think this thread was a good thread. If you wanted to change the partition numbers and nothing else, could you? Nope, I guess not. Now anybody else that comes up with this grand scheme can come to the thread, say "damn!", and repartition their drives over again or just forget it and leave things lie.

Repartitioning didn't solve my problem, so I'm going to start another thread. It'll be called "I can't automount raid because I don't have valid superblocks. How do I get them in ext3?" But that's a new thread.

vonSt
PS: I don't actually have SCSI. I have SATA. The kernel treats it as SCSI. I have an NV SATA RAID. I'm beginning to think that these three things don't go together very well.


All times are GMT -5. The time now is 10:20 PM.