Ubuntu - change block device location from /dev/sda to /dev/sdb

3

1

Host: Ubuntu 15.04

I have a M.2 SSD and one hard-disk.

The hard-disk device location is normally at /dev/sda and the SSD is at /dev/sdb.

I looked into some posts and found out some possible approaches I may take.

  1. Writing my own udev rule

    To do this, I need to modify the udev file in /etc/udev/rules.d/xxx-persistent.rules However, I only have 70-persistent-net.rules in my host and only net related devices appeared.

    SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="81:fb:5c:18:aa:d6", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
    

    Should I edit this file to add the rule here?

  2. Edit the symlink in /etc/disk/by-id ( or by-uuid )

  3. Edit the fstab file under /etc/fstab

      UUID=01d0c5a3-191b-4d59-91cd-99211226d5c9 /media/SSD/ ext4 errors=remount-ro 0       1
    

change to

  UUID=00d0c5a3-191b-4d59-91cd-99211226d5c9 /dev/sdc ext4 errors=remount-ro 0 1

although i added this line to the fstab ( the uuid is my ssd ), it still appears the device node is /dev/sda

This automatically mounts to /dev/sdb, how can I change the path here?

I don't find the sample for the 2 point. Any advice ?

Thanks

user3815726

Posted 2016-01-19T07:40:36.157

Reputation: 51

I am curious. Why do you want to swap these around? What goal are you trying to reach? – Hennes – 2016-01-19T08:17:26.517

@Hennes For example, I may need to install the operating system through Internet to the specific device location, this swap will be needed. – user3815726 – 2016-01-19T08:23:55.313

Why not install it to /dev/sdb if you want it on /dev/sdb andif you want in on /dev/sda install it to /dev/sda? No dik mapping swap needed. The only reason I came up with is if you want to move one of the disk to a new system where it will have a different name by default. If you are going to do that a lot (e.g. the SSD in an external eSATA case and moving it around between several computers) then yes. Such a rule makes sense. But if you keep it in one desktop/laptop then just tell the bootloader or the installer to look at the other disk. – Hennes – 2016-01-19T08:26:58.207

1@Hennes I use PXE to install the operating system and the default PXE will install the OS to the specific device location ( /dev/sda ) for example. However, /dev/sda/ is not the device which I expect to install this OS. Hence, I need to swap it. I know to do this through the PXE script but I am wondering If I can do it by swapping the device node. – user3815726 – 2016-01-19T08:30:41.520

(continued). If you do write a rule, take a look at https://www.veritas.com/support/en_US/article.TECH71007. (note: no linux here to test with atm, and I am not 100% sure how M2 and SATA map to SCSI/SAS).

– Hennes – 2016-01-19T08:31:22.497

@Hennes I thought I can do it in /etc/fstab, can't I ? – user3815726 – 2016-01-19T08:32:13.900

Let us continue this discussion in chat.

– user3815726 – 2016-01-19T08:34:03.563

No answers