
Vultr Block Storage is a high performance, highly available, and scalable storage solution that allows you to expand its storage capacity independently from its compute instance. Google Cloud Platform (GCP) persistent disks are block storage volumes you can mount on virtual machines and store data similar to Vultr Block Storage volumes.
Follow this guide to migrate Google Cloud Platform (GCP) persistent disks to Vultr Block Storage. You will set up a migration environment, transfer your data, and verify the integrity of the transferred files using Rsync.
Before you begin, you need to:
In this section, you'll prepare the Ubuntu instances of both, your Vultr account and your Google Cloud Project, for the data migration. To prepare your GCP environment, open the SSH session of your Compute Engine instance in your browser window and follow these steps:
List the filesystem devices attached to your instance.
Below is an example output:
sda contains your operating system files. sdb is the unmounted persistent disk. GCP persistent disks' naming convention appends an english alphabet to sd in sequence for each additional disk, such as sdc, sdd, sde, and so on.
Create the /mnt/persistentdisk directory to mount the disk.
Mount the /dev/sdb disk to the /mnt/persistentdisk directory.
If you want to migrate data from a specific partition of your disk, you can replace the /dev/sdb device with your partition.
List the attached devices with additional details.
Example output:
You can see that the filesystem format for the sdb Block Storage volume is ext4 and it is mounted at /mnt/persistentdisk. Note this format for use with your destination Vultr Block Storage volume.
Change the ownership of the mount directory and its files to your username to make the disk and its content readable and writable by your username.
Replace gcpuser with your actual username in the command above.
Navigate to the disk's mount directory.
If your disk is empty, create some dummy files for testing purposes.
Add content to these dummy files.
View disk usage and check the volume's usage ratio.
Example output:
In the above output, the /dev/sdb Block Storage volume, mounted on the /mnt/persistentdisk directory, shows a 1% usage.
You should consider the size and file format of your source device and create an appropriately sized Vultr Block Storage instance to transfer the data to.
To prepare your Vultr environment, access your Vultr Cloud Compute instance via SSH as a non-root sudo user, and follow the below steps:
List the attached devices.
Example output:
vdb is the unmounted Block Storage volume. vda contains your operating system files. Vultr Block Storage volumes follow the vd naming convention, with additional disks named vdc, vdd, vde, based on the number of attached volumes.
Format the volume with the filesystem of the source persistent disk, such as ext4.
Create the /mnt/blockstorage directory to mount the disk.
Mount the /dev/vdb volume in the /mnt/blockstorage directory.
Change the ownership of the mount directory to ensure it's writable by your non-root user.
Replace linuxuser with your non-root username.
View disk usage and check that the volume is mounted.
Example output:
In the above output, the /dev/vdb Block Storage volume is mounted to the /mnt/blockstorage directory.
If your GCP persistent disk has multiple partitions, create matching partitions on your Vultr Block Storage volume with the same filesystem format and an equal or larger size.
In this section, you will migrate the files using the Rsync tool. Rsync uses SSH to securely transfer the files over an encrypted connection. In the GCP Compute instance:
Use the below command to start the transfer. Replace linuxuser with your Vultr Cloud Compute instance's non-root username and 192.0.2.1 with its IP address.
Parameters of the command above do the following:
-a - Archive mode (preserves file structure, permissions, timestamps).-v - Generates more verbose output.-z - Compresses the files during data transfer.--progress - Displays real-time transfer progress.--partial - If the transfer interrupts, Rsync doesn't delete any not entirely transferred file.--exclude="lost+found" excludes the lost+found directory from transferring to avoid permission errors and irrelevant data. The filesystem automatically generates this directory for recovery purposes and does not contain user data.You will be prompted to confirm if you want to connect to the remote host. Enter yes at the prompt.
Enter the password of the your Vultr Cloud Compute username at the next prompt.
Wait for the transfer to complete. The transfer may take from several minutes to hours, depending on the data size.
If the file transfer command interrupts or exits due to an error, execute the rsync command again and enter the SSH password to resume the transfer.
If you have multiple partitions in your Google Persistent disk, you can repeat this process for each one of them.
In this section, you will verify that all files transferred without any errors. You will use the Rsync file integrity check, and then create a list of checksums as an extra verification layer of integrity. You will also preview the content of files to ensure they are accessible.
Verify that all files transferred without errors. Replace linuxuser with your Vultr instance's non-root username and 192.0.2.1 with the Vultr instance's IP address.
The command above verifies that the files transferred without errors. It re-uploads any corrupted or missing files.
Enter the SSH password of the Vultr instance.
Wait for the integrity check to complete.
Example output:
Navigate to your user's home directory.
Generate a list of hash checksums of all the files in the Google Cloud persistent disk.
The command above skips computing checksums for the lost+found directory. Rsync didn't transfer this directory, as it is automatically generated by the filesystem for recovery purposes and does not contain user data. The command may take from minutes to hours to finish executing, depending on the data size.
If the command above doesn't return any output, the hash list was generated.
Generate a list of hash checksums of all the files on the Block Storage volume and download it. Replace linuxuser with your Vultr instance's non-root username and 192.0.2.1 with the Vultr instance's IP address.
Enter the SSH password of the Vultr instance.
If the command finishes without any output, it generated the hash list without errors.
Sort the Block Storage checksum list to make the file comparable with the other checksum file.
Sort the persistent disk checksum list to make the file comparable with the other checksum file.
Adjust paths in the persistent disk checksum file to match the Block Storage path structure.
This ensures that both checksum files are comparable in the next step.
Compare the checksums.
If the command above returns no output, it means the files transferred without any corruption.
Otherwise, if the command returns any output similar to below, please repeat the file transfer process by going back to the previous section. You won't have to wait for the entire process to finish again, as Rsync will only transfer the missing or corrupted files.
The output above means that the file test1.txt transferred with errors.
Once the data is transferred successfully, you can cut over your application to use Vultr Block Storage.
You have migrated data from a GCP Persistent Disk to a Vultr Block Storage volume. You've used the Rsync tool to transfer the data and verified its integrity and accessibility. For more information on Vultr Block Storage, visit the official documentation.
0 Comments
Be the first to comment and share your perspective with the community.