0

I am building Linux from Scratch to put on a usb drive but don’t know if Linux always calls the drive being booted from /dev/sda or not.

I have two disks in the system, my SSD which is called /dev/sda in my Arch install, and my USB drive which is called /dev/sdb.

Should my /etc/fstab file look something like this:

    # <device>             <dir>         <type>    <options>             <dump> <fsck>
    /dev/sda1              /             ext4      noatime               0      1
    /dev/sda2              none          swap      defaults              0      0
    /dev/sda3              /home         ext4      noatime               0      2

or something like this:

    # <device>             <dir>         <type>    <options>             <dump> <fsck>
    /dev/sdb1              /             ext4      noatime               0      1
    /dev/sdb2              none          swap      defaults              0      0
    /dev/sdb3              /home         ext4      noatime               0      2
1

3 Answers 3

4

You should not use sda or sdb. While in practice it is likely that the internal disk will be recognized first and become sda, you don't know for sure. You may also come across a computer with two internal disks, and then sdb will be wrong.

To identify your USB drive, use either the UUID or the label of the partition you want to use. It will be something like

/dev/disk/by-uuid/12345678-1234-1234-1234-123456789abc

or

/dev/disk/by-label/usb-drive

The UUID is a random value, it should be uniq. If you use the label, make sure to use a uniq name.

2

In the general case, it does not.

Prefer something like this:

UUID=0a3407de-014b-458b-b5c1-848e92a327a3 /     ext4   defaults

https://wiki.archlinux.org/index.php/fstab#File_system_UUIDs

If you are installing from the Linux text console... I might suggest installing gpm, so you can do "copy & paste" using the mouse :-).

0

I've installed a new system (ubuntu 22.04 LTS) using ZFS mirror on two 120gb ssd, and using /dev/sda1 /boot/efi in /etc/fstab saves me a lot of configuration time. When you pull out one of the two disk simulating it's broken, if I've used uuid instead of /sda1 it will only boot just one disk, the second disk won't boot because it has a different uuid.

It is true that sd letters can change, sda will be the first disk recognized by the motherboard and the OS, and Linux it is not rolling dices in order to determine which disk will be recognize first, it will follow the motherboard sata order related to the sata numbers in the motherboard. If you connect the system drives on SATA1 and SATA2, the mirror drives will always be sda for SATA1 and sdb for SATA2. If sda is broken, when you pulled it out, prior sdb will be now sda and it will boot normally.

I usually label both ends of SATA cables with letters A B C in order to match motherboard SATA sequence numbers, so you don't mess up with wrong connections while working with disks.

Summary:

  • I recommend using UUID for everything except for /boot/efi
  • I recommend using /dev/sda1 for /boot/efi

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .