4

I destroyed by mistype the fstab file in an ubuntu 12.04 server.

Does anybody know, how can I restore it with the correct values?

3
  • 2
    You can copy relevant entries from /etc/mtab
    – muru
    Aug 26, 2014 at 21:00
  • 1
    possible duplicate of How to rebuild fstab automatically
    – user68186
    Aug 26, 2014 at 21:03
  • when I execute blkid i get nothing. When I execute cat /etc/mtab I get /dev/vzfs / reiserfs rw,usrquota,grpquota 0 0. Can you help me to build the fstab? I have not idea how to do it. Aug 26, 2014 at 21:09

1 Answer 1

6

By default Ubuntu uses uuid in your fstab when you install.

To show a created partitions, in a terminal, as user, type the following command:

 ls -l /dev/disk/by-uuid

It will output like this:

lrwxrwxrwx 1 root root 10 2007-05-27 23:42 348ea9e6-7879-4332-8d7a-915507574a80 -> ../../sda1
lrwxrwxrwx 1 root root 10 2007-05-27 23:42 610aaaeb-a65e-4269-9714-b26a1388a106 -> ../../sda2
lrwxrwxrwx 1 root root 10 2007-05-27 23:42 857c5e63-c9be-4080-b4c2-72d606435051 -> ../../sda5
lrwxrwxrwx 1 root root 10 2007-05-27 23:42 a83b8ede-a9df-4df6-bfc7-02b8b7a5f1f2 -> ../../sda6
lrwxrwxrwx 1 root root 10 2007-05-27 23:42 ad662d33-6934-459c-a128-bdf0393e0f44 -> ../../sda7

The next step is to enter the UUID partition to /etc/fstab.

During the boot process, file systems listed in /etc/fstab are automatically mounted except for the entries containing noauto. This file contains entries in the following format:

device /mount-point fstype options dumpfreq passno

device

An existing device name, by default Ubuntu uses uuid 

mount-point

An existing directory on which to mount the file system.

fstype

The file system type to pass to mount. The default Ubuntu file system is ext4.

options

Either rw for read-write file systems, or ro for read-only file systems, followed by any other options that may be needed. A common option is noauto for file systems not normally mounted during the boot sequence. 

dumpfreq

Used by dump to determine which file systems require dumping. If the field is missing, a value of zero is assumed.

passno

Determines the order in which file systems should be checked. File systems that should be skipped should have their passno set to zero. The root file system needs to be checked before everything else and should have its passno set to one. The other file systems should be set to values greater than one. If more than one file system has the same passno, fsck will attempt to check file systems in parallel if possible.

To add it to your fstab file use a text editor with root privileges:

sudo -i
nano /etc/fstab

Example:

# <device file system>                         <mount point>    <type>  <options>       <dump> <pass>
UUID=ad662d33-6934-459c-a128-bdf0393e0f44            /             ext4      defaults              1      1

UUID=30ebb8eb-8f22-460c-b8dd-59140274829d            /home         ext4      defaults              1      1

UUID=7014f66f-6cdf-4fe1-83da-9cab7b6fab1a            swap          swap      defaults              0      0

Control + O, save file

Control +X, close nano

Upon a reboot of the computer the filesystems will be mounted automatically.

It is not necessary to list /proc and /sys in the fstab unless some special options are needed. The boot system will always mount them.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .