LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 08-15-2010, 01:27 AM   #1
-kg-
LQ Newbie
 
Registered: Jan 2010
Location: Godfrey, IL
Distribution: Ubuntu, Fedora, OpenSUSE, Knoppix, Puppy
Posts: 24

Rep: Reputation: 0
Question How To Make Linux Partition Letter/Number Designations Persistent?


Everyone who deals with Linux knows that partitions on hard drives are designated as "sdx#", i.e., sda1 sdb2, etc. I know through experimentation that the number portion of the designation is assigned not according to order on the disk, but chronologically in the order they are created.

Further, if you have several partitions on the disk-say, sda1 through sda3-and you delete sda2, the designation of sda1 will remain the same, but sda3 will become the new sda2. The creation of any further partitions on the drive will start with designation sda3 and increment from that point.

At times this creates a conundrum, especially concerning bootable partitions. Some time back I rendered a partition containing OpenSUSE unbootable because of this, even though Ubuntu owned the GRUB bootloader in the MBR. Ubuntu's GRUB could find and point to the partition using the command "sudo update-grub", but when OpenSUSE took over the boot-up process, its GRUB was pointed to the wrong partition and would freeze up.

My question is this:

Under Windows, one is able to make a Drive letter persistent. Windows will keep the drive letter for that partition and assign around it. Is there a way to change a drive designation number, or at least make it persistent, under Linux? It would be a handy method to forestall these types of booting problems, among other things.

Presently, when a person has installed Linux side-by-side with Windows and want to delete the Windows partition and expand the Linux partition into the free space, I will tell them to format the partition, then shrink it to next to nothing instead of deleting it. This preserves the partition ID scheme while giving them the space to expand their Linux partition into...especially helpful with a seasoned Linux installation that would be a PITA to reinstall and set back up.

Oh, and I already know about UUID. This article explains it, but if you look down through the comments, you will see reasons that it is problematic for desktop application and usage. I want to make it as simple as possible for new Linux users (and myself! ).
 
Old 08-15-2010, 01:47 AM   #2
xeleema
Member
 
Registered: Aug 2005
Location: D.i.t.h.o, Texas
Distribution: Slackware 13.x, rhel3/5, Solaris 8-10(sparc), HP-UX 11.x (pa-risc)
Posts: 987
Blog Entries: 4

Rep: Reputation: 252Reputation: 252Reputation: 252
Greetings!

Well, for starters there are two times where device names can "change";
1) The Boot Loader (GRUB or LILO)
2) What the Linux kernel "sees".

When you talk about "sda1", "sda2", etc, those are names assigned by the Linux kernel once it's loaded. Keep in mind that boot loaders (such as GRUB), can and will name devices differently. This is most obvious when you boot with/without a USB device present.

For solving the "sda1" and "sda2" type naming problems, you may want to consider the following;

1) If you're on a dual-boot Linux/Windows type setup. Consider using udev rules. (More information here: http://wiki.archlinux.org/index.php/..._device_naming)
2) If you system runs only one Operating System (Linux), try using LVM2 (also great if you're attempting redundancy or performance thru various RAID implementations via mdadm)

Hope this helps!

Last edited by xeleema; 08-15-2010 at 01:49 AM.
 
1 members found this post helpful.
Old 08-15-2010, 07:06 PM   #3
-kg-
LQ Newbie
 
Registered: Jan 2010
Location: Godfrey, IL
Distribution: Ubuntu, Fedora, OpenSUSE, Knoppix, Puppy
Posts: 24

Original Poster
Rep: Reputation: 0
Thank you for your prompt and well-considered reply, xeleema!

I was hoping for a "quick and easy fix" for those Linux newbies I help, primarily on the Ubuntu Help Forums, but it seems there will be no such fix forthcoming.

However, your reply led me to interesting reading, research, and experimentation, which itself led me to some rather startling (and rather humbling) results.

Quote:
Originally Posted by xeleema View Post
Well, for starters there are two times where device names can "change";
1) The Boot Loader (GRUB or LILO)
2) What the Linux kernel "sees".
This is fairly well where the problems lie. I am unsure as to how 'What the Linux kernel "sees"' is determined, but I feel that both of the above are related to my issue with my OpenSUSE installation. The Ubuntu Bootloader in MBR "saw" GRUB in SUSE and started it, but when SUSE's GRUB took over the boot-up process, it's own subsequent stages of GRUB looked for "itself" in "sdbX", which no longer existed due to a couple of partitions having been deleted.

Quote:
Originally Posted by xeleema View Post
When you talk about "sda1", "sda2", etc, those are names assigned by the Linux kernel once it's loaded. Keep in mind that boot loaders (such as GRUB), can and will name devices differently. This is most obvious when you boot with/without a USB device present.
Actually, I can boot with or without a USB device present. I made my most recent (fresh) installation with my 1 TB external drive plugged in, and I can successfully boot any of my OSes with or without it plugged in. The only one I can't boot to is the OS I have installed on the external drive itself (naturally! ).

Quote:
Originally Posted by xeleema View Post
For solving the "sda1" and "sda2" type naming problems, you may want to consider the following;

1) If you're on a dual-boot Linux/Windows type setup. Consider using udev rules. (More information here: http://wiki.archlinux.org/index.php/..._device_naming)
This is where the complexity for newbies comes in. It raised the interesting possibility of using partition labels for booting and recognition purposes. Unfortunately, the "initrd" replacement enabling using labels, "mkinitcpio", is only available in the Arch Linux repos, that I could find. Ubuntu definitely has nothing like it, and I was unable to find information about any replacement available in that distro.

However, the "UUID" section led to some interesting experiments, which I'll explain below.

Quote:
Originally Posted by xeleema View Post
2) If you system runs only one Operating System (Linux), try using LVM2 (also great if you're attempting redundancy or performance thru various RAID implementations via mdadm)
I've not studied into or tried LVM, though it will be an interesting exercise later on. I don't perceive that it is for the newbie, though. LVM is not an option on the current (Lucid Lynx Vers 10.04) Live CD, but seemingly is available as an option on the Alternate Install CD. There's not much on it except from third party sources, and again, it doesn't sound like a viable option for someone just starting out.

Traditional partitioning is hard enough for someone just starting out. Perhaps I'm wrong, but LVM seems even more complex, especially for someone looking to experiment and try various different OSes before settling on one (or two). That also might be my experiences speaking, though.

Now my experiments:

I did some experiments with creation/deletion/resizing/moving partitions, and came up with some interesting results. I was greatly surprised by one of them. All the experiments were performed using Gparted from my OS installed on sdb.

First, I found that no matter what I did, the drive designation (sda1, sda2, etc.) of a Primary partition does not change. I created two Primary partitions on an experimental drive I have in my laptop, and when I deleted sdc1, sdc2 remained sdc2. When I created another Primary partition after deleting sdc1, that partition became sdc1, leaving sdc2 as it was.

So I had another idea. Other than installing Windows, I always deal with Logical partitions. This leaves me with the ability to install multiple OSes and multiple partitions to use as different mount points from those OSes, such as a separate "/home" partition.

So I created an extended partition on the drive, which became sdc3 and created two Logical partitions within that, sdc5 and sdc6. As I suspected, when I deleted sda5, sda6 became the new sda5. This is why I was under the impression that the drive designations change; I mostly deal with Logical partitions, and since it happens with Logical partitions, I made the assumption that the same was true with Primary partitions.

Some good news though. I found that, no matter what I did with the Partition scheme, the UUID of existing partitions did not change. I have since found that the only time the UUID of an existing partition is changed is when that partition is reformatted. While recognizing a partition by its UUID is difficult, it can be made easier by including a commented out line that includes the OS name and type of partition ("/", "/home", etc.).

As far as booting, I'm not sure. I looked at my "/boot/grub/grub.cfg" file, and it seems to be done by UUID, but I'm unsure whether other OSes use the same technique. That will be my next research project.

My conclusion is this:

Unless one wants to access the root or other partitions used by another installation (and must reformat it), there shouldn't be any (or many) problems using the UUID for accessing partitions. The only thing I have to check now is whether OpenSUSE's GRUB uses the same techniques. I still can't imagine why SUSE's bootup failed looking for partition "sbx" that no longer existed.

I'm using this post as a reference for those who are interested. If you (or anyone else) has other ideas or suggestions, please do post. Linux (and computers in general) are a continuing learning process.
 
Old 08-15-2010, 08:29 PM   #4
-kg-
LQ Newbie
 
Registered: Jan 2010
Location: Godfrey, IL
Distribution: Ubuntu, Fedora, OpenSUSE, Knoppix, Puppy
Posts: 24

Original Poster
Rep: Reputation: 0
As an addendum:

I have found that both Ubuntu and Fedora seem to use UUID in identifying partitions, but OpenSUSE seems to use "dev/disk-by-id".
 
Old 08-17-2010, 06:45 AM   #5
xeleema
Member
 
Registered: Aug 2005
Location: D.i.t.h.o, Texas
Distribution: Slackware 13.x, rhel3/5, Solaris 8-10(sparc), HP-UX 11.x (pa-risc)
Posts: 987
Blog Entries: 4

Rep: Reputation: 252Reputation: 252Reputation: 252
Ah! I completly forgot about using an "Extended" partition.
Yes, indeed those little logical partitions defined within are renumbered when a "middle" one is removed. My apologies for my confusion, as I was under the impression this was from GRUB (or another boot loader) not being able to see all of the drives before the Linux kernel & drivers were loaded (that's burned me quite badly before in the past).

For what it's worth, the solution I developed in the past was to just simply avoid having an "Extended" partition. Works quite well if you're only trying to triple-boot between Solaris, Linux, and Windows (an old laptop configuration of mine)

Anytime I need more than three operating systems, I just resort to Virtual Machines.

Glad I could help!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get Drive letter and serial number of thumb drive in linux? manucng Linux - Newbie 3 02-05-2010 02:25 AM
grep regex number decimal capital letter casperdaghost Linux - Newbie 4 08-22-2009 06:32 AM
Confused about HDD designations in Linux jacatone Linux - Newbie 3 06-06-2008 02:42 PM
can Linux re-letter my Windows partition? newbiesforever Linux - General 6 08-28-2007 07:36 AM
Max number of linux partition rupesh_pulikool Linux - General 2 01-22-2005 07:59 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:37 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration