Find the answer to your Linux question:
Results 1 to 2 of 2
Hi, I have 2 image files, image 1 which is 16MB, has multiple partitions, where the boot partition has a 2.4 kernel in it, and image 2, which is 32MB, ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Newbie
    Join Date
    Apr 2008
    Posts
    127

    Adding partitions to an existing image file


    Hi,

    I have 2 image files, image 1 which is 16MB, has multiple partitions, where the boot partition has a 2.4 kernel in it, and image 2, which is 32MB, has a single partition with a 2.6 kernel.

    I wish to add those extra partitions from image 1, into image 2, either by adding them within the 32MB(which means cutting back on the size of the existing partition), or adding them to the end of the image(which means extending the image beyond 32MB).

    The boot partition for both images is ext2, while the rest of the partitions in image 1 is just raw data.

    I'm working with these images in Mandriva Linux 2009.

    How can I achieve what I want to do? I think it should be with fdisk and/or mkfs but I'm not sure how? I've tried using gparted to regenerate the partitions from a new image file with the following steps:
    dd if=/dev/zero of=image.img bs=32M count=1
    gparted image.img

    Then I created a 30M boot partition. However, I'm not able to create the rest of the partitions as they are smaller than 1MB, which seems to be the min supported. I need precise control of the start/ending sectors of each partition.

    Thanks!

  2. #2
    Linux Newbie
    Join Date
    Apr 2008
    Posts
    127
    OK, so I managed to recreate a larger image and also insert those partitions that were in image 1 manually using fdisk. I did this by zeroing out a small 128MB USB stick I had, and then fdisk it with calculated cylinders, head, sectors/track values to match the USB stick capacity. Then I created either primary, extended or logical partitions on the USB stick, following the image 1 partition type/sizes, and then finally set partition 1 to be bootable. It all works out well, and when I do an fdisk -ul /dev/sdc(where the USB stick is at), I get

    Code:
    Disk /dev/sdc: 131 MB, 131072000 bytes
    2 heads, 32 sectors/track, 4000 cylinders, total 256000 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Disk identifier: 0xd4796a32
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/sdc1   *          32      255423      127696   e5  Unknown
    /dev/sdc2          255424      255487          32   e5  Unknown
    /dev/sdc3          255488      255999         256    5  Extended
    /dev/sdc5          255520      255551          16   e5  Unknown
    /dev/sdc6          255584      255615          16   e5  Unknown
    /dev/sdc7          255648      255679          16   e5  Unknown
    /dev/sdc8          255712      255999         144   e5  Unknown
    However when I dd the entire /dev/sdc into a file and do a fdisk -ul on the file, I get the following:

    Code:
    You must set cylinders.
    You can do this from the extra functions menu.
    
    Disk 131Megdisk: 0 MB, 0 bytes
    2 heads, 32 sectors/track, 0 cylinders, total 0 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Disk identifier: 0xd4796a32
    
         Device Boot      Start         End      Blocks   Id  System
    131Megdisk1   *          32      255423      127696   e5  Unknown
    Partition 1 has different physical/logical endings:
         phys=(1023, 1, 32) logical=(3990, 1, 32)
    131Megdisk2          255424      255487          32   e5  Unknown
    Partition 2 has different physical/logical beginnings (non-Linux?):
         phys=(1023, 1, 32) logical=(3991, 0, 1)
    Partition 2 has different physical/logical endings:
         phys=(1023, 1, 32) logical=(3991, 1, 32)
    131Megdisk3          255488      255999         256    5  Extended
    Partition 3 has different physical/logical beginnings (non-Linux?):
         phys=(1023, 1, 32) logical=(3992, 0, 1)
    Partition 3 has different physical/logical endings:
         phys=(1023, 1, 32) logical=(3999, 1, 32)
    131Megdisk5          255520      255551          16   e5  Unknown
    131Megdisk6          255584      255615          16   e5  Unknown
    131Megdisk7          255648      255679          16   e5  Unknown
    131Megdisk8          255712      255999         144   e5  Unknown
    Why am I getting the different physical/logical beginnings and endings message? Does it even matter?

    Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •