[Top][All Lists]

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

Building a disk

From: Dale Amon
Subject: Building a disk
Date: Tue, 10 Apr 2012 19:47:39 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

I've a straightforward problem that recurs time after
time after time, and I am quite surprised that I have
not been able to find explicit instructions on how to
do it. I've tried again and again, occasionally 
successfully with much magic, but not terribly

Lets say you have a laptop with the system on /dev/sda.

You mount a hard drive via:

        * A SATA/IDE/USB converter
        * VIA a superbay on a Thinkpad
        * Via a /dev/loop0 of a blank image file

Now you build a system onto the disk:

        $ dd if=/dev/zero of=/ count=20M
        $ losetup /dev/loop0
        $ cfdisk /dev/loop0
                # create a 9G bootable linux partition and a 1G swap
        $ kpartx -a -v /dev/loop0
        $ mkfs.ext4 /dev/mapper/loop0p1 -m 0.01 -L "RecoverTest"
        $ mkdir tmp
        $ mount /dev/mapper/loop0p1 tmp

   From the backup server:
        $ rsync -av address@hidden:/srv/backup/ tmp/

Everything is really easy and straightforward so far, right?

Now... how do I install grub? The boot device I am building is 
mounted as /dev/sdb or /dev/loop0. When it is actually used it 
will be mounted as /dev/sda. How do I reliably tell that to 

This has got to be easy. I just can't believe there isn't a
simple way to do this.

Oh, and I might add that I sometimes have to do this for
grub 1 and sometimes for grub 2. So I need to understand
both environments.

I'm looking for a simple shell scriptable way of doing it.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]