cancel
Showing results for 
Search instead for 
Did you mean: 

Linux disk hardware question.

VileReynard
Seasoned Pro
Posts: 10,651
Thanks: 206
Fixes: 9
Registered: 01-09-2007

Linux disk hardware question.

I'm planning on inserting a 3rd SATA disk into my desktop.
Currently the two present disks are called /dev/sda & /dev/sdb
Is the name got from the physical SATA port on the motherboard?
This is quite important as I want the present /dev/sda to be referenced as /dev/sdc (or higher)
and the new disk as /dev/sda.
(I'm replacing a disk which is predicted to fail soon, with a newer one, but on a gradual basis).

10 REPLIES
Community Veteran
Posts: 3,380
Thanks: 2
Registered: 18-01-2013

Re: Linux disk hardware question.

Pretty sure they go in order of how they are seen in the Bios.
You're better off editing your fstab and using uuid as identifiers to hard code mount points. That way they won't mind which ports they are on and always get mounted in the right place.
Community Veteran
Posts: 1,136
Thanks: 2
Registered: 30-07-2007

Re: Linux disk hardware question.

I've not found SATA naming of drives to be reliable in Linux.
You could change your /etc/fstab to mount based on the UUID of the filesystems instead.

UUID=1cb270f0-7ad9-4654-91b2-a49938de2905 /              ext4    errors=remount-ro 0      1
# swap was on /dev/sda5 during installation
UUID=142b6da3-ecc3-424f-a6d6-1a5be1f1b369 none            swap    sw              0      0
UUID=2a446d37-ae69-4888-8a6d-d8050a7f6d0d /home ext4 errors=remount-ro

You find the uuid's with blkid
F9 member since 4 Sep 1999
F9 ADSL customer since 27 Aug 2004
DLM manages your line the same way DRM manages your rights.
Look at all the pretty graphs! (now with uptime logging!)
VileReynard
Seasoned Pro
Posts: 10,651
Thanks: 206
Fixes: 9
Registered: 01-09-2007

Re: Linux disk hardware question.

I do use uuid's a little bit the moment, but I'm sure that quite a few places use the old /dev/sdx notation.
I have to re-install Mint because I've managed to semi-screw up both the graphics drivers and X and have a drive which is on it's way out.
So I can do this - but I was trying to avoid too much scribbling of uuids (which work at the disk partition level).
Because I want to copy some of the data, I will get 3(?) new uuids to use in my fstab.  Sad
Present fstab - which looks a mess:
Quote
# /dev/sda1
UUID=51fe6ca2-9ab9-4b52-8ae5-35770fede582 / ext4 rw,errors=remount-ro,noatime 0 1
# /dev/sda2
#UUID=0648d2d1-9a41-4257-8b79-dfc7bc227e82 /home ext4 rw,errors=remount-ro 0 0
/dev/sda2 /home ext4 defaults,noatime,user_xattr 0 2
/dev/sda3 /mnt/video ext4 defaults,noatime    0      2
/dev/sdb2 /mnt/backup ext4 defaults,noatime    0      2
/dev/sdb3 /mnt/filestore ext4 defaults,noatime 0      2
/swapfile none swap sw 0 0
NAS:/mnt/C/ /media/NAS nfs    rw,hard,intr,users,noauto,noatime,namlen=250 0 2
/dev/scd0    /media/cdrom0  udf,iso9660 user,noauto,exec,utf8 0      0
Which is plain horrible.  Cry

PeeGee
Aspiring Pro
Posts: 1,077
Thanks: 44
Fixes: 3
Registered: 05-04-2009

Re: Linux disk hardware question.

Almost any referencing is better than /dev/sdxy as they are independent of the BIOS quirks. You should be able to easily change fstab through the partitioning tools and editing the mount point for the partition (apart from "/", where you should get a warning) by using the drop-down list.
If you use "mount by label" (temporarily), it is easy to change disks/partitions and then change to "uuid" or "by-id" for running. I tend to use "by-id" as it is "human friendly" and you can cut/paste/modify the partition reference easily - including for "/" Smiley
The only "difficult" bit is "repairing" grub to use a new boot disk/partition Roll eyes
Plusnet Fibre (Sep 2014), Essentials (Feb 2013); ADSL (Apr 2009); Customer since Jan 2004 (on 28kb dial-up)
Using a TP-Link TD-W9980 modem-router.
Community Veteran
Posts: 6,611
Thanks: 209
Fixes: 15
Registered: 16-02-2009

Re: Linux disk hardware question.

I use mount by label all the time, a lot easier than finding out the uuid.
This is a default install then the added 2 drives:
# / was on /dev/sda1 during installation
UUID=c00e34f9-a66d-4686-8304-b0da2a7ffb14 /              ext4    errors=remount-ro 0      1
# /home was on /dev/sda3 during installation
UUID=69c1ff4e-ac61-41a5-9c31-c51ff0650dad /home          ext4    defaults        0      2
# swap was on /dev/sda2 during installation
UUID=ffb4980e-a4a2-48fc-8e33-da4b5f9b9138 none            swap    sw              0      0
LABEL=Tosh /mnt/Avi ext4 defaults 0 0
LABEL=TV /mnt/TV ext4 defaults 0 0

I let it install ignoring all additional drives then after install I make the mount points and load them in fstab.
These are on my "server" and then mounted to /exports for nfs shares. (I use /exports as an easy point to mount from)
This pc only has one drive so no extra mounts other than /home on a different partition.
VileReynard
Seasoned Pro
Posts: 10,651
Thanks: 206
Fixes: 9
Registered: 01-09-2007

Re: Linux disk hardware question.

Because I've done about 6 years of upgrade installs of several distros, my /etc (etc!) could maybe do with a clean up.
So I've decided to do a totally fresh install - which solves my GRUB problem.
I shall have to read up about that LABEL idea.
However, many utilities still use the /dev/sdxy notation e.g. (different PC)  Cheesy
Quote
jeremy@NETBOOK ~ $ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda5        20G  7.7G  11G  43% /
udev            1.8G  4.0K  1.8G  1% /dev
tmpfs          369M  1.1M  367M  1% /run
none            5.0M    0  5.0M  0% /run/lock
none            1.8G  684K  1.8G  1% /run/shm
/dev/sda7      366G  5.3G  342G  2% /home

Community Veteran
Posts: 6,611
Thanks: 209
Fixes: 15
Registered: 16-02-2009

Re: Linux disk hardware question.

There is nowt to stop you using the /dev/sd[a-z] for any util, the label doesn't by pass this just augments it.
E.g. in the case above TV is /dev/sdc1 etc.
But to answer you original Q, it is normally the first discovered disk is a then b etc. So plugging the new drive into the old a slot will make it the default to install to. Just watch your bios isn't clever and swaps the boot order about.
To use label when you partition it using gparted give the disk/partition a label, you can then use LABEL= in fstab, great for home etc.
VileReynard
Seasoned Pro
Posts: 10,651
Thanks: 206
Fixes: 9
Registered: 01-09-2007

Re: Linux disk hardware question.

OK

CX
Grafter
Posts: 745
Thanks: 2
Registered: 16-09-2010

Re: Linux disk hardware question.

The only other thing to watch out for is if your boot and/or root parition change by adding a new disk, AND, your grub config references by sdx. I ran into this on a Ubuntu system at the weekend. It's easy enough to fix by manually editing the grub command line at bootup, and then running update-grub once to put it right (at which point, interestingly, it used UUIDs as I would have expected).
I mount everything by fstab, but all partitions have a label. There are a number of benefits to assigning labels - firstly (in Ubuntu at least), removable USB disks mount automatically in /media/<label> when connected without needing to manually mount or put details in fstab. You always know where they will be mounted, by a logical human-readable (or not, if you so wish) name. I also use labels in some scripts for obtaining /dev/sdx in a multiple disk system to pass to hdparm or smartctl.
VileReynard
Seasoned Pro
Posts: 10,651
Thanks: 206
Fixes: 9
Registered: 01-09-2007

Re: Linux disk hardware question.

My present GRUB config actually uses UUID's
I'm not planning on using different partition numbers for / and /home so hopefully GRUB will be OK on the reinstall.
Currently USB sticks automount as USB1, USB2 etc
I've been playing with LVM in a small way, which effectively uses labels to reference volumes (filesystems).
I've got an external disk with 20 volumes on it and any attempt to mount a volume manually is rather fraught.
I have to use a script to reliably access the right volume.
So I will standardise most of my fstab with UUID's (+ comment lines). Cheesy
I hope to try all this in the next few days when my spare SATA cable arrives...