LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-20-2014, 12:24 PM   #1
ostene
Member
 
Registered: Jul 2006
Location: Lidingo, Sweden
Distribution: Kubuntu
Posts: 54

Rep: Reputation: 1
/etc/fstab file


Hello!,

When is the /etc/fstab file with device names
etc. created and which program does that?

When I add a new disk to my system the device names
in that file are changed from ex. /dev/sda to /dev/sdc.

How can I avoid this when adding a new HD to the system?

Thanks
ostene
 
Old 02-20-2014, 12:42 PM   #2
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
The installer of your distribution creates that file. That file is never created on the fly by anything in the system. It may be that your device-names change, but not the fstab. Usually you can avoid problems with changing device names whith using labels or UUIDs instead, bu often all you need is to attach the disks in proper order to the SATA connectors on your mainboard (for example, make sure that /dev/sda is attached to the first port, ...).
 
Old 02-20-2014, 12:50 PM   #3
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
It is a configuration file, usually created during an installation.

After installation, it is maintained by the administrator to add/remove entries for filesystems that are to be included as part of the system.

You can't prevent the changing device names. This is due to the way disks are identified - the order is determined by spin up time... Thus adding a disk will/can cause the names to change (especially if it spins up faster...)

What you can do is not use device names in the /ect/fstab file. Filesystems to mount can be identified in one of three ways:

1) by device name - and as you have found out, this isn't reliable.

2) by partition/filesystem UUID - this is reliable as once a partition is created and has a filesystem on it, it is given a unique UUID. Use the command "blkid" to list all filesystems and their associated UUID (it also lists the current device names).

3) by partition label - this is similar to the UUID but is set by the administrator.

In both #2 and #3 problems occur if you create backups by using disk cloning techniques - this causes the duplicated filesystem to also have the same UUID/label, and that will confuse the system boot. Now if these are on removable media, and that media is removed during boot, then there is no problem.

If you want to set a label, you can use e2label (see manpage) for ext2/3/4 filesystems, or tune2fs (see manpage), also for ext2/3/4.
 
1 members found this post helpful.
Old 02-20-2014, 01:08 PM   #4
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Quote:
Originally Posted by TobiSGD View Post
The installer of your distribution creates that file. That file is never created on the fly by anything in the system. It may be that your device-names change, but not the fstab. Usually you can avoid problems with changing device names whith using labels or UUIDs instead, bu often all you need is to attach the disks in proper order to the SATA connectors on your mainboard (for example, make sure that /dev/sda is attached to the first port, ...).
Doesn't always work... It depends on the spin up time for the disks... If you have two sata controllers and for disks, you can get 8 different names... AB CD (order installed), ACBD, BACD, DABC (D happens to be really fast...).

I currently have 4 disks.. A and B are the same type disk, same manufacturer... But the third is much newer (and happens to be on the second controller), the fourth is really really old (a 40GB drive on PATA it always comes up as either C or D depending on the home disk being installed). I nearly always get ACB order. When I had five, I got ACDBE (the CD disks were both newer than the AB...The PATA disk always comes up last with four newer it came up E) and I have no idea why A is so consistent.

Last edited by jpollard; 02-20-2014 at 01:09 PM.
 
1 members found this post helpful.
Old 02-20-2014, 01:38 PM   #5
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
Quote:
Originally Posted by jpollard View Post
Doesn't always work... It depends on the spin up time for the disks... If you have two sata controllers and for disks, you can get 8 different names... AB CD (order installed), ACBD, BACD, DABC (D happens to be really fast...).

I currently have 4 disks.. A and B are the same type disk, same manufacturer... But the third is much newer (and happens to be on the second controller), the fourth is really really old (a 40GB drive on PATA it always comes up as either C or D depending on the home disk being installed). I nearly always get ACB order. When I had five, I got ACDBE (the CD disks were both newer than the AB...The PATA disk always comes up last with four newer it came up E) and I have no idea why A is so consistent.
For me the names didn't even change when temporary connecting a SSD between two other disks, so it may indeed be up to the hardware in use. Of course the proper way to circumvent that issues is to use labels or UUIDs.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
fstab file sfspartan Linux - Newbie 3 04-01-2008 11:37 AM
use of /etc/fstab file ankurcse Linux - Newbie 6 04-17-2006 10:34 PM
Need Help regarding fstab file thinker1 Linux - Security 1 11-01-2005 09:02 PM
changes to fstab file joanduan Linux - Newbie 3 03-10-2005 01:32 PM
fstab file gmg Linux - Newbie 5 09-03-2003 03:21 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:58 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration