LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices


Reply
  Search this Thread
Old 09-20-2011, 05:40 AM   #1
dineshdhiman
LQ Newbie
 
Registered: Sep 2011
Posts: 3

Rep: Reputation: Disabled
Thumbs up how recover /etc/fstab


hi friends
plz help me
I am using rhel6....
i have accidentlly deleted my fstab file.
help me to recover it.....if any one have the solution please post it.
 
Old 09-20-2011, 06:29 AM   #2
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,529

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
Did you rebooted the system, or is it still running?
Do you have a backup?

Kind regards
 
Old 09-20-2011, 06:38 AM   #3
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
If it's still alive (not rebooted) then maybe something like 'egrep -v "(rootfs|/dev/root|sysfs|selinuxfs|usbfs|binfmt_misc)" /proc/mounts > /etc/fstab' could be a start?
 
1 members found this post helpful.
Old 09-20-2011, 07:24 AM   #4
dineshdhiman
LQ Newbie
 
Registered: Sep 2011
Posts: 3

Original Poster
Rep: Reputation: Disabled
sir i reboot my system and i try to recover but i cant plz help me
 
Old 09-20-2011, 07:26 AM   #5
dineshdhiman
LQ Newbie
 
Registered: Sep 2011
Posts: 3

Original Poster
Rep: Reputation: Disabled
and i have no backup of fstab
 
Old 09-20-2011, 08:58 AM   #6
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,636

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by dineshdhiman View Post
sir i reboot my system and i try to recover but i cant plz help me

and i have no backup of fstab
Well, your only chance would be to try to manually mount the partitions one at a time (go into fdisk, and print the partition table, to get an idea of what partitions may be which devices). From there, you can try to create an fstab manually.

Otherwise, you've now learned the importance of having backups, and you may have to reload/reinstall your OS. If you made a separate partition of your /home, you don't have to format that at build time, so you can save that data.
 
Old 09-20-2011, 09:22 AM   #7
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
...in addition fdisk shows devices but not partition labels (as in 'disktype '/dev/devicename' or 'ls -l /dev/disk/by-label'). On simple disks, using something like
Code:
for DISK in /dev/{h,s}d[a-z]; do
 fdisk -l $DISK|awk '/Linux$/ {print $1}'|while read PART; do
  LABEL=$(tune2fs -l $PART|awk -F':' '/Filesystem volume name:/ {print $2}')
  echo "${PART} ${LABEL// /} ext2 defaults 0 0"; done; done
may show Linux (0x83) partitions and their labels, *if* you gave them usable names. You probably also want to add the
Code:
tmpfs      /dev/shm tmpfs  mode=1777 0 0
devpts     /dev/pts devpts gid=5,mode=620 0 0
sysfs      /sys     sysfs  defaults 0 0
proc       /proc    proc   defaults 0 0
entries to /etc/fstab.

* And apart from the valuable lesson wrt having backups you've also learned that next time you mess around you do it as unprivileged user and not root.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
trying to recover deleted /etc/fstab miteshpant Linux - Newbie 33 09-25-2010 12:15 AM
How to recover fstab sunny_rhce Linux - Enterprise 2 03-10-2007 01:13 AM
Recover FSTAB bisht_mohit Linux - Desktop 1 02-04-2007 12:49 AM
Knoppix to recover fstab? kurtwisener Linux - Software 2 06-12-2005 12:42 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat

All times are GMT -5. The time now is 10:08 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration