swapless in Toronto

John Macdonald john-Z7w/En0MP3xWk0Htik3J/w at public.gmane.org
Mon Feb 7 19:36:55 UTC 2005


On Mon, Feb 07, 2005 at 01:11:15PM -0500, David J Patrick wrote:
> Lennart Sorensen wrote:
> 
> >
> >dd if=/dev/zero of=/swapfile bs=1M count=512
> > 
> >
> djp at otter:~ $ sudo dd if=/dev/zero of=/swapfile bs=1M count=512
> Password:
> 512+0 records in
> 512+0 records out
> 536870912 bytes transferred in 35.092725 seconds (15298638 bytes/sec)
> 
> can you tell me what happened here ? (I trust you, Lennart, so I just 
> went and did it) but I'd like to know.
> (and how come it took you a whole seven minutes to come up with this ? 
> were you in the can ?)

The dd command is copying data from the input file (if)
/dev/zero (which is a "device" internal to Unix OSes
that will output an infinite stream of null bytes and
which discards any data sent to it), to the output file
(of) /swapfile (which will probably get created as a new
file if it doesn't already exist).  The blocksize (bs)
argument tells dd to read and write using a 1M buffer,
so a large amount of data is read/written with each step.
The count argument tells dd to stop after 512 bufferfuls
have been copied (which lets it terminate even though
/dev/zero will happily run forever).

The "dd" command dates back to very old Unix days, and it
is derived from the OS/360 JCL command language which had
a dd statement (which had a function similar to the I/O
redirection facilities in Unix shells, but with lots of
extra bells and whistles that Unix handles by running an
extra program in a pipeline instead of options passed to
the OS).  Like the OS/360 dd, the Unix dd has facilities
for blocksize conversion(ibs and obs - used for devices
which need careful control over block sizes, like tape
drives) and character set translation (just in case your
other computer runs on EBCDIC).

> >mkswap /swapfile
> > 
> >
> I'll do it as soon as I understand step A
> 
> >add swapfile to fstab the same way you would a partition for swap.
> >
> /swapfile   /swapfile   swap   defaults   0   0            ?
> 
> > The
> >performance difference is minimal as far as I know.
> > 
> >
> As long as I can avoid the memory trainwreck, I can wait a few extra 
> nanoseconds.
> thanks Lennart,
> djp
> --
> The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
> TLUG requests: Linux topics, No HTML, wrap text below 80 columns
> How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml

-- 
--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list