fstab - linux configuration file

15
FSTAB (File System TABle) Hephzibah A FSTAB (File System TABle) (12) file:///home/hephzibah/Downloads/fstab/slides.h... 1 of 15 Tuesday 31 January 2017 10:41 PM

Upload: hephzibah-a

Post on 08-Feb-2017

24 views

Category:

Technology


6 download

TRANSCRIPT

Page 1: fstab - Linux configuration file

FSTAB (File System TABle)

Hephzibah A

FSTAB (File System TABle) (12) file:///home/hephzibah/Downloads/fstab/slides.h...

1 of 15 Tuesday 31 January 2017 10:41 PM

Page 2: fstab - Linux configuration file

What is fstab?

File System TABle (FSTAB).

File System organizes the files in harddisk.

Fstab contains the information of where and how to mount the partitions.

It is a configuration file.

Can edit this file in text editor.

$ whatis fstabfstab (5) - static information about the filesystems

FSTAB (File System TABle) (12) file:///home/hephzibah/Downloads/fstab/slides.h...

2 of 15 Tuesday 31 January 2017 10:41 PM

Page 3: fstab - Linux configuration file

Where is fstab?

Located in /etc/fstab.

$ whereis fstabfstab: /etc/fstab /usr/include/fstab.h /usr/share/man/man5/fstab.5.gz

FSTAB (File System TABle) (12) file:///home/hephzibah/Downloads/fstab/slides.h...

3 of 15 Tuesday 31 January 2017 10:41 PM

Page 4: fstab - Linux configuration file

When is fstab called?

init

In init somewhere mount -a is called which mounts all filesystems in the same order as mentioned infstab.

If /etc/fstab contains the instructions for mounting the file systems, including the root partition, then how doesthe OS read that file in the first place?

The root partition is initially mounted read-only by the kernel.

init process then mounts the file system in the order as in fstab.

/ is again described in fstab to change its mounting option.

FSTAB (File System TABle) (12) file:///home/hephzibah/Downloads/fstab/slides.h...

4 of 15 Tuesday 31 January 2017 10:41 PM

Page 5: fstab - Linux configuration file

fstab

# → comments.

There are six fields.

fs_spec → <file system>.1.

fs_file → <mount point>.2.

fs_vfstype → <type>.3.

fs_mntops → <options>.4.

fs_freq → <dump>.5.

fs_passno → <pass>.6.

FSTAB (File System TABle) (12) file:///home/hephzibah/Downloads/fstab/slides.h...

5 of 15 Tuesday 31 January 2017 10:41 PM

Page 6: fstab - Linux configuration file

1. File system

Describes the filesystem that needs to be mounted.

The file system to be mounted can be specified by its UUID - Universal Unique IDentifier.

Whenever a hard disk is manufactured or formated, a UUID for it is generated which it carries till itsgrave.

block node eg., /dev/sr0/.

FSTAB (File System TABle) (12) file:///home/hephzibah/Downloads/fstab/slides.h...

6 of 15 Tuesday 31 January 2017 10:41 PM

Page 7: fstab - Linux configuration file

2. Mount point

Mount point is the point where the partition is attached to the filesystem.

It describes point for the filesystem to be mounted.

FSTAB (File System TABle) (12) file:///home/hephzibah/Downloads/fstab/slides.h...

7 of 15 Tuesday 31 January 2017 10:41 PM

Page 8: fstab - Linux configuration file

3. Type

Specifies the type of the filesystem.

ext41.

NTFS2.

FAT etc3.

What is swap?

It is a partition in hard disk. Whenever the memory in RAM needs to be freed, process from RAM aretransfered to Swap partition. Process are retrived when it is needed. eg., Hibernation in linux os.

FSTAB (File System TABle) (12) file:///home/hephzibah/Downloads/fstab/slides.h...

8 of 15 Tuesday 31 January 2017 10:41 PM

Page 9: fstab - Linux configuration file

4. Option

File system mount options.

rw → read write only.

exec → Allows the execution of binary files on the particular file system.

nouser → Disallows an ordinary user (that is, other than root) to mount and unmount the file system.

defaults : rw, suid, dev, exec, auto, nouser, and async.

To see various mount and swap options see man page of mount and swapon respectively.

FSTAB (File System TABle) (12) file:///home/hephzibah/Downloads/fstab/slides.h...

9 of 15 Tuesday 31 January 2017 10:41 PM

Page 10: fstab - Linux configuration file

5. Dump

This field is used by the dump command.

1 → dump the Filesystem.

space / 0 (zero) → donot dump the filesystem.

FSTAB (File System TABle) (12) file:///home/hephzibah/Downloads/fstab/slides.h...

10 of 15 Tuesday 31 January 2017 10:41 PM

Page 11: fstab - Linux configuration file

6. Pass

Order in which fsck checks are done.

NOTE : fsck (File System ChecK) checks and repairs filesystem at reboot time.

root must be 1.

other than root must be 2.

If space or 0(zero) is entered fsck assumes that the filesystem need not be checked.

Let’s check out the fstab file!

$ vi /etc/fstab

open /etc/fstab in any text editor.

You could see its various fields.

FSTAB (File System TABle) (12) file:///home/hephzibah/Downloads/fstab/slides.h...

11 of 15 Tuesday 31 January 2017 10:41 PM

Page 12: fstab - Linux configuration file

Step 1

Step 2

Demo

Note: To try this demo you need to be superuser or have the permission to edit the fstab file.

Open the /etc/fstab in text editor

Create a swap partition if it doesnot exist and reboot and goto step2

If it exist goto step2

Goto System Monitor → Resources

You can see swap is available.

FSTAB (File System TABle) (12) file:///home/hephzibah/Downloads/fstab/slides.h...

12 of 15 Tuesday 31 January 2017 10:41 PM

Page 13: fstab - Linux configuration file

Step 3

Step 4

Comment the swap partition related lines in fstab. Reboot.

Goto System Monitor → Resources

You can see swap is not available

FSTAB (File System TABle) (12) file:///home/hephzibah/Downloads/fstab/slides.h...

13 of 15 Tuesday 31 January 2017 10:41 PM

Page 14: fstab - Linux configuration file

Conclusion

This shows that you can manage the partition mounting by fstab.

FSTAB (File System TABle) (12) file:///home/hephzibah/Downloads/fstab/slides.h...

14 of 15 Tuesday 31 January 2017 10:41 PM

Page 15: fstab - Linux configuration file

Further reading..

fstab - man page

fstab introduction and check this out too

When fstab called?

Why UUID in fstab?

Swap partition

Various mount options

FSTAB (File System TABle) (12) file:///home/hephzibah/Downloads/fstab/slides.h...

15 of 15 Tuesday 31 January 2017 10:41 PM