Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's 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.
Hi- is there a command that I can run that will detect devices on my machine and then automatically repair my fstab file?
For some reason hard drive device names on my machine keep switching and it's screwing up my fstab. /dev/sda which was my primary drive is now /dev/sdb and /dev/sdb which was my secondary drive is now /dev/sda.
It is just an example how you have to put entry in fstab. Instead of using /dev/sdax you have to use the UUID of the partition thats it. Rest all will remain the same.
Last edited by T3RM1NVT0R; 10-11-2011 at 02:29 PM.
# /etc/fstab: static file system information.
#
# Use 'blkid -o value -s UUID' to print the universally unique identifier
# for a device; this may be used with UUID= as a more robust way to name
# devices that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc nodev,noexec,nosuid 0 0
# / was on /dev/sda1 during installation
UUID=a97e6722-7e13-4f56-a96f-e46a841a29c6 / ext4 errors=remount-ro 0 1
# swap was on /dev/sda5 during installation
UUID=3ee6628e-c69e-4925-8adf-3c4804acd33b none swap sw 0 0
/dev/fd0 /media/floppy0 auto rw,user,noauto,exec,utf8 0 0
I've never tried using quoted strings in fstab, but I suppose it would work that way.
Here's an example of what you can do with fstab. It's my personal "standard" to create my system device mount points under the root directory with a name that starts with an upper-case letter (so the names won't collide with any of the usual Linux names) by use of a sudo mkdir /Name command.
Code:
#
# /etc/fstab
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=31ae217a-e756-4465-9e52-7f4040dcd2b8 / ext4 defaults 1 1
UUID=65c92b08-9f35-4ba3-8c3e-e3c3f0efaf01 /boot ext4 defaults 1 2
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
UUID=8ECEC31BCEC2FA8B /Win7 ntfs-3g defaults,rw 0 0
# Mirror
UUID=f52a4cdd-befe-4197-82dc-18a34eacf783 /Mirror btrfs defaults 0 0
# USB 120 Gb drive
UUID=004a12e0-a205-4b45-8ca1-2a7ba8e6a73f /Fedora ext4 defaults,noauto 0 0
UUID=5793cd07-fe28-4fae-9069-2ddca8a05420 /Fedora/boot ext3 defaults,noauto 0 0
# USB 500Gb drive
UUID=53eb35a6-dc07-4956-9376-a8ef7d10a9fb /Backup ext4 defaults,noauto 0 0
UUID=ea123517-ebae-495c-afdd-08b3712638ef /Ubuntu ext4 defaults,noauto 0 0
# SMB files (Note: This will cause a boot abort if the network is down.)
//Office/Books /Smb/Books cifs credentials=/.Smb_credentials,rw 0 0
//Office/Documents /Smb/Documents cifs credentials=/.Smb_credentials,rw 0 0
//Office/FEBE /Smb/FEBE cifs credentials=/.Smb_credentials,rw 0 0
//Office/Public /Smb/Public cifs credentials=/.Smb_credentials,rw 0 0
//Office/Sys /Smb/Noaccess cifs uid=0,gid=0,credentials=/.Smb_credentials,rw 0 0
//Office/Users /Smb/Users cifs credentials=/.Smb_credentials,rw 0 0
Alright. As I can see from the output of fdisk -l and ls -l /dev/ | grep sd you have got 2 partitions on your second hard drive. Out of which 1 is swap and other is normal linux paritition. We will talk about swap partition your second drive later which is /dev/sdb2. First we will work on your /dev/sdb1 partition which is linux partition.
This is what you have to do:
1. Find out the UUID of /dev/sdb1 using blkid. Here is the syntax
Code:
blkid /dev/sdb1
2. Choose the directory where you want to mount this partition. Remember, either choose a blank directory or the directory on which you use to mount this partition before otherwise your existing data will become inaccessible.
3. Add the following line to your /etc/fstab:
Code:
UUID= /mount_point file_system defaults 0 0
Where,
UUID= Will be the output of blkid command mentioned in the first step.
/mount_point= Will be the directory location where you want to mount the partition.
file_system= Will be the file system type like ext3 or ext4.
defaults= We will use the defaults option to mount the file system
Paste the output of 1st step and your /etc/fstab file after editing.
Make sure that you take backup of /etc/fstab file before making any changes.
Didn't work. This time I got a different error message. When I select slackware from the grub splash screen it says media not yet present, or something like that. Luckily I was still able to get into ubuntu.
This is my fstab now:
Quote:
# /etc/fstab: static file system information.
#
# Use 'blkid -o value -s UUID' to print the universally unique identifier
# for a device; this may be used with UUID= as a more robust way to name
# devices that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc nodev,noexec,nosuid 0 0
# / was on /dev/sda1 during installation
UUID=a97e6722-7e13-4f56-a96f-e46a841a29c6 / ext4 errors=remount-ro 0 1
# swap was on /dev/sda5 during installation
UUID=3ee6628e-c69e-4925-8adf-3c4804acd33b none swap sw 0 0
# linuxSlack on /dev/sdb1
UUID="54915623-8ff7-4b43-8c41-94485063590f /media/LinuxSlack ext4 defaults 0 0
/dev/fd0 /media/floppy0 auto rw,user,noauto,exec,utf8 0 0
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.