15

I accidentally removed all the entries from the fstab files while doing a backup (Yeah, I know ;)).

I would like to know if there is a way to rebuild it with the current mount options, since I did not restart the server since the deletion. If there is no such program, could anybody help me rebuild it.

Using this, I have found the command to show the current setup, but I don't know what to do with it.

$ sudo blkid
/dev/sda1: UUID="3fc55e0f-a9b3-4229-9e76-ca95b4825a40" TYPE="ext4" 
/dev/sda5: UUID="718e611d-b8a3-4f02-a0cc-b3025d8db54d" TYPE="swap" 
/dev/sdb1: LABEL="Files_Server_Int" UUID="02fc2eda-d9fb-47fb-9e60-5fe3073e5b55" TYPE="ext4" 
/dev/sdc1: UUID="41e60bc2-2c9c-4104-9649-6b513919df4a" TYPE="ext4" 
/dev/sdd1: LABEL="Expansion Drive" UUID="782042B920427E5E" TYPE="ntfs" 


$ cat /etc/mtab
/dev/sda1 / ext4 rw,errors=remount-ro 0 0
proc /proc proc rw,noexec,nosuid,nodev 0 0
none /sys sysfs rw,noexec,nosuid,nodev 0 0
none /sys/fs/fuse/connections fusectl rw 0 0
none /sys/kernel/debug debugfs rw 0 0
none /sys/kernel/security securityfs rw 0 0
none /dev devtmpfs rw,mode=0755 0 0
none /dev/pts devpts rw,noexec,nosuid,gid=5,mode=0620 0 0
none /dev/shm tmpfs rw,nosuid,nodev 0 0
none /var/run tmpfs rw,nosuid,mode=0755 0 0
none /var/lock tmpfs rw,noexec,nosuid,nodev 0 0
none /lib/init/rw tmpfs rw,nosuid,mode=0755 0 0
none /var/lib/ureadahead/debugfs debugfs rw,relatime 0 0
/dev/sdc1 /home ext4 rw 0 0
/dev/sdb1 /media/Files_Server ext4 rw 0 0
binfmt_misc /proc/sys/fs/binfmt_misc binfmt_misc rw,noexec,nosuid,nodev 0 0
/dev/sdd1 /media/Expansion\040Drive fuseblk rw,nosuid,nodev,allow_other,blksize=4096,default_permissions 0 0
gvfs-fuse-daemon /home/yvoyer/.gvfs fuse.gvfs-fuse-daemon rw,nosuid,nodev,user=yvoyer 0 0
/dev/sdd1 /media/Backup500 fuseblk rw,nosuid,nodev,sync,allow_other,blksize=4096,default_permissions 0 0
/dev/sr0 /media/DIR-615 iso9660 ro,nosuid,nodev,uhelper=udisks,uid=1000,gid=1000,iocharset=utf8,mode=0400,dmode=0500 0 0
gvfs-fuse-daemon /home/cdrapeau/.gvfs fuse.gvfs-fuse-daemon rw,nosuid,nodev,user=cdrapeau 0 0

4 Answers 4

16

Well, I don't know of an automated way to restore it, but from your paste, created by hand..

# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc /proc proc nodev,noexec,nosuid 0  0
UUID=3fc55e0f-a9b3-4229-9e76-ca95b4825a40 / ext4 errors=remount-ro 0 1
UUID=718e611d-b8a3-4f02-a0cc-b3025d8db54d none swap sw 0 0 
UUID=41e60bc2-2c9c-4104-9649-6b513919df4a /home ext4 defaults 0 0
UUID=02fc2eda-d9fb-47fb-9e60-5fe3073e5b55 /media/Files_Server ext4 defaults 0 0

Please wait for a couple of other people review and approve this before you blindly copy and reboot with it, a second set of eyes is always good ;)

I've left out sdd and sr0 as they look like they're done by gvfs.

4
  • Thanks, but you didn't specify anything about cd-rom "/media/cdrom/", is it normal?
    – yvoyer
    Nov 22, 2011 at 16:09
  • Sorry, should have said, I'll edit my answer. Yes I left that out intentionally too, as it's also handled by gvfs, automatically mounted when you insert a disc.
    – Caesium
    Nov 22, 2011 at 16:13
  • Is it better to restart or to run mount -a. With the mount -a option, could it break everything, or will it gives me warnings? Thanks very much.
    – yvoyer
    Nov 22, 2011 at 16:26
  • 1
    mount -a will do precisely nothing if the lines in fstab are already mounted. You should see exactly zero output. So yes, I think you can safely try that. If you do get any messages it indicates an fstab line might be wrong. It is very unlikely to break anything though.
    – Caesium
    Nov 22, 2011 at 16:28
10

Disks GUI program controls fstab. You can go there and put your partitions mount options on automatic by switching it off and on again. I think it will rebuild your fstab to the default mode.

2
  • 2
    The OP was waiting on answer to reboot his server almost 5 years ago.... Jul 9, 2016 at 18:00
  • 27
    @OrganicMarble if the asker was the only person the answers were here for, the accept button could just be a delete post button.
    – Olathe
    Jul 9, 2016 at 18:14
3
blkid | grep /dev/sd | sed -e 's/:.* UUID/;UUID/' -e 's/ TYPE.*//' | while read re; do sed -i "s;$re;" /etc/fstab; done

This ^ cmd works for me quite well.

1
  • 3
    This gives me `s' command at char 12 and 102
    – Sudhanshu
    Feb 4, 2020 at 9:49
0

Using the Disks program (as suggested by Dead) worked for me. After selecting the partition I wanted to add to fstab, I used "Edit Mount Options..." and then selected "Mount on startup".

You must log in to answer this question.

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