Need to Repair Fstab
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. Thanks in advance. |
@ Reply
Well I am not aware of any tool that can automatically fix your /etc/fstab file. However, I would suggest you to mount the device using UUID instead.
You can find the UUID of a particular partition using the following command: Code:
blkid /dev/sdaX You can put this UUID in /etc/fstab as follows: Code:
UUID="b6759bda-d6d7-4e1c-b184-d3b9ed29a641" / ext3 defaults 1 1 |
Okay, thanks. I'll give that a try.
|
Something I forgot to ask...
both hard drives on my machine are ext4, should I make one of them ext3 as in your example? |
@ Reply
Nope, that was just an example use ext4 instead.
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. |
Okay, here's the original file:
Quote:
Quote:
|
@ Reply
Wait. I can see that your orginal file uses UUID format then what was the issue?
In your new file I do not see quotes at both end. Either do not use them or use them at both ends: New file: Quote:
/proc is virtual file system that linux uses to manage file system and various processes. Leave it as it is. Please do not reboot your system unless you are sure that /etc/fstab is 100% correct as it might result in system not booting up at all. Make sure that you backup your existing /etc/fstab file. |
I can remove the quotes- that's no problem. And I can add the following swap:
Quote:
|
@ Reply
Do you mount the partitions on your second hard drive manually? If not, then it should be there in /etc/fstab.
Please paste the output of the following commands: 1. Code:
df -h Code:
fdisk -l Code:
ls -l /dev/ | grep sd |
I can manually mount the 2nd hard drive, but I can't get it to boot up.
1. Code:
Filesystem Size Used Avail Use% Mounted on 2. Code:
Disk /dev/sdb: 120.1 GB, 120060444672 bytes Code:
lrwxrwxrwx 1 root root 4 2011-10-11 14:10 root -> sda1 |
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:
# |
Maybe I should explain what I'm trying to do here so you guys can better help me.
I have two hard drives. My primary is Ubuntu. My secondary drive is slackware. When I boot up, I get a grub splash screen. Slackware is one of the options, but if I select it, it won't boot up. I get error messages. That's the short and sweet of it. |
@ Reply
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 3. Add the following line to your /etc/fstab: Code:
UUID= /mount_point file_system defaults 0 0 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. I hope this helps. |
Sounds good. Let me try this out and see what happens.
|
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:
|
All times are GMT -5. The time now is 05:11 PM. |