• Quote of the week

    “Here's to the crazy ones. The misfits. The rebels. The troublemakers. The round pegs in the square holes. The ones who see things differently. They're not fond of rules. And they have no respect for the status quo. You can quote them, disagree with them, glorify or vilify them. About the only thing you can't do is ignore them. Because they change things. They push the human race forward. And while some may see them as the crazy ones, we see genius. Because the people who are crazy enough to think they can change the world, are the ones who do.”
    ― Rob Siltanen

    Past Quotes of the Week

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

A rough utilization of cat command would be to make a full disk backup or a disk partition backup 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.

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.

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

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

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

$ sudo resize2fs /dev/sdb1

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.

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

Similar Posts:

Comments are closed.

  • Your online freedom is just seconds away.

    Buy VPN with Bitcoin, PayPal, Credit Card | Get Your First 30 Days FREE

  • Famous Quotes In History

    "I think the subject which will be of most importance politically is mass psychology....Although this science will be diligently studied, it will be rigidly confined to the governing class. The populace will not be allowed to know how its convictions were generated."
    -- Bertrand Russell in The Impact of Science on Society  
     
    “Beware the leader who bangs the drums of war in order to whip the citizenry into a patriotic fervor, for patriotism is indeed a double-edged sword. It both emboldens the blood, just as it narrows the mind. And when the drums of war have reached a fever pitch and the blood boils with hate and the mind has closed, the leader will have no need in seizing the rights of the citizenry. Rather, the citizenry, infused with fear and blinded by patriotism, will offer up all of their rights unto the leader and gladly so. How do I know? For this is what I have done. And I am Caesar.”
    – Julius Caesar  
     
    Past Famous Quotes | Archive