disk order -- sda, sdb vs, hardware

Questions about Grub, UEFI,the liveCD and the installer
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
User avatar
SaintDanBert
Level 4
Level 4
Posts: 449
Joined: Sat Feb 20, 2010 4:04 pm
Location: Covington, LA USA

disk order -- sda, sdb vs, hardware

Post by SaintDanBert »

I'm writing because my search does not find the details I'm seeking. I suspect that I've used the wrong search words in the past. I hope that someone here might (1) guide me to effective searches, and (2) help me resolve my situation.

My laptop already has a 1TB HDD as /dev/sda. This drive boots, holds /boot and / file systems, and runs just fine.
I removed an unused cell-phone adapter and added a 256GB mSATA SDD-drive to my laptop. I now have /dev/sdb which is the mSATA SDD.
This drive order seems to survive power-off restart. (I have not seen the order change ... yet.)
  • /dev/sda -- the HDD
  • /dev/sdb -- the mSATA SDD
How do I configure so that the mSATA SDD appears as /dev/sda and the HDD appears as /dev/sdb?
I know that GRUB can find boot parts on whichever drive and file system I name in the configuration. Over too many years, I've had troubles when trying to boot from something other than the first, or primary, or /dev/sda drive of a system.
With modern hardware and loaders does it matter, other than my own peace-of-mind, that my boot drive is /dev/sdb instead of /dev/sda?
I'm running Mint 18.3 and understand that UDEV and friends manage the contents of /dev during startup. That suggests that I could create local udev rules to accomplish the drive order changes. I have no idea how to manipulate udev-rules, but i'm willing to learn.
Will someone explain or direct me to an effective tutorial, if udev-rule writing is how I resolve my troubles?

FOLLOW-UP:
How do I enable logging or other ways to watch what is happening with UDEV during power-on restart and boot? My workstation clearly has /dev/sdb as an available drive. However, I don't find any mention of this device in /var/log/syslog.


Related Questions
I want the SDD to serve as the boot drive and provide all of the resources for speedy boot, effective suspend and restore, and related behavior. I know this means that I write GRUB to the SDD. I suspect that I place my /boot folder and contents onto the SDD as well.
The drive is 256GB so I must be choosy. The drive is SDD so I must be careful about read-write cycles and such.
Which other system folders and files do I place onto the SDD?
Does it make sense to maintain both drives as bootable as a just-in-case recovery configuration?

Thanks in advance,
~~~ 0;-Dan
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
ricardogroetaers
Level 6
Level 6
Posts: 1374
Joined: Sat Oct 27, 2018 3:06 am
Location: Rio de Janeiro, Brasil

Re: disk order -- sda, sdb vs, hardware

Post by ricardogroetaers »

SaintDanBert wrote: Wed Nov 21, 2018 2:28 pm My laptop already has a 1TB HDD as /dev/sda. .......
I removed an unused cell-phone adapter and added a 256GB mSATA SDD-drive to my laptop. I now have /dev/sdb which is the mSATA SDD.
This drive order seems to survive power-off restart. (I have not seen the order change ... yet.)
  • /dev/sda -- the HDD
  • /dev/sdb -- the mSATA SDD
How do I configure so that the mSATA SDD appears as /dev/sda and the HDD appears as /dev/sdb?
The hard drive is internal and (probably) connected to the first SATA port on the motherboard.
The SSD is connected internally to the second (or other) SATA port or is connected to a USB port through an adapter.
In this condition the hard disk will always be represented by the special sda device file. The SSD or any other storage device will be represented by sdb, sdc, and so on.

Example:
sda1
sd -> stands for SATA disk, SCSI disk, IDE disk or similar.
a -> first SATA, IDE or similar port
b -> second SATA port, IDE, ....
c -> third port ....... and so on.
1 -> first partition of the disk
2 -> second partition, ....

The solution would be to connect the SSD to the first internal SATA port on the motherboard and the HDD to the USB port through the adapter or to the second SATA port on the motherboard (if there is any physical space, of course).

Another solution would be to maintain the current physical connections however by installing the boot and operating system on the SSD. However it is not guaranteed that the SSD is designated by sda.

It is due to these unpredictability that it is recommended to designate in fstab the file system to be mounted by its UUID and not by the special device file that represents it.

The device file may change unpredictably, either by connecting another device, or by connecting the device to another port, or even by simply installing software.
phd21
Level 20
Level 20
Posts: 10104
Joined: Thu Jan 09, 2014 9:42 pm
Location: Florida

Re: disk order -- sda, sdb vs, hardware

Post by phd21 »

Hi SaintDanBert,

I just read your post and the good replies to it. Here are my thoughts on this as well.

My suggestions would be to clone using "Clonezilla Live" (or copy using "gparted" partition manager) the current Linux Mint partition on the 1tb drive to the new 256GB mSATA SDD-drive so that you can benefit from the speedy SSDrive, then change the Bios boot order to make the SSD the first drive boot device and the 1tb the second drive boot device. You can then reformat or delete the Linux Mint Partition from the 1tb drive and reclaim that space. Cloning the drive assumes that the Linux Mint bootable partition on the 1tb drive is less than 256gb or is using less than 256gb and if not you could easily change that using a bootable partition manager like "gparted" before cloning or copying. This is what I did when I got my SSDrive.

OR, You could also just install a fresh copy of Linux Mint onto the SSDrive, then copy whatever you want from the original 1tb drive to the new SSDrive. Recommend using Aptik on the original 1tb Linux Mint to backup everything to an external backup drive, then on the fresh Linux Mint install on the SSD, install Aptik and restore from the Aptik backup.

It would help to know more about your system setup. If you run "inxi -Fxzd" and "lsblk -a" and "lsusb" from the console terminal prompt, highlight the results, copy and paste them back here, that should provide enough information.


Hope this helps ...
Phd21: Mint 20 Cinnamon & KDE Neon 64-bit Awesome OS's, Dell Inspiron I5 7000 (7573, quad core i5-8250U ) 2 in 1 touch screen
User avatar
SaintDanBert
Level 4
Level 4
Posts: 449
Joined: Sat Feb 20, 2010 4:04 pm
Location: Covington, LA USA

Re: disk order -- sda, sdb vs, hardware

Post by SaintDanBert »

phd21 wrote: Thu Nov 22, 2018 6:19 pm ...
I just read your post and the good replies to it. Here are my thoughts on this as well.
Thanks for reading my questions and taking time for such a detailed reply.
phd21 wrote: Thu Nov 22, 2018 6:19 pm ...
then change the Bios boot order to make the SSD the first drive boot device and the 1tb the second drive boot device. You can then reformat or delete the Linux Mint Partition from the 1tb drive and reclaim that space.
I agree about changing the boot order to boot from the SSD. However, I'm trying to sort out my old-school/old-world knowledge versus the current world of dynamic everything. My laptop clearly sees
  • first device ==> internal HDD (linux gets /dev/sda)
  • second device ==> internal SDD (linux gets /dev/sdb)
  • third device ==> drive bay in docking station (linux gets /dev/sdc if an HDD)
IMPORTANT -- I hope that there is some way to configure linux such that the SDD appears as /dev/sda and the HDD appears as /dev/sdb. I understand that this is a job for UDEV rules. From ancient times, I so used to booting from the "first drive" as default, that using /dev/sdb warps my brain.
phd21 wrote: Thu Nov 22, 2018 6:19 pm Cloning the drive assumes that the Linux Mint bootable partition on the 1tb drive is less than 256gb or is using less than 256gb and if not you could easily change that using a bootable partition manager like "gparted" before cloning or copying. This is what I did when I got my SSDrive.
I wrote grub onto the internal 1TB HDD. There is a /boot file system and a /(root) and swap file system. There is a separate /home file system. All of this appears as /dev/sda. Could I simply clone the /boot file systen onto the SDD as /dev/s/db and then write grub to the SDD as well? I would really like to be able to boot either /dev/sda or /dev/sdb using the same grub menu choices. I'd need some way to keep /boot in sync if they are duplicates.
phd21 wrote: Thu Nov 22, 2018 6:19 pm OR, You could also just install a fresh copy of Linux Mint onto the SSDrive, then copy whatever you want from the original 1tb drive to the new SSDrive. Recommend using Aptik on the original 1tb Linux Mint to backup everything to an external backup drive, then on the fresh Linux Mint install on the SSD, install Aptik and restore from the Aptik backup.
I plan to do exactly this once Linux Mint 19.1 gets published. I'm running Mint 18.3 now and I'm wanting to learn about what I'm doing then enjoy my SDD a bit while I'm waiting.
phd21 wrote: Thu Nov 22, 2018 6:19 pm It would help to know more about your system setup. If you run "inxi -Fxzd" and "lsblk -a" and "lsusb" from the console terminal prompt, highlight the results, copy and paste them back here, that should provide enough information.
As you requested:
NOTE -- I'm not using USB connected drives during boot. There is a 1TB internal HDD and a 256GB internal SDD. Also, there is a docking station drive bat that can accept either and HDD tray or a DVD tray. I show the HDD tray installed below.

Code: Select all

prompt$ lsblk --fs -o name,fstype,label,mountpoint

NAME        FSTYPE LABEL           MOUNTPOINT
sda                                
├─sda1      ntfs   Win7-Helper     
├─sda2      ntfs   Wn7-System      
├─sda3      ext4   LnxBoot         /boot
├─sda4                             
├─sda5      ntfs   Lenovo_Recovery 
├─sda6      swap   LnxSwap         [SWAP]
├─sda7      ext4   LnxRoot         /
├─sda8      ext4   LnxHome         /home
└─sda9      ext4   LnxWork         /wrk
sdb                                
└─sdb1      btrfs  SysSSD          
sdc                                
└─sdc1      ext4   test-hdd        
mmcblk0                            
└─mmcblk0p1 vfat   SD-KAYWINE      /media/saint/SD-KAYWINE

Code: Select all

prompt$ inxi -dCRSM -c 0

System:    Host: kaywine Kernel: 4.4.0-116-generic x86_64 (64 bit)
           Desktop: Cinnamon 3.6.7  Distro: Linux Mint 18.3 Sylvia
Machine:   System: LENOVO (portable) product: 4294CTO v: ThinkPad X220 Tablet
           Mobo: LENOVO model: 4294CTO Bios: LENOVO v: 8DET70WW (1.40 ) date: 05/14/2015
CPU:       Dual core Intel Core i5-2520M (-HT-MCP-) cache: 3072 KB 
           clock speeds: max: 3200 MHz 1: 1115 MHz 2: 1374 MHz 3: 914 MHz 4: 853 MHz
Drives:    HDD Total Size: 2256.5GB (10.6% used)
           ID-1: /dev/mmcblk0 model: N/A size: 16.0GB
           ID-2: /dev/sda model: WDC_WD10SPCX size: 1000.2GB
           ID-3: /dev/sdb model: SAMSUNG_SSD_PM85 size: 256.1GB
           ID-4: /dev/sdc model: WDC_WD10SPCX size: 1000.2GB
           Optical: No optical drives detected.
RAID:      No RAID devices: /proc/mdstat, md_mod kernel module present
phd21
Level 20
Level 20
Posts: 10104
Joined: Thu Jan 09, 2014 9:42 pm
Location: Florida

Re: disk order -- sda, sdb vs, hardware

Post by phd21 »

Hi SaintDanBert,

You are welcome...
SaintDanBert wrote:I agree about changing the boot order to boot from the SSD. However, I'm trying to sort out my old-school/old-world knowledge versus the current world of dynamic everything. My laptop clearly sees
  • first device ==> internal HDD (linux gets /dev/sda)
  • second device ==> internal SDD (linux gets /dev/sdb)
  • third device ==> drive bay in docking station (linux gets /dev/sdc if an HDD)
IMPORTANT -- I hope that there is some way to configure linux such that the SDD appears as /dev/sda and the HDD appears as /dev/sdb. I understand that this is a job for UDEV rules. From ancient times, I so used to booting from the "first drive" as default, that using /dev/sdb warps my brain.
I am pretty sure, if you just change the boot priority so that the SSDrive is the first boot device and the 1tb drive is the second boot device, reboot, the SSDrive will become "sda" and the 1tb will become "sdb" without having to do anything else. Try it...
SaintDanBert wrote:
phd21 wrote: Thu Nov 22, 2018 6:19 pm Cloning the drive assumes that the Linux Mint bootable partition on the 1tb drive is less than 256gb or is using less than 256gb and if not you could easily change that using a bootable partition manager like "gparted" before cloning or copying. This is what I did when I got my SSDrive.
I wrote grub onto the internal 1TB HDD. There is a /boot file system and a /(root) and swap file system. There is a separate /home file system. All of this appears as /dev/sda. Could I simply clone the /boot file systen onto the SDD as /dev/sdb and then write grub to the SDD as well? I would really like to be able to boot either /dev/sda or /dev/sdb using the same grub menu choices. I'd need some way to keep /boot in sync if they are duplicates.
You can always easily update the grub bootloader after booting into either drive.

Code: Select all

sudo update-grub
I do not recommend having duplicate operating systems attached while booting up. My KDE systems recognize on bootup if another KDE system is attached and it sometimes gets confused.

Are you going to dual-boot the SSDrive with MS Windows and Linux? Because you already have a "dual-boot" scenario on the 1tb drive, you might be better off installing Linux Mint fresh onto the SSDrive and using Aptik to back up the existing Linux Mint on the 1tb drive and restoring that after booting to the SSDrive.

I noticed you have put the BTRFS file system on the SSDrive now. I really like the BTRFS filesystem, BUT there are too many problems with maintaining this at this time IMHO until all supporting OS packages support it well. The current Grub updating does not seem to work well with BTRFS filesystem especially if you have to recreate Grub and I have even had trouble cloning it by partition because of the bootup differences. This could just be my experience though...

Btrfs - ArchWiki
https://wiki.archlinux.org/index.php/btrfs

I did find this:
Antynea/grub-btrfs: grub-btrfs, Include btrfs snapshots at boot options. (grub menu)
https://github.com/Antynea/grub-btrfs

I do not see the benefit of having separate a Home folder. I do see the benefit of having a commonly shared data partition for mostly static (non-changing) folders and files like multi-media files (videos, music, pictures) or document and data archiving especially when backing up.

Depending upon how you want to clone (Clonezilla Live, etc...) or copy (gParted) the current partition(s) on the 1tb drive to the SSDrive will determine if you need to install or update the Grub bootloader. I found that if you copy partitions using gparted then you will probably have to install grub from a working bootable system using a command like that below, change the "sdb" to whatever the actual drive is.

Code: Select all

sudo grub-install /dev/sdb
SaintDanBert wrote:
phd21 wrote: Thu Nov 22, 2018 6:19 pm OR, You could also just install a fresh copy of Linux Mint onto the SSDrive, then copy whatever you want from the original 1tb drive to the new SSDrive. Recommend using Aptik on the original 1tb Linux Mint to backup everything to an external backup drive, then on the fresh Linux Mint install on the SSD, install Aptik and restore from the Aptik backup.
I plan to do exactly this once Linux Mint 19.1 gets published. I'm running Mint 18.3 now and I'm wanting to learn about what I'm doing then enjoy my SDD a bit while I'm waiting.
I would recommend using Linux Mint 18.x now on the SSDrive since it has long-term support until 2021.
SaintDanBert wrote:NOTE -- I'm not using USB connected drives during boot. There is a 1TB internal HDD and a 256GB internal SDD. Also, there is a docking station drive bat that can accept either and HDD tray or a DVD tray. I show the HDD tray installed below.
How is the docking station connected to your system?

Also, after setting up the new drive, I recommend updating the Linux Kernel to the 4.15.xx series or higher.

