Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I recently installed another harddrive into my Arch Linux computer. The first time I booted up all worked fine. The next time I restarted my computer though I was greeted with a /dev/sda2 not found error.

See, basically sometimes my boot harddrive is sda and sometimes it's sdb. It appears to be completely random and I don't see any options for making it non-random in the BIOS. How do I fix this?

share|improve this question

If your two hard disks are on different interfaces and controlled by different drivers, Linux will name them in the order in which the drivers are initialized. If the initializations are in parallel, this can indeed cause the device name assignments to vary.

Device names are assigned by udev. Your problem is mentioned in the Arch wiki, but there doesn't seem to be a solution there.

I'm not familiar with Arch, so I'll explain how this problem is solved in Ubuntu; the underlying features are provided by the Linux kernel, which is the same, but there might be configuration settings that make these features work differently on Arch.

Rather than use /dev/sda2 as the root device (the root=) setting in the bootloader, you can use a UUID or a label, with the following syntax:

… /boot/vmlinuz root=UUID=01234567-89ab-cdef-0123-456789abcdef ro …
… /boot/vmlinuz root=LABEL=mylabel ro …

The UUID identifies a filesystem uniquely, so you want the UUID of the filesystem that's on /dev/sda2. On Ubuntu, /dev/disk/by-uuid/01234567-89ab-cdef-0123-456789abcdef is a symbolic link to /dev/sda2. If your filesystem has a label (set manually, it's up to you to enforce uniqueness), there's a symbolic link under /dev/disk/by-label. The labels and UUID links are generated by the following udev rules:

ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}"
ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_FS_LABEL_ENC}=="?*", SYMLINK+="disk/by-label/$env{ID_FS_LABEL_ENC}"
share|improve this answer

Take a look at Persistant block device naming.

Personally, I think labels are the best, since they give you the uniqueness of UUIDs, but are human-readable.

You'll end up with an fstab something like this:

LABEL=boot /boot ext2 defaults 0 1
LABEL=swap swap swap defaults 0 0
LABEL=root / ext4 defaults 0 1
share|improve this answer

You must log in to answer this question.

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