[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-users] Clean deleted space in linux diks?

Niels Dettenbach (Syndicat IT&Internet) wrote:

 >a=0 ; while [ $a -lt X ]
 >   dd if=/dev/zero of=null-file-$a bs=1024k count=1024
rm null-file*

hmmm, just to understand: this is writing onto a file system and not to a device directly, or not?

This particular command sequence will create a number of files called null-file-0, null-file-1, and so on. With these figures, each file will be 1GB in size.

If you do :
  dd if=/dev/zero of=big-null-file
then you will create a file called big-null-file which will grow until either the filesystem is full, or the file reaches the file size limit for your combination of OS and filesystem.
The same effect can be had with
  cat /dev/zero > big-null-file

In case you don't quite get what is happening. "dd" is a command that copies input to output, while applying conversions (none in this case). "if" specifies infile, "of" specifies outfile, "bs" specifies block size, and "count" specifies how many blocks to copy. So "dd if=/dev/zero of=null-file-$a bs=1024k count=1024" means : copy /dev/zero to null-file-<something>, use 1MByte blocks, and copy 1k of blocks (to get 1GByte of file).

/dev/zero is a "magic file" that just produces an infinite number of zeros (nulls) for as long as you read it.

Simon Hobson

Visit http://www.magpiesnestpublishing.co.uk/ for books by acclaimed
author Gladys Hobson. Novels - poetry - short stories - ideal as
Christmas stocking fillers. Some available as e-books.

Xen-users mailing list



Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.