LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-15-2009, 11:14 PM   #1
galapogos
Member
 
Registered: May 2008
Posts: 227

Rep: Reputation: 30
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!

Last edited by galapogos; 06-16-2009 at 01:28 AM.
 
Old 06-16-2009, 03:50 AM   #2
galapogos
Member
 
Registered: May 2008
Posts: 227

Original Poster
Rep: Reputation: 30
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Resize existing partitions Steve W Linux - Newbie 5 10-29-2008 10:28 AM
Correct syntax for adding text to an existing file kaplan71 Linux - Software 4 01-05-2008 06:36 PM
resizing existing partitions? Jukas Debian 3 09-20-2006 11:11 PM
Adding a new partition to an existing LV ntwrkguru Fedora 9 11-03-2005 08:22 AM
Adding new os to existing one synapse Linux - Newbie 1 01-27-2004 10:58 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:53 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration