Pages

How To Make NTFS Partitions Read Only in Ubuntu

Sometime ago (back in 2007 I think), when the ntfs-3g project was still young out of enthusiasm I went ahead and let Ubuntu mount it with read and write enabled was the default option back then as with all the recent releases. 

As usual I played in Ubuntu and spent a lot of my time in it rather than Window XP and everything seems to be fine. First I was a bit scared, because there was a possibility, because Microsoft won't issue the full technical details concerning how the NTFS file system works, etc giving their reasons by saying it would create a security "hole"... ha!.

Anyhow, I watched movies and listened to music, read few e-books but did not actually delete large amount of file via Ubuntu in those windows NTFS partitions. However, one day, just to make sure that everything was OK, I went ahead and manually set a disk check in XP for the drive "D" where I had most of my personal data.

Then the PC ran a check and shi*..., out of nowhere Windows XP has found several errors on my NTFS partition where I used to play with my Ubuntu, and after the check is complete, I've lost a lot of files because of some of the complications due to buggy or whatever the reasons with NTFS-3g (you really can't blame them actually), that partition lost a lot of files!.

Luckily I was able to recover most of them but not ever thing!. I may sound foolish, but since then, I never felt comfortable opening ntfs partitions with read/write enabled. So even it happened several years ago and I'm pretty sure ntfs-3g has advanced and is highly stable these days, but still even now, I always use it read only on Linux. As said this has nothing to do with Linux or ntfs-3g, Microsoft as usual is not open enough which is the problem.

Anyway, I'm sorry I drag you this long, and let me give you a hint on how to make ntfs partitions read-only on Ubuntu.


1. first we need to create a folder where the partitions are mounted. But for that we need to know the names of the partitions as Linux has recognized them. For that issue the below command (when asked, enter your password).

sudo fdisk -l /dev/sda

If everything went well then you should see something similar to this

Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        1020     8193118+   7  HPFS/NTFS
/dev/sda2            1021        9730    69957475+   f  W95 Ext'd (LBA)
/dev/sda5            1021        8998    64083253+   7  HPFS/NTFS
/dev/sda6            8999        9730     5873664   83  Linux


(note - if you have 2 hard disks, then for the second hdd you should replace "sda" with "sdb", if you have a third it should be "sdd", etc.

We ONLY want to mount partitions that has the "HPFS/NTFS" label. So in this case I only have to mount "/dev/sda1" and "/dev/sda5".

Now I'm going to create folders for these partitions to be mounted, although you can create them anywhere, but if you want to show them on your desktop in Ubuntu after mounting, then you should create them inside "/media" directory.

2. So I'm going to create two folders called "winc" and "wind" inside "/media" (you can use whatever the names you want rather than "winc or wind"). To do that in your terminal issue the following command.

sudo mkdir /media/winc

sudo mkdir /media/wind

Now we have created folders where we want our partitions are mounted, the only thing left now is to mount them!. Let's do that.


*. To do this we have to edit a file called "fstab" which is located at = /etc/fstab.

3. But before doing that you have to make a backup in case of an emergency ;-). To do that, open your terminal and issue this command....


    cp /etc/fstab  /home/yourusername



Note that, "yourusername" should be replaced with your current username/log-in name.

4. Let's edit the fstab, open your terminal and issues the command below

sudo gedit /etc/fstab

5. Now, this would bring you a graphical text editor and you'll have to copy the below code and paste it into the opened "fstab" file (note - don't change anything that is already in the text file).

/dev/sda1       /media/winc    ntfs-3g         nls=iso8859-1,ro,umask=000,user  0  0

/dev/sda5       /media/wind    ntfs-3g         nls=iso8859-1,ro,umask=000,user  0  0

Note - You should only replace "sda1" and "sda5" with your partition names and the mounting folder names of "winc" and "wind" with your desired names. Make sure to save the file before closing.

Now reboot your PC and when you comeback to the Ubuntu Desktop you ntfs partitions will be mounted automatically with read-only :D. If you have any problems... then Spam heck out of my comments! ;-).

No comments:

Post a Comment