LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   /etc/fstab file (https://www.linuxquestions.org/questions/linux-newbie-8/etc-fstab-file-4175495673/)

ostene 02-20-2014 12:24 PM

/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

TobiSGD 02-20-2014 12:42 PM

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, ...).

jpollard 02-20-2014 12:50 PM

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.

jpollard 02-20-2014 01:08 PM

Quote:

Originally Posted by TobiSGD (Post 5121773)
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.

TobiSGD 02-20-2014 01:38 PM

Quote:

Originally Posted by jpollard (Post 5121782)
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.


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