How to Backup or Clone Linux Partitions Using ‘cat’ Command

A rough utilization of Linux cat command would be to make a full disk backup or a disk partition backup or cloning of a disk partition by redirecting the command output against the partition of a hard disk, or USB stick or a local image file or write the output to a network socket.

Linux Filesystem Backup Using 'cat' Command

Linux Filesystem Backup Using ‘cat’ Command

It absolutely normal of you to think of why we should use cat over dd when the latter does the same job easily, which is quite right, however, I recently realized that cat is much faster than dd when its comes to speed and performance.

I do agree that dd provides, even more, options and also very useful in dealing with large backups such as tape drives (How to Clone Linux Partitions Using ‘dd’ Command), whereas cat includes lesser option and it’s not necessarily a worthy dd replacement but still, remains an option wherever applicable.

Suggested Read: How to Clone or Backup Linux Disk Using Clonezilla

Trust me, it gets the job done quite successfully in copying the content of a partition to a new unformatted partition. The only requirements would be to provide a valid hard disk partition with the minimum size of the existing data and with no filesystem whatsoever.

In the below example the first partition on the first hard disk, which corresponds to the /boot partition i.e. /dev/sda1, is cloned onto the first partition of the second disk (i.e. /dev/sdb1) using the Linux redirection operator.

# cat /dev/sda1 > /dev/sdb1
Full Disk Partition Backup in Linux

Full Disk Partition Backup in Linux

After the command finishes, the cloned partition is mounted to /mnt and both mount points directories are listed to check if any files are missing.

# mount /dev/sdb1 /mnt
# ls /mnt
# ls /boot
Verify Cloned Partition Files

Verify Cloned Partition Files

In order to extend the partition file system to the maximum size issue the following command with root privileges.

Suggested Read: 14 Outstanding Backup Utilities for Linux Systems

$ sudo resize2fs /dev/sdb1
Resize or Extend Partition Size in Linux

Resize or Extend Partition Size in Linux

The cat command is an excellent tool to manipulate text files in Linux and some special multimedia files, but should be avoided for binary data files or concatenate shebang files. For all other options don’t hesitate to execute man cat from console.

$ man cat

Surprisingly, there is another command called tac, yes, I am talking about tac, which is a reverse version of cat command (also spelled backwards) which display each line of a file in reverse order, want to know more about tac, read How to Use Tac Command in Linux.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

Ravi Saive

I am Ravi Saive, creator of TecMint. A Computer Geek and Linux Guru who loves to share tricks and tips on Internet. Most Of My Servers runs on Open Source Platform called Linux. Follow Me: Twitter, Facebook and Google+

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

7 Responses

  1. dzaczek says:

    Hi,

    Nice tutorial but when we cloning partition/disk must remember about change uuid after copy. If disk will stay connected to machine after reboot we can have problem with mount by uuid.

    Sometimes we want to have the same uuid but you must remember to remove the disk from the server for xfs file system.

    # xfs_admin -U {uuid} {device}
    

    for ext file systems

    # tune2fs /dev/{device}  -U time 
    

    For reiserfs

    # tunefs.reiserfs -i {uuid} {device}
    
    • Ravi Saive says:

      @Daczek,

      I agree with you, we should change the uuid after creating a clone or copying disk and thanks for sharing the commands for changing the UUID in Linux. Hope it will help other users..

  2. James pinkerton says:

    Morning Ravi, I see what cat does and just wondered why when making a bootable usb pen-drive the code listed on most web-sites uses dd if=whatever.iso of=/dev/sdb, I read that dd copies saved files byte by byte probably from ascii coded text, how does cat work. I am a novice user of Linux, currently taking in all knowledge to gain my ” Red-Hat CSA”. I use your website daily, very informative chunk size blocks of data. Thank you

  3. Jalal Hajigholamali says:

    Hi,
    Thanks for nice article

  4. PP says:

    Another one is writing ISO images to flash drives. Su to root and then, `cat fedora-24.iso > /dev/sdx`

  5. Rafael Rojas says:

    Thanks Ravi Saive for this article!!. One question, can I use the cat command to clone a partition with database files? like MySQL, or it’s works only if the original partition contains only text files?.

    • Ravi Saive says:

      @Rafael,

      In Linux everything is file, so the cat command will work on all types of files, whether it is database file or any file type extension, you can easily clone any partition..

Leave a Reply to dzaczek Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.