[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ilug
Subject:    Re: [ILUG] how to create an image of a partition?
From:       "Colm Buckley" <colm () tuatha ! org>
Date:       2007-05-28 9:55:41
Message-ID: 9003ed000705280255x15b3959bnaf0531fd676fcc33 () mail ! gmail ! com
[Download RAW message or body]

> == Conor Daly
>> == Lisa Muir
>>> == Colm Buckley

>>> If you just want to compress the image, pipe dd through gzip or bzip2
(dd bs=4k < /dev/sda2 | bzip2 -9 > partition.image).

>> Just out of curiousity, what is the thinking behind setting the bs=4k
>> ... for an 8gig partition, IMHO, thats going to take ages compaired
>> with something like bs=1M as Proinnsias suggested, which is what I use
>> when I dd, but knowing that you know more about linux than I, I'd just
>> love to hear the thinking behind the 4k!

It doesn't make that much difference.  There's a small overhead associated
with each read() and write() system call, but we're talking tens of
microseconds per block at worst.  On an 8GB partition, bs=4k might have a
read and write overhead a few seconds - bs=1M would reduce that but, on the
other hand, 4k matches the default block size of the device, so the kernel
and dd can do some useful optimisations.  The larger the block size, the
greater the possibility that the kernel might need to retry the read, if
it's interrupted in mid-flow.  Also, the larger the block size, the more
memory dd will require, and the higher the possibility that it'll hit swap
space.

It would only take "ages" if you used a really small block size.  On
morrigan, copying /dev/sda2 (4GB swap partition) actually takes considerably
*longer* with bs=1M than with bs=4k (this was after a couple of runs to
prime the block cache):

dd if=/dev/sda2 of=/dev/null bs=4k  0.29s user 5.05s system 5% cpu 1:33.28total
dd if=/dev/sda2 of=/dev/null bs=1M  0.02s user 6.88s system 5% cpu 2:16.35total

Note that the "user" time is indeed lower with bs=1M as opposed to bs=4k,
but the overall time is longer.

> My assumption is that it's related to the 4k default inode size on an
> ext2/3 filesystem but, given that I don't know the inside of Colm's head,
> that may be tosh.

s/inode/block but yes.

Colm


-- 
Colm Buckley / colm@tuatha.org / +353 87 2469146
-- 
Irish Linux Users' Group mailing list
About this list : http://mail.linux.ie/mailman/listinfo/ilug
Who we are : http://www.linux.ie/
Where we are : http://www.linux.ie/map/
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic