Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm in a time crunch. I did something stupid. I overwrote my /etc/fstab. Is there a way to rebuild fstab from files in /proc or /sys or /dev? Until I reboot, I'm fine, of course.
I generally use Slackware, but this is specifically Linux Mint, which in my experience uses UUID instead of /dev/sdX notation.
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233
Rep:
UUID notation is optional, however you can get currently mounted volumes by use of the 'mount' command (mount with NO arguments)
then you can re-build the fstab by hand, not sure how to obtain the uuid from a device node, you can, but device node (/dev/HDX or /dev/SDX etc... will still work)
Today I'm a poster child for "Dumb Mistakes 101." For want of a single character--and adequate time to perform the task at hand--I have done something which has cost me time instead.
Quote:
Originally Posted by zedmelon
I'm in a time crunch. I did something stupid. I overwrote my /etc/fstab.
Again, for the newbies reading this and the experienced guys ready to tell me I've made a foolish oversight, yes:
I should have made a backup.
I should have double-checked the command I executed as root.
I blithely and complacently edited a critical system file.
Ugh.
----------------------------------------
In case anyone's curious, I wrote a shell script to mass-duplicate 1500 USB thumb sticks from a single master (naturally this needs to be done last week, even though I only got the sticks yesterday). Initial testing has gone well, and I'm now writing a wrapper script to automatically copy to each new stick as it's connected. I'm using a predefined array of directories for mounting and executed this command to add them to my fstab, omitting one single character (line breaks are mine, to prevent line-wrappage on this forum page:
Code:
# [14.40.37] ROOT@mintlap [~] 5 for i in b c d e f g h i j k l m n o p q r s t u v w x y z;
do echo "/dev/sdZ1 /files/stickcp/Z auto noauto,user,rw 0 0" | sed "s/Z/$i/g" > /etc/fstab;
done
...needless to say, it *nearly* gave me what I wanted. My fstab should look like this:
Code:
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc nodev,noexec,nosuid 0 0
# / was on /dev/sda8 during installation
UUID=17f434e1-eead-4684-b291-17931f5dbfc5 / ext4 errors=remount-ro 0 1
# /files was on /dev/sda13 during installation
UUID=0fdc1742-1e36-4207-b13f-80ce10ca33d5 /files ext4 defaults 0 2
# /home was on /dev/sda12 during installation
UUID=8f34b43d-5910-4d4f-96e9-aca2a2a2b816 /home ext4 defaults 0 2
# /usr was on /dev/sda9 during installation
UUID=2fe320c9-7d03-4f3f-8d25-c13d2fd5767a /usr ext4 defaults 0 2
# /usr/local was on /dev/sda10 during installation
UUID=eea3302f-7f7a-420f-b77b-e67a90ad5333 /usr/local ext4 defaults 0 2
# /var was on /dev/sda11 during installation
UUID=c055187e-6f46-4a4e-9cce-9c28ff57faec /var ext4 defaults 0 2
# swap was on /dev/sda14 during installation
UUID=8cc15220-5c35-4190-8988-f1a71cd49149 none swap sw 0 0
# from the slackware side:
# /dev/sda8 /os/mint ext4 defaults 1 2
# /dev/sda2 /os/winxp ntfs-3g fmask=133,dmask=022 1 0
# /dev/cdrom /mnt/cdrom auto noauto,owner,ro,comment=x-gvfs-show 0 0
# /dev/fd0 /mnt/floppy auto noauto,owner 0 0
#
# my phone:
UUID=1ADD-921F /files/android vfat noauto,user,exec,noatime,rw 0 0
/dev/sdc1 /files/stickcp/c auto noauto,user,rw 0 0
/dev/sdd1 /files/stickcp/d auto noauto,user,rw 0 0
...
/dev/sdz1 /files/stickcp/z auto noauto,user,rw 0 0
...but instead this is now my entire fstab:
Code:
/dev/sdz1 /files/stickcp/z auto noauto,user,rw 0 0
Ugh.
If anyone has a quick-n-dirty rebuild method, I'd love to hear it. I'll buy you a Sam Adams or a Guinness.
Last edited by zedmelon; 05-24-2013 at 04:22 PM.
Reason: typo
THanks. I guess I was just worried I wasn't going to get enough options to properly rebuild the file. But I suppose the lines output by 'mount' only bother showing options if they're not simply the default.
Quote:
Originally Posted by frieza
not sure how to obtain the uuid from a device node
add your system volumes by hand to fstab than do something like this
Yeah, I'm not really sure why I used sed. Like I said, it's a crazy day. And I missed a greater-than symbol and wasted half an hour between at least three people.
I forgot to do the swap - "swapon" will give you what you need to add.
As mentioned, UUID is optional - and doesn't always help. There are other options see under "/dev/disk".
been using linux since before UUID even was a thing
Yeah, me too. Love the sig, BTW. There are days it feels my guitar is tuned by Bill Gates. Evidently today, my brain is as well. Append file, overwrite file, it's all the same...
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233
Rep:
Quote:
Originally Posted by zedmelon
Yeah, me too. Love the sig, BTW. There are days it feels my guitar is tuned by Bill Gates. Evidently today, my brain is as well. Append file, overwrite file, it's all the same...
why thanks ^^ hehe
i'll tell ya, when i first started learning how to use linux.. well, let's just say i was an absolute EXPERT on reinstalling linux.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.