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

problems extracting the first partition from the Debian Live binary.img file



Hi there...

I created a Debian Live system in file debian-live-etch-small.img

I want to change the order of the partitions on the USB key. In the Debian
Live system, there is only the /dev/sdb1 Debian Live partition, then free
space. I want to move the Debian Live partition at the end of the USB key
and create a DOCUMENTS partition as first partition. This is because Windows
will only mount the first partition of a USB key.

As explained on my blog (
http://pierrebauduin.blogspot.com/2008/03/plus-loin-dans-debian-live-sur-une-clef.html)
the solution I found is to create a new /dev/sdb2 partition at the end of
the USB key which has the very same number of cylinders as /dev/sdb1. Then
you dd from /dev/sdb1 to the newly created /dev/sdb2 partition. Then you can
erase /dev/sdb1 and create a new DOCUMENTS /dev/sdb1 partition that will
occupy the free space before the /dev/sdb2 partition. Don't forget to set
/dev/sdb2 as a bootable partition in the MBR.

This solution always works... unless the Debian Live binary.img is bigger
than half the size of the USB key ! If you've got say, 1000 cylinders on
your USB key, and the partition in binary.img takes up 600 cylinders, you
would need to create a 600 cylinders partition at the end of the USB key.
But you can't, since there is only 400 cylinders left on the USB key.

In this case the solution is to:
1) Look at the size of binary.img and estimate the number of cylinders
(let's say n cylinders)
2) Using fdisk and/or cfdisk, create two partitions on the USB key:
/dev/sdb2 has n cylinders, and /dev/sdb1 has the rest of the space.
Partition /dev/sdb2 must be set as bootable in the MBR.
3) Extract the first partition from binary.img. In binary.img there is first
the MBR, then the first partition. The MBR has always a size of 512 bytes.
Thus you need to do:
dd if=/home/pbn/debian-live/debian-live-etch-small.img bs=512 skip=1
of=/dev/sdb2
4) Format the first partition /dev/sdb1 as fat32 and put files on it.

... and it's done. Now you can boot off that USB key.

The problem is... the USB key fails to boot.
And the reason is that when you do dd if=/home/pbn/debian-live/debian-
live-etch-small.img bs=512 skip=1 you *do not get the first filesystem* from
debian-live-etch-small.img

To try to understand and fix this problem I did a few things.

First I transferred the debian-live-etch-small.img to my USB key:
dd if=/home/pbn/debian-live/debian-live-etch-small.img of=/dev/sdb

Now to try to understand what is going wrong here is what I am doing:

So, with the very same Debian Live system in file
debian-live-etch-small.imgand on my USB stick (/dev/sdb), I'm trying
to extract the first filesystem.
This means skipping the MBR which is at the beginning of
debian-live-etch-small.img and is 512 bytes long.

Here's what I do, I'm extracting the first 5 kB of the first filesystem


Reply to: