Simple trick of how to split and merge back large files on Linux using split and cat commands. split and cat commands belong to the GNU core utilities which are expected to exist on every Linux operating system. Means, every Linux distro is already prepared for split/merge files and you only need to know how.
In my scenario, I wanted to copy virtual machine with 8GB disk image to the USB stick. USB stick has contained enough space but copying process stopped at 2GB with output message File too large. Here is report of file system disk space usage:
$ df -Th Filesystem Type Size Used Avail Use% Mounted on /dev/sda1 ext2 7.9G 409M 7.1G 6% / tmpfs tmpfs 996M 552K 996M 1% /dev/shm /dev/sdb5 ext4 204G 53G 141G 28% /home /dev/sdb3 ext4 4.0G 140M 3.7G 4% /tmp /dev/sda2 ext2 22G 5.8G 15G 29% /usr /dev/sdb1 ext4 20G 13G 6.4G 66% /var /dev/sdg1 vfat 16G 5.8G 9.5G 38% /media/CORSAIR
“T” switch of df command prints file system type. As you can see, CORSAIR USB stick has VFAT (FAT32) file system. FAT32 has 4GB file-size limit but it’s signed (for +/- seeking within a file), so the limit is 1/2 the range, hence 2GB total. The only workaround was to split large file into pieces. With split command, 8GB file was sliced to four 2GB files (before start split process, be sure to have enough free space on disk):
# split [option] [input [prefix]] $ split --bytes=2048m WinXP.img WinXP_img_
After several minutes, four files (2GB each) appeared in the same directory:
WinXP_img_aa WinXP_img_ab WinXP_img_ac WinXP_img_ad
Now copying sliced parts to the USB stick had been without problems. After files were copied to the new Linux host, four pieces should be returned to the original form. cat command can concatenate files and here is how:
# cat [option] [file]... $ cat WinXP_img_* > WinXP.img
Hope this simple scenario will help you to split/merge large files on Linux.