Sunday, June 14, 2015

How To copy a Very large file to a flash drive in Linux

 

Say that you have a very large file say 6GB and you want to copy the entire file into a flash drive with FAT32 file system where the maximum size for each file can be around 4 GBS ((2^32) - 1 bytes). If you want to copy them then you have got two choice :-

1. Format the USB with some other file system which will allow files of size greater than 4 gb, like NTFS.
2. Split the Large file into smaller sizes and write to USB and then concatenate them into a single file.

I prefer the second method and so we will learn how to do this.

Step 1

Split the file into smaller sizes and write it to flash drive. (Make sure you have mounted your flash drive already)

split --bytes=2G VeryLargeFIle.txt /media/38B9-D21F/VeryLargeFile.txt. 

In th above command we are splitting a text file (it could be any file) into smaller files of size 2GB and storing in the location where our flash drive was mounted.

Now if look into your mounted drive folder you will see smaller files with sequential extensions were created like VeryLargeFile.txt.aa, VeryLargeFile.txt.ab ......

Step 2

Now we concatenate the smaller files into a single file. We can do this using the cat command. Simply copy the three smaller files from usb to another location in a different pc (Do whatever you want). Move to that location using terminal and then execute the following command. 

cat VeryLargeFile.txt.aa VeryLargeFile.txt.ab VeryLargeFile.txt.ac > VeryLargeFile.txt


Taddah! You now have your very large file moved to another system and in another location in one piece. You can remove the smaller sized files which were created earlier in the USB.

I hope you like this little piece of advice or trick. This technique will work on any file with any format.

Share this post among your social networks.

Thank you.
Sincerely,
Psycho_Coder

0 comments :

Post a Comment

Follow Me!

Blog Archive

Followers

Visitor Map