sprotheroe / vagrant-disksize

Vagrant plugin to resize disks in VirtualBox
MIT License
479 stars 52 forks source link

[Issue 16] Implement proper removal of cloned disk #17

Closed EmersonPrado closed 5 years ago

EmersonPrado commented 6 years ago

This change creates a method, remove_disk, which fully erases a disk file and its VirtualBox reference after cloning

rsaikali commented 6 years ago

Hi, When will this PR be merged ? 👍 Looks like it's exactly what I need.

EmersonPrado commented 6 years ago

@rsaikali This project seems inactive for quite a while - over a year indeed. Maybe the mantainer can clear this better. @sprotheroe Is this an active project? It's very useful to me. Is there any help needed?

rsaikali commented 6 years ago

Just in case, if it can help: As a workaround I use this command between any vagrant destroy/up:

vboxmanage list hdds | grep -B 2 inaccessible | egrep '^UUID' | awk '{ print $2 }' | xargs -I{} vboxmanage closemedium disk {} --delete

In my case it seems to fix the disk/media reference in VirtualBox. Inspired from: https://coderwall.com/p/8m--dq/purge-deleted-hard-disks-from-virtual-box

danowar2k commented 6 years ago

This would fix my current problem in Vagrant. Is this repository unmaintained? If so, is there a way to change ownership to someone who would maintain this?

EDIT: As this is the gem that is published to RubyGems and the forks either do not publish to RubyGems or can't, I don't know how I could get a new version of this plugin. I would rake the gem myself but ATM I only have Vagrant for Windows installed and that uses its own Ruby it seems. I don't know how I would rake there....

EmersonPrado commented 6 years ago

@danowar2k Some food for thought - a thread on RubyGems about project adoption. It doesn't seem to be implemented yet, but there seems to be some ideas.

danowar2k commented 6 years ago

This is so frustrating... There is of course no procedure for stale repositories on Github and no way to check if the owner of this is ever coming back. RubyGems doesn't have any procedure to let people publish gem forks, like detecting that a repo is a fork of another repo which is a published gem and automatically adding a gem fork (or something like it). Vagrant doesn't have a way to install plugins directly from github repositories.

I want to make the way to setup my Vagrant boxes completely painless, but right now I'm completely stumped as to how to incorporate the fix from the fork.

EDIT: Also, the plugins are installed into VAGRANT_HOME, which I have not set explicitly. And if VAGRANT_HOME is not set, it is empty and Vagrant seems to determine ~/.vagrant.d from some value in the code. If VAGRANT_HOME were accessible, I could apply a patch to the installed plugin, but noooooo...

danowar2k commented 6 years ago

@EmersonPrado : Would you please publish the disksize gem as vagrant-disksize-fork or something like it? At the moment it would be the easiest way :-/

danowar2k commented 6 years ago

I found out that I can access the directory where Vagrant plugins are installed with the Vagrant.user_data_path method. Right now I'm creating a patch and write a method above my Vagrantfile configuration where every time the disksize plugin is installed, I apply your patch to the appropriate file.

As I am completely unfamiliar with Ruby, I hope that will be enough and I won't have to compile something or other.

EmersonPrado commented 6 years ago

@danowar2k Yes, uploading a forked gem with an alternative name (have to think of a good one) is doable. I never uploaded to RubyGems, so it'll take some learning. The main problem is I don't think I can truly mantain the package. But would be a step forward. BTW, I have other two fixes waiting. If you'd like, check other pending PRs. Good to hear on the Vagrant patch. I usually make the gem directory a Git local repo, then apply changes there. git apply is my friend there. Ruby is an interpreted language. Once you change it, Vagrant will catch. Just avoid doing changes with VMs on. Just a caution.