Sunday, October 14, 2012

How to edit fstab with terminal?


What if you are all experienced users, who create partitions on their HDD separately for the system, which you are using at the moment, and another for the personal data you have like music, pics, movies, etc. I think all of you know, what will be this spot about after such an in medias res beginning, right? Yes, it will be about how to mount those partitions on your Linux system, which are not using Unix file systems, like NTFS partitions.
Using NTFS partitions can be useful as if you decide to use Windows for some time instead of Penguin, so your system will easily manage your personal stuff. However, if you would use EXT or BTRFS file systems, your Windows OS would rather jump out the window instead of managing such things.
After you have installed your brand new super cool Linux system (openSUSE, Ubuntu, Fedora, whatever...) take your time ensure yourself: it is beautiful, omg! Now it is time to mount the other NTFS partitions in your file manager (Dolphin, Nautilus, Thunar, etc.) with the music, pics, and movies you have, and of course all are totally legal contents, what else, right? So this is okay, now you can copy from and there, create files and folders, whatever you wish to do, but ask yourself the question: should I have to do this every time I login? Manually all the time? What if my Linux system is so smart, it can do it automatically, without my help after each login? Let me tell you: it is that smart. Just tell it the following.
Before you begin to initiate any terminal in your system I have to admit something. There are a lot of open source software available in the repos, which can take root privileges - as we need root privileges granted to ourselves to do the things we are preparing at the moment - and do the stuff via GUI and without your better understanding. However, I don’t like them and I don’t recommend to use them, why? The answer is simpler, than you might think: if you learn how to do such thing manually in the terminal, you can develop yourself from a beginner Linux user to an experienced one, which can be good in the mornings, when you see yourself in the mirror. In the other hand such software can fuck up your whole system in one blink, so use them at your own risk, but now I will tell you how to do it with terminal.
So we better start it. First of all, please make sure that no NTFS partitions are mounted to your system. The question comes up, how your Linux defines your drives, because we need to know their names in order to tell you Linux, which to mount. If you’re interested go this place:
/dev/disk/

/dev/disk/ folder
Here you can find plenty of folders around but all for the same purpose, to define your drives but in different ways: by identification number (ID), given name (Label), place (path), and last but not least unique identifier (uuid). You will need the ID to have all the information needed, but do not begin to CC&CV, because the necessary information is already at the proper place, so please be patient.
The next step will be to create the folder you will use to mount your partition into it. There are a lot of places to put your folder, for me the default place of the folder /media. No advantages or disadvantages, you can create a folder even in your /home folder, just remember, where have you put it. So if you would like to create something out of your home folder, then open terminal graphically or by hitting ALT+F2 and type there terminal. In order to create anything outside your /home you need to have root privileges:
sudo mkdir /media/your folder/
After typing there your root password the new folder will appear at the defined place. If you see that the cursor jumped into the folder you can be sure that everything is set ready. So let’s proceed because you are almost there. The Linux systems are using fstab to record the mounted systems, which is similar to GRUB, but it is much easier to edit fstab. Of course you will need root privileges again, otherwise your changes won’t be saved. Open terminal as stated above and type in:
sudo kwrite /etc/fstab
After you’ve put there your password, kwrite will open fstab in root editor mode, which allowes you to save. If you are using GNOME window manager type there gedit instead of kwrite. However, this is the reason, why you have to be cautious. Follow my instructions and everything will be fine. This is how fstab will look like:

fstab
Your purpose can be clearly seen now, you have an NTFS partition to put at the third place:
1. At the beginning of the line proc hit an enter, in order to have a new, totally empty line. Then copy the ID from the beginning of the second line, cause we need it properly set and it is better to copy something correct instead of typing everything again. At the end of the long ID replace “2” with “3”, as this is the third partition.
2. In this step you will type the path of your previously prepared folder. So type it, similar to the above line. The file is totally syntax sensitive, which means, whatever you type somewhere, the file will recognize, what it is.
3. Now you will have to tell Linux, what to do with the partition you want to mount. In this case you will need ntfs-3g, which mounts an NTFS partition with write privileges. Without this command, your partition won’t be editable.
4. Let’s set the different parameters, which tells Linux, what kind of data are available on the mounted drive. No need to define anything special, if someone is interested, let me know, and I will provide some support. For simple English named files (ANSI coding) you better put there defaults. I had to put there locale=en_US.UTF-8, cause I’m Hungarian and we have a lot of accents on our letters.
5. And the last setting is here. Just put at the end 0_0, where _ is a space. This parameter is set by Linux developers, no need to get into details, but if you need any more information, let me know and I will willingly help you out.
6. Whether it is unbelievable or not, but you are done. Save the file (CTRL+S or click „save”) and quit.
7. Reboot! :)

This is it, how to make Linux automatically boot with an NTFS partition mounted at your service. Quite simple, isn’t it? As I mentioned before, let me know if you need help and I will help you out.

Have a nice day!


No comments:

Post a Comment