Page 1 of 3 123 LastLast
Results 1 to 10 of 27

Thread: Merging partitions

  1. #1
    Join Date
    Nov 2009
    Location
    Moscow, Russia
    Posts
    27

    Unhappy Merging partitions

    Hello.
    Is there an easy way to merge two non-empty partitions which have the same filesystem without losing data?
    In my case, I have 300GB hard drive broken into two partitions, each has about 80GB of data in it. The goal is to merge them without formatting or moving data from one to another and gradually increasing the size of the end partition.
    P.S.: I tried changing partition table with fdisk (deleted one, then increased another) and now I only have data from the partition I haven't deleted. So the lost data is still there, just need to find the way to make it visible again.

  2. #2
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    29,834

    Default Re: Merging partitions

    First and foremost it seems important to you to restore what you have done, even before contemplating about how to do what you want.

    You can only undo what you did by using fdisk again and recreating the removed partition with EXACT the same parameters (especialy the begin/end addresses) it had before. I hope you have a backup of a former fdisk -l somewhere or has written them down or can reconstruct them from the start/end addresses of the still existing partitions.

    When this is not the case, you have to restore the data later from the backup you made before you started changing the partition table.

    When you want more suggestions about your partitioning please post the output of
    Code:
    fdisk -l
    (and of course between CODE tags: Posting in Code Tags - A Guide).
    Henk van Velden

  3. #3
    Join Date
    Nov 2009
    Location
    Australia
    Posts
    1,391

    Default Re: Merging partitions

    One more option for repairing the damage you have done is TestDisk - CGSecurity you can find it on the PartedMagic liveCD downloads
    As for the rest of the question, I would simply delete one partition, resize the other and restore from my backup.

  4. #4
    Join Date
    Feb 2009
    Location
    Spain
    Posts
    25,547

    Default Re: Merging partitions

    On 2011-04-26 10:36, RotogloK wrote:
    >
    > Hello.
    > Is there an easy way to merge two non-empty partitions which have the
    > same filesystem without losing data?


    Easy, no.

    > In my case, I have 300GB hard drive broken into two partitions, each
    > has about 80GB of data in it. The goal is to merge them without
    > formatting or moving data from one to another and gradually increasing
    > the size of the end partition.


    Not possible.

    If they are contiguous, you could backup the second partition, assuming
    they are contiguous, then grow the first, repartitioning.

    > P.S.: I tried changing partition table with fdisk (deleted one, then
    > increased another) and now I only have data from the partition I haven't
    > deleted. So the lost data is still there, just need to find the way to
    > make it visible again.


    Good grief, man! :-O

    And you did not make a backup. And you did grow the first one... so data in
    the second one will be trashed.

    Did you grow the filesystem, or just repartitioned? As anything being
    written? If the answer is no, then just repartition _exactly_ as it were.
    You can find out, perhaps, where the old partitions were with gpart.

    --
    Cheers / Saludos,

    Carlos E. R.
    (from 11.2 x86_64 "Emerald" at Telcontar)

  5. #5
    Join Date
    Nov 2009
    Location
    Moscow, Russia
    Posts
    27

    Default Re: Merging partitions

    Quote Originally Posted by robin_listas View Post
    Did you grow the filesystem, or just repartitioned?
    I deleted the partition, not the filesystem. Then I changed end sector of another partition. I know that the first partition was 119 GB, but I don't know the exact number of sectors it had. I somehow thought that deleting the partition won't erase the data on it, seems my memory is tricking me.

  6. #6
    Join Date
    Feb 2009
    Location
    Spain
    Posts
    25,547

    Default Re: Merging partitions

    On 2011-04-26 21:06, RotogloK wrote:
    >
    > robin_listas;2330001 Wrote:
    >>
    >> Did you grow the filesystem, or just repartitioned?

    >
    > I deleted the partition, not the filesystem. Then I changed end sector
    > of another partition. I know that the first partition was 119 GB, but I
    > don't know the exact number of sectors it had. I somehow thought that
    > deleting the partition won't erase the data on it, seems my memory is
    > tricking me.


    Deleting a partition doesn't destroy the data, but it makes it not
    accessible. There is no way to merge both filesystems into one.


    You could recover your data if you replace the partition as it was, unless
    anything is written there.

    --
    Cheers / Saludos,

    Carlos E. R.
    (from 11.2 x86_64 "Emerald" at Telcontar)

  7. #7
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    29,834

    Default Re: Merging partitions

    Quote Originally Posted by RotogloK View Post
    I deleted the partition, not the filesystem. Then I changed end sector of another partition. I know that the first partition was 119 GB, but I don't know the exact number of sectors it had. I somehow thought that deleting the partition won't erase the data on it, seems my memory is tricking me.
    Your assumption about the data not changing when changing the partition table is correct. That is why we say you can recover your data when you can recover your partitions table (of course only when you data is not overwritten by any other means).

    But your misconception lies imho in the fact that you think that a file system is just a continuous thing with no proper begin end end in such a way that you can put two of them behind each other and that they then miraculous become a new file system. A bit like two rectangle boxes neighbouring each other filled with water where you just remove the divider between them to have one big box filed with water.

    This is not true. A file system is an organised thing with a start and an end and a lot of other special places in between. That organisation is spread all over that file system and does not change when you simply remove a divider. When he new space is at the end of the existing file system, software that knows how this type of file system (e.g. ext4) works may be abl to change that organisation and add new structures into the new space. Thus the file system is extended. But of course all organisation data that was in that new space wll be then of nil value (as this will overwrite pieces of file system organisation and data in the new space).

    But your biggest error may be that you did not make any backups before you started to play with your partition table. Every partition table thread here has this advice at least one time.
    Henk van Velden

  8. #8

    Default Re: Merging partitions

    It might sound silly but ... would it be a big deal to have a daemon or something making regular snapshots of the partition table... or in the worst case fdisk -l in a cron job? Among all features that are supposed to make life easier, that would be more usefull than automatic mounting of unreadable partitions.

  9. #9
    Join Date
    Feb 2009
    Location
    Spain
    Posts
    25,547

    Default Re: Merging partitions

    On 2011-04-26 23:36, please try again wrote:
    >
    > It might sound silly but ... would it be a big deal to have a daemon or
    > something making regular snapshots of the partition table... or in the
    > worst case *fdisk -l* in a cron job? Among all features that are
    > supposed to make life easier, that would be more usefull than automatic
    > mounting of unreadable partitions.


    Propose it as a junior job or summer project in the project mail list. It
    is not that difficult to do ;-)

    --
    Cheers / Saludos,

    Carlos E. R.
    (from 11.2 x86_64 "Emerald" at Telcontar)

  10. #10

    Default Re: Merging partitions

    Quote Originally Posted by robin_listas View Post
    On 2011-04-26 23:36, please try again wrote:
    >>
    >> It might sound silly but ... would it be a big deal to have a daemon or
    >> something making regular snapshots of the partition table... or in the
    >> worst case *fdisk -l* in a cron job? Among all features that are
    >> supposed to make life easier, that would be more usefull than automatic
    >> mounting of unreadable partitions.


    Propose it as a junior job or summer project in the project mail list. It
    is not that difficult to do ;-)
    Indeed, it is not! Next time someone comes in the development forum and asks how he could be helpful.

Page 1 of 3 123 LastLast

Tags for this Thread

Posting Permissions

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