Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] Grub: root= device keeps switching sda to sdb
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
elmar283
Guru
Guru


Joined: 06 Dec 2004
Posts: 316
Location: Haarlem, Netherlands

PostPosted: Sun Aug 05, 2018 11:08 am    Post subject: [SOLVED] Grub: root= device keeps switching sda to sdb Reply with quote

I have a Macbook Pro with MacOS and Gentoo on it.
I have two problems right now:
1. since a month when I boot sometimes the first harddrive (I have only one) is sda and sometimes it is sdb.
On /etc/fstab I solved this by replaceing the devicenames by UUID.
2. os-prober does not work.

The first queation I will ask here.

To fix the problem I have set the kernel "CONFIG_CMDLINE="root=PARTUUID=fc80794a-f214-41c3-a046-46403a8e4a63".

But 'grub-mkconfig' keeps passing on 'root=/dev/sda' in '/boot/grub/grub.cfg'.

I have three questions:
1. Why does hda keeps switching to hdb and back?
2. How can I stop 'grub-mkconfig' from passing the 'root=/dev/sda' in '/boot/grub/grub.cfg' or
3 Is it possible to set the UUID in '/etc/default/grub'?

I tried the last by setting 'GRUB_DEVICE="UUID=da72d0b5-bd89-4cb8-8958-c820691077d7"', but that doesn't work.

Some information about my system:
http://www.elmarotter.eu/bestanden/boxmodel/index.php?dir=Gentoo/grub

EDIT: I changed hda and hda to sda and sdb.


Last edited by elmar283 on Sun Aug 12, 2018 3:07 pm; edited 2 times in total
Back to top
View user's profile Send private message
LIsLinuxIsSogood
Veteran
Veteran


Joined: 13 Feb 2016
Posts: 1179

PostPosted: Sun Aug 05, 2018 12:15 pm    Post subject: Reply with quote

Quote:
1. Why does hda keeps switching to hdb and back?

So what happens to the first block device when the main harddrive is remapped to hdb...sorry for answering with a question but i think if you can figure out why maybe there is another device there like your usb card reader in lsusb output
provided by you.

To answer the more important question of booting using uuid i think you will find good luck with applying some variation of what you already attempted to put into the kernel config parameyer as an argument but doing so in /etc/default/grub so that this change is made more permanent with with respect to later uses like update-grub, or whatever.

I spent almost two hours today working on a similar issue of having a bootable system that was not recognizing EFI firmware, so please let me know if you cant figure out. The thing i had to do was to attempt boot options in different combos for root= and rootdrlay= but eventually turned up a solution betweecn those and some minor edits to one of the files in the EFI directory which is where the system boots from.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54216
Location: 56N 3W

PostPosted: Sun Aug 05, 2018 12:32 pm    Post subject: Reply with quote

elmar283,

To build on what LIsLinuxIsSogood is saying, please pastebin your dmesg output when your hdd is /dev/sdb.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Jaglover
Watchman
Watchman


Joined: 29 May 2005
Posts: 8291
Location: Saint Amant, Acadiana

PostPosted: Sun Aug 05, 2018 12:49 pm    Post subject: Reply with quote

There is SATA controller and AHCI in kernel. Why we are talking about hda/hdb? Why are those PATA drivers enabled in kernel?
_________________
My Gentoo installation notes.
Please learn how to denote units correctly!
Back to top
View user's profile Send private message
elmar283
Guru
Guru


Joined: 06 Dec 2004
Posts: 316
Location: Haarlem, Netherlands

PostPosted: Sun Aug 05, 2018 1:56 pm    Post subject: Reply with quote

Jaglover wrote:
There is SATA controller and AHCI in kernel. Why we are talking about hda/hdb? Why are those PATA drivers enabled in kernel?

Sorry, you're wright. it is '/dev/sda' and '/dev/sdb'
Back to top
View user's profile Send private message
elmar283
Guru
Guru


Joined: 06 Dec 2004
Posts: 316
Location: Haarlem, Netherlands

PostPosted: Sun Aug 05, 2018 2:06 pm    Post subject: Reply with quote

Here is the dmesg when system is sdb:
http://www.elmarotter.eu/bestanden/boxmodel/Gentoo/grub/dmesg_sdb.txt
Back to top
View user's profile Send private message
Anon-E-moose
Watchman
Watchman


Joined: 23 May 2008
Posts: 6097
Location: Dallas area

PostPosted: Sun Aug 05, 2018 2:07 pm    Post subject: Reply with quote

Almost sounds like you have some external device plugged in (sometimes) which makes it change from sda to sdb.
Do you have any usb devices (disk, stick) ever plugged in before booting?
(I've had the bios interpret some usb sticks as hard disks)


edit to add: just looked at your last post

Code:
1.764030] sd 1:0:0:0: [sda] Attached SCSI removable disk

_________________
PRIME x570-pro, 3700x, 6.1 zen kernel
gcc 13, profile 17.0 (custom bare multilib), openrc, wayland
Back to top
View user's profile Send private message
Jaglover
Watchman
Watchman


Joined: 29 May 2005
Posts: 8291
Location: Saint Amant, Acadiana

PostPosted: Sun Aug 05, 2018 2:10 pm    Post subject: Reply with quote

Code:
[    1.762599] scsi 1:0:0:0: Direct-Access     APPLE    SD Card Reader   3.00 PQ: 0 ANSI: 6
[    1.763023] sd 1:0:0:0: Attached scsi generic sg0 type 0
[    1.764030] sd 1:0:0:0: [sda] Attached SCSI removable disk

Easiest way is probably to build this driver as module so it never gets loaded before AHCI.
_________________
My Gentoo installation notes.
Please learn how to denote units correctly!
Back to top
View user's profile Send private message
elmar283
Guru
Guru


Joined: 06 Dec 2004
Posts: 316
Location: Haarlem, Netherlands

PostPosted: Sun Aug 05, 2018 2:12 pm    Post subject: Reply with quote

It seems to be a card reeder that is now sda:
Code:

[    1.762599] scsi 1:0:0:0: Direct-Access     APPLE    SD Card Reader   3.00 PQ: 0 ANSI: 6
[    1.763023] sd 1:0:0:0: Attached scsi generic sg0 type 0
[    1.764030] sd 1:0:0:0: [sda] Attached SCSI removable disk

and the sdb:
Code:

[    1.958270] scsi 0:0:0:0: Direct-Access     ATA      APPLE SSD SM0256 SA0Q PQ: 0 ANSI: 5
[    1.958410] sd 0:0:0:0: Attached scsi generic sg1 type 0
[    1.958416] sd 0:0:0:0: [sdb] 490234752 512-byte logical blocks: (251 GB/234 GiB)
[    1.958418] sd 0:0:0:0: [sdb] 4096-byte physical blocks
[    1.958427] sd 0:0:0:0: [sdb] Write Protect is off
[    1.958429] sd 0:0:0:0: [sdb] Mode Sense: 00 3a 00 00
[    1.958444] sd 0:0:0:0: [sdb] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[    1.961742]  sdb: sdb1 sdb2 sdb3 sdb4 sdb5 sdb6
[    1.962108] sd 0:0:0:0: [sdb] Attached SCSI disk
Back to top
View user's profile Send private message
Anon-E-moose
Watchman
Watchman


Joined: 23 May 2008
Posts: 6097
Location: Dallas area

PostPosted: Sun Aug 05, 2018 2:20 pm    Post subject: Reply with quote

Jaglover wrote:

Easiest way is probably to build this driver as module so it never gets loaded before AHCI.


That would solve it, I keep my usb devices as modules just for that reason.
_________________
PRIME x570-pro, 3700x, 6.1 zen kernel
gcc 13, profile 17.0 (custom bare multilib), openrc, wayland
Back to top
View user's profile Send private message
LIsLinuxIsSogood
Veteran
Veteran


Joined: 13 Feb 2016
Posts: 1179

PostPosted: Sun Aug 12, 2018 11:49 am    Post subject: Reply with quote

Anon-E-moose...I wonder if you by creating kernel modules there what would happen if there was a need for access to the files on those other storage devices early on like during the boot process still, and wouldn't this make a problem if that were the case?


Elmar, because I think we only answered the first of your questions here's answers to more of them.
Quote:
2. How can I stop 'grub-mkconfig' from passing the 'root=/dev/sda' in '/boot/grub/grub.cfg' or

The simplest way is just not to use the tool at all. The other way I think is how you suggested in /etc/default/grub, but that is if you are using the auto config tool that is grub-mkconfig, which you may not have to.
Quote:
3 Is it possible to set the UUID in '/etc/default/grub'?

Yes, but take a look at syntax you used there I think it was slightly incorrect, but surely it must be possible to do this. I assume that a tool that is primarily used for automating the configuration process is meant as an initial step to get you 90% of the way there, and you don't have to necessarily count on it to get you 100%. You can make the rest of the changes yourself if you know what to do when navigating the final file.

And it still beats having to write the things from from scratch.
Back to top
View user's profile Send private message
LIsLinuxIsSogood
Veteran
Veteran


Joined: 13 Feb 2016
Posts: 1179

PostPosted: Sun Aug 12, 2018 12:00 pm    Post subject: Reply with quote

Here are some other things to be aware of :
Potential risks such as security risk that could be an unwanted boot entry in the configuration file, or maybe something that tries to boot up another network resouces or PXE from a network host, or operating system that you did not intend to have on there.

Not getting locked out of the system, meaning have a readily available way back in via a rescue system, or be sure to thoroughly inspect the grub file before rebooting to make sure what you are committing to it. I think grub does come with a way of testing this from within the operating system. Or you can just fire up a text editor always.

Don't count on there being an easy way to retrieve any of your difficult or hard efforts in configuration boot parameters and therefore make a backup of the configuration files you work with just like you would with a working kernel it makes sense (in my opinion) to have a grub.cfg.old in case of restoring or if the actual grub.cfg file becomes corrupt in which case it is likely that something could be wrong with grub itself and then what is easier, if grub is still correctly installed on the device then having a working kernel and grub boot file saves time here.

Lastly instead of relying on mkconfig to get it right, you can work with the grub.cfg file and the grub-mkconfig tool as either a last resort or to replace a missing boot configuration. But otherwise perhaps going into the file and seeing why it doesn't work...that sounds like a better idea.

So did you get root=/dev/sda to be working correctly, or are you still thinking to change it to root=UUID=
Back to top
View user's profile Send private message
LIsLinuxIsSogood
Veteran
Veteran


Joined: 13 Feb 2016
Posts: 1179

PostPosted: Sun Aug 12, 2018 12:04 pm    Post subject: Reply with quote

And lastly see here: https://unix.stackexchange.com/questions/93767/why-cant-i-specify-my-root-fs-with-a-uuid

root=UUID only works with an initramfs, which if you don't have means you should be using root=PARTUUID instead.
Back to top
View user's profile Send private message
elmar283
Guru
Guru


Joined: 06 Dec 2004
Posts: 316
Location: Haarlem, Netherlands

PostPosted: Sun Aug 12, 2018 3:07 pm    Post subject: Reply with quote

I sovled it by using Refind instead of grub. Now I can boot Gentoo and MacOS from refind.
I have put the partuid of /dev/sda4 in the kernel.
Back to top
View user's profile Send private message
LIsLinuxIsSogood
Veteran
Veteran


Joined: 13 Feb 2016
Posts: 1179

PostPosted: Mon Aug 13, 2018 1:01 am    Post subject: Reply with quote

I just got through making the change myself on my system...it only runs linux on it actually only Gentoo linux, but the funny thing is adding disks via SATA or USB or whatever could st ill have thrown in a wrench in the boot process.

So now I too can claim that I have a more reliable avenue to boot with the instruction embedded into the kernel itself (way to figure that out with little or no help elmar283) And Thanks by the way :)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum