Sign in with
Sign up | Sign in
Your question
Solved

Meaning of <file system> when using fstab

Tags:
  • mount
  • fstab
  • Boot
  • Hard Drives
  • Ubuntu
  • Linux
  • File System
  • Tutorial
Last response: in Linux/Free BSD
Share
March 4, 2014 4:54:33 AM

Hi there,

I'm trying to automatically mount a disk at boot, using fstab. But for every tutorial I find, they seem to use a new string in the first column, which is the <file system> column (as far as I can figure out).
One that seems to work would be /dev/sda1 (for example), but here comes the next problem. Because commands like fdisk, lshw -class disk and fs, all gives different indications of the /dev/[hdname], so how do I know which to use? I could of course just try to reboot until it works, but at this is a rather critical server, I would prefer to minimize downtime. So I really hope you guys can help. Currently I'm using the following line in fstab:

  1. Data /media/Data ext4 defaults 0 0


Is this even remotely correct? And if not, what should change?

More about : meaning file system fstab

a b 5 Linux
March 4, 2014 7:33:37 AM

In your example the "file system" is ext4

What filesystem was created on "Data"?

If you will not know what file system will be mounted beforehand you can always use "auto" and let mount figure it out. However, mount can guess wrong and fail to mount the volume.

First column = What you want to mount. Could be a UUID, /dev/xxx, or other unique identifier.

Second column = Where you want to mount it. Be aware that what you mount here will overlay anything that may already exist that that point, rendering it inaccessible until you unmount.

Third column = What file system is on the volume being mounted.
m
0
l
a b 5 Linux
March 4, 2014 8:01:48 AM

The easiest way to do it is to put the device name in the first column. This will be /dev/sd??, where the two question marks are replaced with the appropriate letter and number. So the question is, what is the device you are trying to mount. Is it on the only hard disk, the second hard disk, or where? And which partition on that device is it? To help, have a look at what is already mounted; using just the "mount" command will tell you that. And have a look at the available devices; "ls /dev/sd??" will tell you that.

Then make the entry in fstab and test it. You don't need to reboot to do this. The command "mount /media/Data" will do the mount if your entry is correct. If not, try again. But the first step is to understand which device the filesystem resides on.
m
0
l
Related resources
March 4, 2014 8:28:51 AM

Just to clarify...ext4 is correct if that is the file system of the drive you are trying to mount. Other options are ext3, vfat, etc. You can find the filesystem types, the location (dev/sd??), and UUID by typing in terminal:

sudo blkid

Also for the options at the end, for a data drive the recommendation is usually "defaults 0 2". The 2 ensures that it is one of the last drives to mount.

Following exbubble's instructions, the correct entry for /dev/sdb1 formatted as ext4 would be:

/dev/sdb1 /media/Data ext4 defaults 0 2

Note that you will need to create a folder within /media called "Data" prior to reboot.
m
0
l
a b 5 Linux
March 4, 2014 8:39:14 AM

Aristotelian said:
You can find the filesystem types, the location (dev/sd??), and UUID by typing in terminal:

sudo blkid

I think you have a Catch-22 there. "blkid" only lists those details for mounted filesystems. The problem here seems to be in finding the correct details to mount the filesystem in the first place.
m
0
l
March 4, 2014 8:48:55 AM

Ijack said:
Aristotelian said:
You can find the filesystem types, the location (dev/sd??), and UUID by typing in terminal:

sudo blkid

I think you have a Catch-22 there. "blkid" only lists those details for mounted filesystems. The problem here seems to be in finding the correct details to mount the filesystem in the first place.


No, blkid will work. When a drive is unmounted it is still detected by the system and blkid gives you all the essential info to edit fstab. I have used it hundreds of times.

m
0
l
a b 5 Linux
March 4, 2014 10:59:29 AM

Yes blkid directly detects block devices. In particular:
  1. When device is specified, tokens from only this device are displayed.
  2. It is possible to specify multiple device arguments on the command
  3. line. If none is given, all devices which appear in /proc/partitions
  4. are shown, if they are recognized.
m
0
l
March 5, 2014 4:28:57 AM

ex_bubblehead said:
In your example the "file system" is ext4

What filesystem was created on "Data"?

If you will not know what file system will be mounted beforehand you can always use "auto" and let mount figure it out. However, mount can guess wrong and fail to mount the volume.



I thought the first column was called "file system" and was something like the dev/sd?? where the thing you are talking about (as I understand it) is what is called "fs type" in fstab?


Also, I'm pretty sure the correct "fs type" (or whatever it is called) is ext4. The disk has currently been mounted using the GUI, so it is possible to access it. I just need this process automated.

Finally, as mentioned, I have some issues figuring out what /dev/sd?? name the disk has. Different commands, seems to give different answers. Which one would be the correct?
m
0
l
a b 5 Linux
March 5, 2014 4:30:12 AM

Semantics
m
0
l
a b 5 Linux
March 5, 2014 5:04:13 AM

What commands have you used, and what answers do you get? Surely you know which disk, and which partition, contains the filesystem that you want to mount.
m
0
l
a b 5 Linux
March 5, 2014 6:29:29 AM

you can use command "sudo parted -l" to see what disk has been assigned to a specific label /dev/sdX.
unfortunately the assignment is not guaranteed to be the same next time you reboot.
for this reason you should use UUID in your fstab and not /dev/sdX
m
0
l

Best solution

March 5, 2014 6:48:28 AM

You can get both /dev/sd?? label and UUID from sudo blkid. You can use either the /dev/sd?? label or the UUID but UUID is preferred because it will never change (for example, if you switch your cables around). If you use the UUID method, replace /dev/sd?? with UUID=12345678910. So the correct fstab would be:

UUID=1245678910 /media/data ext4 defaults 0 2

Just because the disk is mounting manually does not mean you have the correct file system type. Linux will mount all sorts of file systems. To get fstab correct you need to do sudo blkid to confirm you have the correct file type. If the HDD was pre-formatted it most likely is NOT ext4, because that is a Linux format. The only way it would be ext4 is if you formatted it yourself.
Share
March 18, 2014 12:48:50 AM

Thanks for all the inputs, I think I got it to work. But I wont know for sure until the next server reboot :-)
m
0
l
a b 5 Linux
March 18, 2014 1:51:22 AM

Quote:
But I wont know for sure until the next server reboot :-)

Yes you will. Suppose you have it mounted at /mnt. If the commands

umount /mnt
mount /mnt

work as expected then your fstab entry is correct.
m
0
l
March 18, 2014 2:26:09 AM

Ijack said:
Quote:
But I wont know for sure until the next server reboot :-)

Yes you will. Suppose you have it mounted at /mnt. If the commands

umount /mnt
mount /mnt

work as expected then your fstab entry is correct.


Thanks for the hint, that might ease the testing a bit. However, the drive must be available at all time (as far as possible), so re-mounting is not possible right now.
m
0
l
!