DEV Community

Lag Lagendary
Lag Lagendary

Posted on

How to Turn Cloud "Trash" into a Golden 100GB Encrypted Vault (LVM + rclone)

We’ve all been there: a dozen free cloud accounts, each offering a measly 2GB to 10GB. Individually, they are useless — just a digital "flash drive" from a bargain bin. But together? They can become a high-performance, encrypted, unified storage system.

Today, I’ll show you how to legally use cloud providers as raw block devices to build a Unified Encrypted Monster on Debian/Ubuntu.

The Architecture

We aren't just syncing files. We are building a layered sandwich:

Physical Layer: Multiple free cloud accounts (Yandex, Mail.ru, Sber, Google, etc.).

Transport Layer: rclone mount points.

Block Layer: Loop devices on top of sparse files.

Abstraction Layer: LVM (Logical Volume Manager) to glue them into one drive.

Security Layer: LUKS for client-side encryption.
Enter fullscreen mode Exit fullscreen mode

Step 1: Recruiting the "Workers" (rclone)

Install rclone and configure your remotes. Map them to local directories:

Bash

Example for one of many

rclone mount remote1: /mnt/cloud/storage1 --vfs-cache-mode writes &

Tip: --vfs-cache-mode writes is crucial. It handles the latency and prevents LVM from crashing if the connection blips.

Step 2: Creating the "Bricks"

In each mounted cloud folder, create a container file. Let's say we have 50 accounts with 2GB each:
Bash

truncate -s 1900M /mnt/cloud/storage1/data.img

Repeat for storage2, storage3... storage50

truncate creates sparse files instantly without consuming local space until you actually write data.

Step 3: From Files to Hardware (Loop Devices)

Tell the Linux kernel to treat these files as hard drives:
Bash

losetup /dev/loop1 /mnt/cloud/storage1/data.img

...and so on

Step 4: The LVM Magic (The Glue)

This is where the "trash" becomes a "vault." We combine all loop devices into one Volume Group.

Bash

pvcreate /dev/loop1 /dev/loop2 /dev/loop3 ...
vgcreate cloud_monster /dev/loop1 /dev/loop2 ...
lvcreate -l 100%FREE -n gold_vault cloud_monster

Why LVM? It doesn't care where the chunks are. When you save a 5GB video, LVM automatically stripes it across multiple clouds. No single provider sees the whole file.
Step 5: Privacy First (LUKS Encryption)

We don't trust the providers, right? Let's lock the door.

Bash

cryptsetup luksFormat /dev/cloud_monster/gold_vault
cryptsetup open /dev/cloud_monster/gold_vault private_storage
mkfs.ext4 /dev/mapper/private_storage
mount /dev/mapper/private_storage /home/user/my_secure_data

Conclusion: Why bother?

Total Privacy: Everything is encrypted before it leaves your machine.

Decentralization: No single provider has your complete data.

Cost: $0.

Flexibility: Need more space? Just add another "trash" account and extend the LVM volume on the fly.
Enter fullscreen mode Exit fullscreen mode

Instead of carrying a pocketful of 150-ruble flash drives, you now have a sophisticated, encrypted SAN (Storage Area Network) running in the cloud.

Happy Hacking!

linux #opensource #cloud #encryption #storage #rclone #sysadmin #devto

Top comments (0)