We begin by identifying the source partition.
[codesyntax lang=”bash”]
sudo fdisk -l /dev/sda Disk /dev/sda: 111.8 GiB, 120040980480 bytes, 234455040 sectors Disk model: SanDisk SSD PLUS Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: gpt Disk identifier: 56B49C6F-1D42-4DE2-8C69-B130E787D345 Device Start End Sectors Size Type /dev/sda1 2048 4095 2048 1M BIOS boot /dev/sda2 4096 1054719 1050624 513M EFI System /dev/sda3 1054720 234452991 233398272 111.3G Linux filesystem
[/codesyntax]
Next we will mount our partition.
[codesyntax lang=”bash”]
sudo mount /dev/sda3 /mnt
[/codesyntax]
Lets identify our target partition.
[codesyntax lang=”bash”]
sudo fdisk -l /dev/sdb
[/codesyntax]
Identify possible target partition.
[codesyntax lang=”bash”]
sudo fdisk -l /dev/sdb Disk /dev/sdb: 111.79 GiB, 120034123776 bytes, 234441648 sectors Disk model: 2115 Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 33553920 bytes Disklabel type: dos Disk identifier: 0x7689cbd0 Device Boot Start End Sectors Size Id Type /dev/sdb1 2048 234440703 234438656 111.8G 83 Linux
[/codesyntax]
Create a new mount point.
[codesyntax lang=”bash”]
sudo mkdir -p /usb
[/codesyntax]
Mount the destination partition.
[codesyntax lang=”bash”]
sudo mount /dev/sdb1 /usb
[/codesyntax]
Copy the files.
[codesyntax lang=”bash”]
sudo cp -R -f /mnt/home/archman/workspace /usb/workspace
[/codesyntax]
To copy a specific sub directory to the backup issue the following command.
[codesyntax lang=”bash”]
sudo cp -R -f /mnt/home/archman/workspace/cb/cpp/dirCtrl2/ /usb/workspace/cb/cpp
[/codesyntax]
To change ownership of the copied files issue the following command.
[codesyntax lang=”bash”]
sudo chown -R archman:archman workspace
[/codesyntax]
Remove directory recursively.
[codesyntax lang=”bash”]
sudo rm -r /usb/workspace
[/codesyntax]
Mr. Arch Brooks, Software Engineer, Brooks Computing Systems, LLC authored this article.