Ugacomp

How to Transfer files from one Linux disk Partition to another

Where necessary, you may need to have access to a VPS server so you can follow how to implement the steps in this article.  You can get a cheaper VPS Server from Contabo with 4vCPU cores, 8GM RAM, and 32TB Bandwidth for less than $5.50 per month. Get this deal here now

Table of Contents

Cloud VPS S

$5.50 Monthly
  • 4 vCPU Cores | 8GB RAM

CLOUD VPS M

$15.50 Monthly
  • 6 vCPU Cores | 16GB RAM

CLOUD VPS L

$17.50 Monthly
  • 8 vCPU Cores | 24GB RAM

Transferring files between disk partitions is a common task in Linux administration. Whether you’re reorganizing your storage or need to move data for backup purposes, knowing how to efficiently transfer files is essential. In this guide, we’ll explore various methods to transfer files between Linux disk partitions with command-line examples.

Method 1: Using cp Command

The cp command is one of the most straightforward ways to copy files in Linux.

cp /path/to/source/file /path/to/destination/

For example, to copy a file named example.txt from /home/user/documents/ to /mnt/data/, you would use:

cp /home/user/documents/example.txt /mnt/data/

Method 2: Using mv Command

The mv command is used to move files and directories. It’s also commonly used to transfer files between partitions by essentially moving them from one location to another.

mv /path/to/source/file /path/to/destination/

For instance, to move a file named data.csv from /mnt/old_partition/ to /mnt/new_partition/, you would use:

mv /mnt/old_partition/data.csv /mnt/new_partition/

Method 3: Using rsync Command

rsync is a powerful utility for efficiently transferring and synchronizing files between directories, even across different partitions.

On Ubuntu and Debian-based systems, you can install rsync using the apt package manager.

sudo apt update
sudo apt install rsync

For CentOS and Red Hat Enterprise Linux (RHEL), rsync can be installed using the yum package manager.

sudo yum install rsync

Now, here is the rsync command syntax for moving files between different directories or partitions:

rsync -av /path/to/source/directory/ /path/to/destination/directory/

For example, to synchronize the contents of /home/user/documents/ to /mnt/backup/, you would use:

rsync -av /home/user/documents/ /mnt/backup/

Method 4: Using tar Command

The tar command can create archives of files and directories, which can then be moved between partitions and extracted at the destination.

tar -cvf archive.tar /path/to/source/directory/

To create an archive of /mnt/photos/ and move it to /mnt/backup/, you would use:

tar -cvf /mnt/backup/photos_backup.tar /mnt/photos/

Conclusion

Transferring files between Linux disk partitions can be achieved using various command-line utilities like cp, mv, rsync, and tar. Each method offers its advantages, so choose the one that best fits your requirements for speed, efficiency, and ease of use. With these commands in your arsenal, managing your files across partitions becomes a straightforward task.

Hire us to handle what you want

Hire us through our Fiverr Profile and leave all the complicated & technical stuff to us. Here are some of the things we can do for you:

  • Website migration, troubleshooting, and maintenance.
  • Server & application deployment, scaling, troubleshooting, and maintenance
  • Deployment of Kubernetes, Docker, Cloudron, Ant Media, Apache, Nginx,  OpenVPN, cPanel, WHMCS, WordPress, and more
  • Everything you need on AWS, IBM Cloud, GCP, Azure, Oracle Cloud, Alibaba Cloud, Linode, Contabo, DigitalOcean, Ionos, Vultr, GoDaddy, HostGator, Namecheap, DreamHost, and more.
 

We will design, configure, deploy, or troubleshoot anything you want. Starting from $10, we will get your job done in the shortest time possible. Your payment is safe with Fiverr as we will only be paid once your project is completed.