Bananian

Banana Pi is switching HHDs /dev/sda and /dev/sdb between system starts

5 4712
Markus  
Hello,

I have a problem with my Banana Pi and I would ask you if you can help me with that. I have attached 2 hard disks to my Banana Pi: Disk 1 per SATA and disk 2 per USB. If I boot my Pi when it was turned off, disk 1 is assigned to /dev/sda and disk 2 is assigned to /dev/sdb. When I perform a reboot the assignments are switched, so that disk 1 is assigned to /dev/sdb and disk 2 is assigned to /dev/sda. How can I make a persisten assignment, so that each disk is everytime assigned to the same /dev/sdX? I will use the mounting to edit uEnv.txt and use it to boot from the SATA disk with "root=/dev/sda1", for example.

I read a lot about UUIDs, udev, fstab, and so forth. But as I'm not a linux specialist, I'm not sure which way would be the best and most common one. If I read that correctly, using udev would be a good way. But my rule to assign something like /dev/usbhd did not work. I'm wondering if udev will work at all as I could not find any rule files in /etc/udev/rules.d and the tutorials say that there should be default rule files. But it could be that udev is the wrong way as I need the /dev/sda1 to mount my root file system in which the /etc/udev/rules.d is located. So maybe I have to interfere at an earlyer point in the booting process.

So I hope that I pointed out my problem precise enough so that you can help my.

Kind regards
Markus
mpps  
Edited by mpps at Fri Oct 31, 2014 09:19

Hi Markus,

Yes, you can mount the disk via uuid... so far i know the id will change when you change the partition...

I prefer to mount by label: /dev/disk/by-label/mylabel

edit:
From my point of view hdds connected to sata they always appear as /dev/sdax...
I read your post a second time, and I missed the uEnv.txt... I am not sure but I think I have tried to use label in uEnv.txt and it was not working, but sata and /dev/sda1 is working fine for me...
I have not tried UUID in uEnv.txt...

I have 5 disks connected to one bpi and every disk has a name ;)

Regards
mpps

The recommended way is to reference the disks with UUIDs. Check the Debian reference for fstab to see what options you have:
https://wiki.debian.org/fstab
If your labels are unique, you could also use labels as identifiers for your filesystems. I prefer UUIDs because they can be used also in other places where labels can not be used (for example hdparm.conf).

Markus  
The problem is, that I need the reference to the disk in the uEnv.txt to mount my root filesystem. When I see this correctly, fstab can't be used because it is not loaded at this early point at all. fstab can be used later to mount additionaly disks as /media/XXX for example, but not to reference the root filesystem. Please correct my if this is worng.

Like Bananian wrote here (http://forum.lemaker.org/forum.p ... 7&fromuid=28977) the UUID can't be used either. Only PARTUUID is supported at this point. But how can I find this PARTUUID?

Regards
Markus

tkaiser  
Edited by tkaiser at Mon Nov 3, 2014 13:46
Markus replied at Mon Nov 3, 2014 13:38
Only PARTUUID is supported at this point. But how can I find this PARTUUID?


You might want to try gdisk for example:
  1. root@bananas ~ # gdisk /dev/sda
  2. GPT fdisk (gdisk) version 0.8.5

  3. Partition table scan:
  4.   MBR: protective
  5.   BSD: not present
  6.   APM: not present
  7.   GPT: present

  8. Found valid GPT with protective MBR; using GPT.

  9. Command (? for help): i
  10. Using 1
  11. Partition GUID code: EBD0A0A2-B9E5-4433-87C0-68B6B72699C7 (Microsoft basic data)
  12. Partition unique GUID: B6C9A755-364E-47E4-8665-1181A288457A
  13. First sector: 3072 (at 1.5 MiB)
  14. Last sector: 234439680 (at 111.8 GiB)
  15. Partition size: 234436609 sectors (111.8 GiB)
  16. Attribute flags: 0000000000000000
  17. Partition name: 'primary'

  18. Command (? for help): q
Copy the Code

Markus  
Hi!

I had a realy hard time to install a GPT without loosing all my data. But in the end it worked and the Pi is now booting without problems! Thank you very much!!

Regards
Markus

You have to log in before you can reply Login | Sign Up

Points Rules