PDA

View Full Version : shrinking linux vhd in hyper-v



khill1963
28-Apr-2012, 20:25
If i am running SLES 11 as a vm guest in hyper-v and have shrunk the partition down but want to compact the vhd does anyone here have nay experince with that? I was told i need to use zerofree but i can't find a suse variant of that program? they say i need to write zeros to the unallocated space. Any ideas? Thanks.

Jim Henderson
28-Apr-2012, 22:33
On Sat, 28 Apr 2012 19:34:01 +0000, khill1963 wrote:

> If i am running SLES 11 as a vm guest in hyper-v and have shrunk the
> partition down but want to compact the vhd does anyone here have nay
> experince with that? I was told i need to use zerofree but i can't find
> a suse variant of that program? they say i need to write zeros to the
> unallocated space. Any ideas? Thanks.

Try:

dd if=/dev/zero of=file.tmp
rm file.tmp

You'll need to do this on each mounted filesystem to get the full effect.

Those commands create a file full of NULL chars and then remove it.

Jim





--
Jim Henderson
openSUSE Forums Administrator
Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C

khill1963
29-Apr-2012, 14:02
Jim,
So me being a novice to linux can you explain that command to me? Also will it only write zeros to the unallocated portion of the vhd and not all of it? I would assume since this is the boot partition i would need to boot from a linux cd and run it from there. Thanks.


On Sat, 28 Apr 2012 19:34:01 +0000, khill1963 wrote:

> If i am running SLES 11 as a vm guest in hyper-v and have shrunk the
> partition down but want to compact the vhd does anyone here have nay
> experince with that? I was told i need to use zerofree but i can't find
> a suse variant of that program? they say i need to write zeros to the
> unallocated space. Any ideas? Thanks.

Try:

dd if=/dev/zero of=file.tmp
rm file.tmp

You'll need to do this on each mounted filesystem to get the full effect.

Those commands create a file full of NULL chars and then remove it.

Jim





--
Jim Henderson
openSUSE Forums Administrator
Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C

Jim Henderson
29-Apr-2012, 20:08
On Sun, 29 Apr 2012 13:04:01 +0000, khill1963 wrote:

> So me being a novice to linux can you explain that command to me?
> Also will it only write zeros to the unallocated portion of the vhd and
> not all of it? I would assume since this is the boot partition i would
> need to boot from a linux cd and run it from there. Thanks.

dd is the "data dump" command.

if=/dev/zero - takes the contents of /dev/zero as the 'input file'

of=file.tmp - specifies that the contents of the input file are written
to the file 'file.tmp'.

Because you're creating a new file, it won't overwrite allocated blocks
(because it's a file and not the device file, it's going to allocate
blocks as any program creating a file and writing to it writes).

Because you're writing just a normal file, you don't need to boot from a
LiveCD and run it there - it's just a regular file, written to a mounted
filesystem.

man dd

This will give you more detailed information about the dd command.

Jim

--
Jim Henderson
openSUSE Forums Administrator
Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C