FSTAB - Editing Manually

FSTAB and all That?!

The purpose of this documentation is just to provide a little insight into manually editing /etc/fstab. It is not a comprehensive document and it is intend to address the issue with the help of screenshots/pictures. Fstab requires you have root privileges to edit it. CAUTION – NOT TO BE UNDERTAKEN LIGHTLY. ** Editing is possible by opening a terminal and doing:
In KDE: kdesu kwrite /etc/fstab
In Gnome: gnomesu gedit /etc/fstab**
You can also use super user file managers as available with kde. And the yast partitioner also can be used.

/etc/fstab is the location of a config file which controls mount information for drives/partitions and is used as your system boots. Your Linux file system (swap, / and /home) will automatically be added in here during installation and it’s unlikely you will need to alter the defaults used there. However, it’s possible you may need to edit this file to either add partitions not already included from the initial installation OR to edit the detail of a particular entry. In this document we will look at.

  1. An existing entry for a Vista partition.
  2. The Mount Point
  3. Commenting Out
  4. Manually adding an entry

1. Here is an example of a typical fstab file:
ImageBam - Fast, Free Image Hosting and Photo Sharing
It shows a highlighted entry of a Vista partition added during installation but it has been modified for read/write access. Originally it would have looked a little like the entry above it but now it is simplified with “defaults 0 0”. We’ll cover that later.
Notice the mount point ( /Vista ).
The line above shows ( /STORE ). ImageBam - Fast, Free Image Hosting and Photo Sharing Both these entries were created during installation by setting the mount points of the partitions in the Custom Partitioner.

2. A mount Point as mentioned in point 1 is a folder in the Linux Installation file system tree. Here is a screen of a typical tree. I have highlighted the two points we have refered to already /Vista and /STORE
http://thumbnails8.imagebam.com/3389/b1bc3d33885464.gif](http://www.imagebam.com/image/b1bc3d33885464/)
Therefore, if you fail to add/mount a partition, such as a windows installation, during the initial installation of Linux, you will need to manually add an entry to fstab – But you must provide a mount point. If I hadn’t added Vista during installation, no folder of that name would exist and if I wanted to mount the Vista partition to that location, I would have to create the folder /Vista first.

3. A mention of ‘Commenting Out’. The process of placing a # at the start of a configuration line. Is considered a better practice than say deleting the entire line, as commenting out preserves the text for future reference but disables the configuration line. Here is an example:
ImageBam - Fast, Free Image Hosting and Photo Sharing
After reboot, with these lines commented out, the partitions Vista and STORE would no longer be available.

4. Manually adding an entry to fstab. Let’s say we fail to set this up during installation, how can we do it later? Well first you need the ‘Mount Point’. You can create this. In my examples the folders Vista and STORE are directly on /
( A note However, even if you fail to set up mount points for partitions, usually the installer will automatically pick up other partitions such as XP or Vista and add an entry in fstab but use a mount point like: /media/windows_c – In this case, all that would be required is to edit the entry in fstab to give ‘read’ or ‘read/write’ permissions)
If nothing exists just create a folder with the name you require in whatever location you desire. You may need to do this with root permissions.
Let’s assume though that nothing exists. How do you know what to add? Well let’s find the Vista partition in my installation. We need to open a terminal, type su and then the root password to have root privileges. And then type: fdisk -l
http://thumbnails13.imagebam.com/3389/7a3be833886521.gif](http://www.imagebam.com/image/7a3be833886521/)

Here you see the output. I highlighted the first line sda1 which is the Vista installation. Now to add that to fstab.
http://thumbnails19.imagebam.com/3389/fde7ab33886684.gif](http://www.imagebam.com/image/fde7ab33886684/)
This assumes we had no entry for Vista and are adding it from the fdisk output. Notice the method of using /dev/sda1

You can find more information here: HowTo Mount NTFS Filesystem Partition Read Write Access in openSUSE 10, 11
@swerdna provides a valuable source of information not just on this subject but whole range of topics. You can go to his homepage from the link above.

  • You should exercise extreme caution when giving access to NTFS partitions of windows installations. The best policy is to only provide ‘read’ access and NOT ‘write’. My example using ‘defaults 0 0’ gives read/write access.

Lastly – You must leave an empty line at the end of fstab:
ImageBam - Fast, Free Image Hosting and Photo Sharing

Other sources of information:
NTFS - openSUSE

Access Your Windows Files - openSUSE

This is a very comprehensive tutorial that I think many will find as an easy step-by-step solution to a lot of problems. Also the links you provide contain a lot of useful information as well.

Excellent work!

I have a question though. What’s the significance of leaving an empty line at the end of fstab?

Ian

I have a question though. What’s the significance of leaving an empty line at the end of fstab?

Hopefully someone more knowledgeable than me will be able to answer that.

AFAIK it is to indicate that there are no more entries.
Found a good fstab guide here How to edit and understand /etc/fstab

Geoff

I think this protection against broken editors (both software and human) not ending the last line with the newline character and that line getting ignored by the utilities: typical message when editing with vim, no EOL at end. By putting in a blank line, it doesn’t matter if the last line is not terminated by newline.

I manage five systems here. None of them has an empty line at the end of /etc/fstab. Some of them were generated at installation, some of them were changed by YaST later, some of them edited using vi. When even installation does not add an empty line I think there is no reason whatsoever to promote this behaviour as a sort of black magic

As ken_yap posts, the only reason may be that there is no CR at the end of the last characters. But you do not add a new line then, you just add the CR (and may be two, which will give you an empty line).

In any case, when this phenomenon of not having a CR at the end of a text file would happen often, much more tools would be affected by this.

I multiboot (x6) and have had errors/warnings in the past caused by missing the blank line. Maybe it’s no longer an issue, but until the distros say that, I take the precaution of leaving one there after any edit. Better safe than sorry, for newbies anyway.

I’ve never had to insert blank lines at the end of fstab but then I use an editor that terminates all lines. I believe it is possible in an editor like emacs to leave out the final newline because emacs just treats the file as a bunch of bytes. Maybe nano too. So there is a bit of cargo-cult mentality here, but the alternative is to educate all users which might be a bigger job than stating a rule that works. Then again, after a while the original reason for the rule is forgotten.

Bit like the story about the family that always prepared a certain food by folding it over before baking. When the mother was asked, she said, it must be our people’s tradition, I’ve always seen grandma do it that way. When grandma was asked she said, oh it’s just because I didn’t have a baking tray large enough when I first made this dish so I folded it.

So fstab actually stands for “fold sides to assist baking”. The things you learn in this forum…lol!

I’d better not tell you stories about SuSE then. :slight_smile:

My grasp of the german language isn’t that good, and my brain is pleasantly full after consuming your baking:).

Brilliant :stuck_out_tongue: