[svlug] Need a shell/bash loop over each partition and execute dd && rm

Bill Ward bill at wards.net
Tue Aug 2 12:11:46 PDT 2011


This sounds dangerous enough that automating it to such an extent would be
fraught with peril. Perhaps having the list of filesystems stored in the
script would be safer than trying to parse df and potentially nuking
something you shouldn't. After all, who's to say that a future upgrade to
the OS might not change the output format of df?

On Mon, Aug 1, 2011 at 8:05 PM, Daevid Vincent <daevid at daevid.com> wrote:

> I use VirtualBox quite a lot, but one of the drawbacks of Linux guest VMs
> is that there is no built in way to shrink the .vdi disks… they just
> continually grow.****
>
> ** **
>
> However, you can manually shrink them by doing this:****
>
> ** **
>
> sudo dd if=/dev/zero of=./zerofile && sudo rm ./zerofile****
>
> ** **
>
> then execute:****
>
> VBoxManage modifyhd %USERPROFILE%\.VirtualBox\HardDisks\myVBVM.vdi–compact
> ****
>
> ** **
>
> The process is more tedious if you’re using FreeBSD or other Unix flavors
> that have multiple partitions.****
>
> ** **
>
> Can someone give me a little bash-fu that will loop over every partition,
> execute that dd and rm command?****
>
> ** **
>
> I’m pretty sure it will involve “df” and sed/awk, but maybe there’s a
> better way to find all the partitions on ANY unix variant? We mix FreeBSD,
> Debian, Ubuntu VMs here for various purposes.****
>
> ** **
>
> Thanks in advance,****
>
> ** **
>
> d.****
>
> ** **
>
> ** **
>
> ** **
>
> _______________________________________________
> svlug mailing list
> svlug at lists.svlug.org
> http://lists.svlug.org/lists/listinfo/svlug
>
>


-- 
Check out my LEGO blog at http://www.brickpile.com/
View my photos at http://flickr.com/photos/billward/
Follow me at http://twitter.com/williamward
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.svlug.org/archives/svlug/attachments/20110802/2cc9d907/attachment.htm


More information about the svlug mailing list