NTFS and Linux – An Annoying Relationship

Very recently I wrote a blog about getting rid of FAT32 file systems because the maximum file size that it can handle is 4GB. Read it here if you are interested.

By the end of that blog I had decided that I would move to either ext4/NTFS and get rid of FAT totally. ext4 was only for linux and is not compatible with windows. NTFS on the other hand is compatible with windows and linux. I started off by copying stuff off my 16GB FAT32 pen drive and loading it on my laptop, to format it into an NTFS drive, so that I can load it all back again. I was done with this process in half an hour. Then I noticed something, all the files and folders in the drive had weird (read, write, execute) permissions now. Everything was a 777 (rwxrwxrwx). Meaning, every file had permissions to read, write and execute for user, group and others. That was an irritating sight to see on a terminal.

A little searching,  and I realized that, although NTFS has a much bigger file size limit, it does not retain permissions from a linux system. Uff! That was really disappointing. It was still possible to maintain permissions, but it was a long process and I was not going to complicate my life for basic backup and file transfer. I had to do some thinking and I realized that the best way to handle this was to use ext4 along with FAT32 and NTFS, in some fashion so I get the best of both worlds. So this is what I decided for the two 16GB pen drives and one 1TB hard disk I have for work.

  1. One of the 16GB pen drive would be turned into an ext4 system for use with Linux and also for those big files. Since most of the computers around me use linux, it would not be much of a problem and I do not want any pesky virus filled windows users to use my pen drive either.
  2. The other 16 GB pen drive will remain FAT. To be compatible across all machines. It would not be able to handle huge files but who’s handling huge files all the time.
  3. The 1TB hard disk would be split into two drives
    1. 800GB ext4 for use with my machine and other linux machines if required. Again to avoid virus laden windows users and their machines. (It is pretty simple to clean off viruses from a linux system later on though. But it needs some work. Maybe I will talk about it in some other post)
    2. 200GB NTFS for use with windows if required anytime in the future. A big portion, but I thought it might be required somehow.
Advertisements

Autorun, Not really a bad guy

When ever someone finds an autorun.inf file in their flash drives, they would immediately try to hit delete, thinking it is a virus. It most probably is, except in some situations.

Autorun.inf is a file that is used to give some attributes to a disc/disk. For example an icon for your cd, or for your pen drive even. You could also assign some parameters to determine what program should be launched when the disc is loaded. Stuff like that.

Something interesting you could do with your pen drives is, to give it a fancy icon. All you have to do is create a file called Autorun.inf using a text editor and enter something like

[autorun]
icon=.\someicon.ico

Save the file in the root folder of the disc/disk and then add your image file as well in the same place (or some other place, depending on the path you set for the icon parameter). You are done.

Another common parameter is open=myapplication.exe

For more info, refer the manual. Or take a look at this blog, it was pretty good. I just wanted to let you know that it is not always a virus, you have some good uses too. Just that its vulnerability is used pretty well by the virus manufacturing folk 🙂

Compress, Split and Join Tar files – Linux

Creating a tar file and splitting it for storing it in cds, dvds or any other storage with small capacity.

Create a tarball and compress it using bz2 or gz compression algorithms by using one of the following commands.

tar -cvjf tarofsomefolder.tar.bz2 /home/someone/Documents/*
tar -cvzf tarfileofsomeiso.tar.gz some.iso

To split you can use the split command
split -b 4500M tarofsomefolder.tar.bz2 "tarofsomefolder.tar.bz2.part"

You can use both of them together in a single command by piping the outputs of the tar command to the split command,

tar -cvzf downloads.tar.bz2 ~/Downloads/* | split -b 4500M - "downloads-part"

To extract these split tar files together, you have to cat those individual tar files either by listing them one after the other or by using a regular expression that covers all of it and then piping the output to a tar extract command. Something like,

cat downloads.tar.bz2.part* | tar -xvzf -

Mount a disk – Linux – cmd

To mount a disk (usually a file system that you usually go and click on using nautilus/caja (file browsers)) from the command line, use the following,

udisksctl mount -b /dev/disk/by-label/

Listing the content of /dev/disk/by-label/ will give you the names of the mountable disks/drives. Usually flash drives are mounted automatically so they do not have to be mounted. Unless you unmount it and want to mount it again. Use man udisksctl for more information. Also, I think it is udisks in some distributions.

Wget – Download from a list

If everyone started to read the manual then bloggers like me would…. eh no… I would still blog even if no one reads this.

This is pretty simple but it is really nice and may inspire you to investigate more. If you have a list of links to download all you have to do is put them all in a text file. One in each line. Then fire up wget from the terminal like this

wget -i path/to/textfile

 

This will download all of those files one by one and save it in the present working directory. Really good if you already have a list of links to download. Or if you have a set of links to download from on  the same page you can use some download plug in like downthemall on firefox.

You can use wget to do a lot lot more. Read the manual. You can use wget on bash scripts as well, since it is a command line tool. Imagine the possibilities. You could write a bash script with regex to get all files with certain patterns from a particular location. I once downloaded a full website containing more than a 1000 html pages with wget, and it was really good. But that was simple. Not much scripting involved though. You just have to look for the proper parameters to use with wget.

Get rid of the FAT(32)

Here is one good reason why you can stop using FAT32 file format for your drives.

The Story: I have been using computers since around 2000. I started out with windows 98 first of all and I have grown up using FAT32 for a very long time. When NTFS came in, right about when windows NT came in i guess? I am not sure, I never bothered to know what it was about and I continued using FAT32 on all my data drives till now. Although my C drive may have been in the new NTFS format, I was still using FAT32 for the other drives without realizing what I was doing. Then I switched to Linux where it was ext4. So for a lot of years NTFS and FAT32 did not bother me.

The Crux: Calamity struck now after so many years. I was trying to download an 8GB zip file containing a database and the downloads kept stopping at 4GB. A little investigation, and I came to know that the maximum file size in a FAT32 drive is only 4GB. Gladly, my trust wget command line downloader gave me a perfect error to search for. The only way out of this was to have an NTFS or ext4 drive. Maybe I would just go for ext 4. I dont see myself adding/installing windows anytime in the future on my laptop.

A good job for tomorrow. Backup everything on an external hard drive, format my hard disk, put it all back again.


Thu Oct 5 14:10:16 IST 2017: Related update here