Hope this helps ...
Phd21: Mint 20 Cinnamon & KDE Neon 64-bit Awesome OS's, Dell Inspiron I5 7000 (7573, quad core i5-8250U ) 2 in 1 touch screen
Mark Phelps
Level 7
Level 7
Posts: 1869
Joined: Mon Jun 10, 2013 4:39 pm

Re: disk order -- sda, sdb vs, hardware

Post by Mark Phelps »

There is no way to "configure" the drives so that what is now shown as "sda" gets changed to "sdb" -- short of changing the physical connections between the motherboard and the drives.

There is no software or configuration file that will do this for you.
phd21
Level 20
Level 20
Posts: 10104
Joined: Thu Jan 09, 2014 9:42 pm
Location: Florida

Re: disk order -- sda, sdb vs, hardware

Post by phd21 »

Hi "Mark Phelps", "SaintDanBert", etc...

I tried just tried changing the Bios boot order to make my 2nd drive (sdb) boot first, but it did not change the drive designation from "sdb" to "sda".

You could just swap the SATA cables or the actual drives, and that should be enough to change the drive designators as well without having to do anything else.

I did find articles like "SaintDanBert" referenced where you can forcibly change the drive designators, but I think I would just change (swap) the cables or the drives.

Replace /dev/sda with /dev/sdb device name assignment - Bash - Snipplr Social Snippet Repository
https://snipplr.com/view/80310/replace- ... ssignment/

[ubuntu] [SOLVED] Swap /dev/sda and /dev/sdb?
https://ubuntuforums.org/showthread.php?t=966665

Persistent block device naming - ArchWiki
https://wiki.archlinux.org/index.php/pe ... ice_naming

Writing udev rules
http://www.reactivated.net/writing_udev_rules.html

Hope this helps ...
Phd21: Mint 20 Cinnamon & KDE Neon 64-bit Awesome OS's, Dell Inspiron I5 7000 (7573, quad core i5-8250U ) 2 in 1 touch screen
User avatar
SaintDanBert
Level 4
Level 4
Posts: 449
Joined: Sat Feb 20, 2010 4:04 pm
Location: Covington, LA USA

Re: disk order -- sda, sdb vs, hardware

Post by SaintDanBert »

phd21 wrote: Mon Nov 26, 2018 7:42 pm Hi "Mark Phelps", "SaintDanBert", etc...

I tried just tried changing the Bios boot order to make my 2nd drive (sdb) boot first, but it did not change the drive designation from "sdb" to "sda".

You could just swap the SATA cables or the actual drives, and that should be enough to change the drive designators as well without having to do anything else.

I did find articles like "SaintDanBert" referenced where you can forcibly change the drive designators, but I think I would just change (swap) the cables or the drives.

Replace /dev/sda with /dev/sdb device name assignment - Bash - Snipplr Social Snippet Repository
https://snipplr.com/view/80310/replace- ... ssignment/

[ubuntu] [SOLVED] Swap /dev/sda and /dev/sdb?
https://ubuntuforums.org/showthread.php?t=966665

Persistent block device naming - ArchWiki
https://wiki.archlinux.org/index.php/pe ... ice_naming

Writing udev rules
http://www.reactivated.net/writing_udev_rules.html

Hope this helps ...
Thanks for all of these references...

Tough to swap cables with a laptop workstation. I've done that many times with towers and pizza-box workstations.

I'll let you know if any of the reference articles work this out.

Thanks in advance,
~~~ *<];¬} Dan
phd21
Level 20
Level 20
Posts: 10104
Joined: Thu Jan 09, 2014 9:42 pm
Location: Florida

Re: disk order -- sda, sdb vs, hardware

Post by phd21 »

Hi "SaintDanBert",

You are welcome...

Obviously, if this is a laptop, swap the actual drives since you won't be able to swap the cables.
Phd21: Mint 20 Cinnamon & KDE Neon 64-bit Awesome OS's, Dell Inspiron I5 7000 (7573, quad core i5-8250U ) 2 in 1 touch screen
Locked

Return to “Installation & Boot”