* [gentoo-user] Duplicate Flash drive
@ 2009-09-13 2:32 James
2009-09-13 7:13 ` Dirk Heinrichs
0 siblings, 1 reply; 6+ messages in thread
From: James @ 2009-09-13 2:32 UTC (permalink / raw
To: gentoo-user
Hello,
Background:
I've been building firewall for friends out of old pentiums and
amd machines for some time now. I have successfully switch to
compact Flash 4 G drive, using a CF to ide converter.
Now I need to be able to store a generic install on a machine, plug
in a new CF module to a CF reader/writer and copy over the default install.
From there I can change IP, hostname etc etc.
I have several CF reader/writers one should do the trick.
I have a few questions; and I'm seeking advice on how to
scale this up, so new installs and replacing firewalls
hard drives is quick and easy. All will use an identical hard
drive setup and file systems.
I guess I should use 'dd' to copy the entire contents
of one CF drive to another? Any example syntax with dd
is welcome.
Should I keep a machine around to run fdisk on a new CF
module, or is there a way, I can just plug the CF module
into a reader/writer and burn the image onto
the CF module directly, and not have to use fdisk to format
first?
What about grub and the mbr. Will dd copy over all of that information,
or do I have to run grub (grub install) manually to ensure the MBR
is set properly.
Any other comments, caveats or ideas are most welcome. The setup
I'm using is as generic as possible so all old 586/pentium/k(amd)
arch boxes work....
ideas and comments are welcome.
James
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [gentoo-user] Duplicate Flash drive
2009-09-13 2:32 [gentoo-user] Duplicate Flash drive James
@ 2009-09-13 7:13 ` Dirk Heinrichs
2009-09-13 7:24 ` Dirk Heinrichs
2009-09-13 15:48 ` [gentoo-user] " Neil Bothwick
0 siblings, 2 replies; 6+ messages in thread
From: Dirk Heinrichs @ 2009-09-13 7:13 UTC (permalink / raw
To: gentoo-user
Am Sonntag 13 September 2009 04:32:43 schrieb James:
> I guess I should use 'dd' to copy the entire contents
> of one CF drive to another? Any example syntax with dd
> is welcome.
What about "man dd"?
> Should I keep a machine around to run fdisk on a new CF
> module, or is there a way, I can just plug the CF module
> into a reader/writer and burn the image onto
> the CF module directly, and not have to use fdisk to format
> first?
No, just use dd.
> What about grub and the mbr. Will dd copy over all of that information,
> or do I have to run grub (grub install) manually to ensure the MBR
> is set properly.
If you create an image of your entire device, then no. However, you will loose
the ability to mount and modify the image. But you could easily write a small
script for writing the MBR. I've never done this, but I'd bet that fdisk (or
one of it's many cousins) can be used in scripts to setup the partitions on
the fly.
So let's assume your CF card USB stick or whatever is has one partition and is
detected as /dev/sda.
You can then first take an image of the partition:
dd if=/dev/sda1 of=firewall.img
This image can then be mounted and modified as needed:
mkdir /mnt/firewall
mount -t ext2 -oloop firewall.img /mnt/firewall
[do modifications inside /mnt/firewall]
umount /mnt/firewall
then write it back to as many other CF cards you need:
dd if=firewall.img of=/dev/sdX1 (replace X as appropriate)
There should also be a possibility to copy the MBR with dd, something like
dd if=/dev/sda of=mbr.img count=512 (not sure about the count value, though).
and write it back with
dd if=mbr.img of=/dev/sda.
The only thing left is the automatic partitioning.
HTH...
Dirk
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [gentoo-user] Duplicate Flash drive
2009-09-13 7:13 ` Dirk Heinrichs
@ 2009-09-13 7:24 ` Dirk Heinrichs
2009-09-13 15:08 ` [gentoo-user] " James
2009-09-13 15:48 ` [gentoo-user] " Neil Bothwick
1 sibling, 1 reply; 6+ messages in thread
From: Dirk Heinrichs @ 2009-09-13 7:24 UTC (permalink / raw
To: gentoo-user
Am Sonntag 13 September 2009 09:13:21 schrieb Dirk Heinrichs:
> I've never done this, but I'd bet that fdisk (or
> one of it's many cousins) can be used in scripts to setup the partitions
> on the fly.
That cousin would be sfdisk.
Bye...
Dirk
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [gentoo-user] Duplicate Flash drive
2009-09-13 7:13 ` Dirk Heinrichs
2009-09-13 7:24 ` Dirk Heinrichs
@ 2009-09-13 15:48 ` Neil Bothwick
2009-09-13 16:52 ` [gentoo-user] " Grant Edwards
1 sibling, 1 reply; 6+ messages in thread
From: Neil Bothwick @ 2009-09-13 15:48 UTC (permalink / raw
To: gentoo-user
[-- Attachment #1: Type: text/plain, Size: 1138 bytes --]
On Sun, 13 Sep 2009 09:13:21 +0200, Dirk Heinrichs wrote:
> You can then first take an image of the partition:
>
> dd if=/dev/sda1 of=firewall.img
>
> This image can then be mounted and modified as needed:
>
> mkdir /mnt/firewall
> mount -t ext2 -oloop firewall.img /mnt/firewall
> [do modifications inside /mnt/firewall]
> umount /mnt/firewall
>
> then write it back to as many other CF cards you need:
>
> dd if=firewall.img of=/dev/sdX1 (replace X as appropriate)
>
> There should also be a possibility to copy the MBR with dd, something
> like
>
> dd if=/dev/sda of=mbr.img count=512 (not sure about the count value,
> though).
>
> and write it back with
>
> dd if=mbr.img of=/dev/sda.
>
> The only thing left is the automatic partitioning.
Alternatively, set everything up as you need to start with, then dd the
entire device, including partitioning and bootloader, with
dd if=/dev/sda of=firewall.img
If you need to make changes to network or other settings for each setup,
do that after you have copied the image to the new disk.
--
Neil Bothwick
Microbiology: staph only.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* [gentoo-user] Re: Duplicate Flash drive
2009-09-13 15:48 ` [gentoo-user] " Neil Bothwick
@ 2009-09-13 16:52 ` Grant Edwards
0 siblings, 0 replies; 6+ messages in thread
From: Grant Edwards @ 2009-09-13 16:52 UTC (permalink / raw
To: gentoo-user
On 2009-09-13, Neil Bothwick <neil@digimed.co.uk> wrote:
> Alternatively, set everything up as you need to start with,
> then dd the entire device, including partitioning and
> bootloader, with
>
> dd if=/dev/sda of=firewall.img
That's how we used to do it when we were shipping CF-based
products.
The one gotcha you have to look out for is that CF cards vary
considerably in size (even though they all have identical part
numbers and are all labeled as 512MB or whatever). You can't
expect to be able to fill up 512MB CF card #1, and then always
be able to copy that to 512MB CF card #2. Card #2 might be
smaller than card #1. So you might want to check the capacity
of a good sized sample of cards and make your image a few
percent smaller than the smallest one you find.
--
Grant
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2009-09-13 16:52 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-13 2:32 [gentoo-user] Duplicate Flash drive James
2009-09-13 7:13 ` Dirk Heinrichs
2009-09-13 7:24 ` Dirk Heinrichs
2009-09-13 15:08 ` [gentoo-user] " James
2009-09-13 15:48 ` [gentoo-user] " Neil Bothwick
2009-09-13 16:52 ` [gentoo-user] " Grant Edwards
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox