Question

Boot from attached volume

Posted March 19, 2021 262 views
DigitalOcean VolumesUbuntu 20.04

Is there any easy way to boot a droplet from an existing volume instead of a boot image?

I’d like to be able to spin up a machine and tear it down again - and maintain all the installed packages without having to re-install from apt each time.

I don’t necessarily want a custom image for this, as I want the whole disk context to be persistent (while the actual droplet can be destroyed)

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
2 answers

Hello @kieranbingham ,

You can take a Snapshot of the Droplet. Creating a snapshot saves everything from the Droplet or volume’s disk to a disk image saved in your DigitalOcean account. Snapshots persist on your account even after the Droplet is destroyed. You will be able to create a new Droplet from the Snapshot anytime. Please refer to the following articles for more details
https://www.digitalocean.com/docs/images/snapshots/
https://www.digitalocean.com/docs/images/snapshots/how-to/

Hope this helps!

Cheers,
Lalitha

  • Doesn’t using snapshots mean that I would then have to take another snapshot after having done any ‘work’ on the image?

    I would want the usable environment state to be saved so that each time I launched, I could resume from where I last left off.

Hi,

@kieranbingham wrote
Doesn’t using snapshots mean that I would then have to take another snapshot after having done any ‘work’ on the image?

Yes, it does. You would have to take a snapshot each time before destroying your droplet, otherwise you loose your recent changes. You could simplify ‘taking a snapshot/destroying a droplet’ process with a script based on DO API.

But, have you considered chrooting ? You could install an OS on an attached block storage volume using a tool like debootstrap, and then, chroot to this environment from a droplet’s OS. In that case, all the changes will remain on the attached volume.

Note.
The solution mentioned by @Lalitha has got (at least) one advantage over chrooting. 
You can move a snapshot to another region and spin up a new droplet there. You cannot 
do that with a volume.