LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-26-2007, 06:18 AM   #1
kreon28
LQ Newbie
 
Registered: May 2007
Posts: 4

Rep: Reputation: 0
[solved] merging partitions


Hi,

I've got 2 disks and partitions like:
/dev/hda1 FA32 (boot)
/dev/hda2 Linux (working system)
/dev/hda3 Win95 ext'd
/dev/hda4 Linux (broken system)
/dev/hda5 linux swap
/dev/hdb1 Fat32

On hda4 I have got distro to delete, so I would like to merge hda4 and hda2 partitions into one.
Grub is on hda1 (MBR)
Of course I want to merge both partitions without formatting hda2.
The best option I though would be merging these partitions using some shareware software under win98 but after that grub wouldn't boot.
Anyone could help me with that?

p.s my box is old with small HDD's (I'm using DSL 3.3) so mounting /home under hda4 won't help because any bigger file wouldn't fit.

Last edited by kreon28; 05-27-2007 at 09:36 AM.
 
Old 05-26-2007, 07:56 AM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671
Look into using LVM.
 
Old 05-26-2007, 09:54 AM   #3
kreon28
LQ Newbie
 
Registered: May 2007
Posts: 4

Original Poster
Rep: Reputation: 0
Yeah, but how to do it without being geek :P
 
Old 05-26-2007, 12:31 PM   #4
Junior Hacker
Senior Member
 
Registered: Jan 2005
Location: North America
Distribution: Debian testing Mandriva Ubuntu
Posts: 2,687

Rep: Reputation: 61
Looks to me like it might not be possible because hda2 is a primary partition and hda4 is a logical partition. The only suggestion I could make is to download and try gparted to see if it can move the location of the extended partition hda3 in between them to get the free space next to hda2. If you delete hda4, you will have free space which can be added to a partition next to it.
 
Old 05-26-2007, 01:27 PM   #5
lurko
Member
 
Registered: Jun 2006
Location: Ontario, Canada
Distribution: Debian
Posts: 448

Rep: Reputation: 35
I had a whole other post written (and posted) about my confusion with your partition list. Then I removed most of it after I saw hda3 was "ext'd". Then I did this edit because I still can't fully grok the list you posted.

If hda3 is your extended partition, there shouldn't be a hda4 - the first logical drive in the extended partition would be hda5 since 1-4 are reserved for primary partitions. If that was my drive I'd probably delete every partition after hda2 and start over to be honest.

If there's only the extended partition between 2 partitions you want to merge, then that should work fine - but only if there are no other partitions/logical drives in that extended partition (like the swap partition you list as being hda5, which would be wiped out if you deleted your extended partition to merge hda2 and what you're calling hda4). So to summarize, going by the partition list you posted, I would not recommend doing what I explain below. Please run #fdisk -l and post the output before proceeding, or at least be certain you really know which partitions are which and what the consequences of deleting some of them will be.

merge partitions with fdisk
-unmount any partitions you'll be working on.

#fdisk /dev/hda

-use 'm' to list fdisk commands.

-use 'p' to list the partition table. note the start cylinder of the first partition you want to merge, and the end cylinder of the second (if they are the last 2 partitions at the end of the drive, it shouldn't be necessary to note anything though).

-use 'd' to delete both partitions, one by one (don't "Commit" or "Write Partition Table" though). It will ask you which partition number, refer to partition table.

-use 'n' to create a new partition with the same start cylinder as the first partition and the same end cylinder as the second (again, if these were the 2 partitions on the end of the drive, using the default cylinders for the start and end of this new partition should do just fine).

-optionally, change partition's system id where appropriate, see 'm' command list. 'l' lists valid ids.

-use 'w' to write partition table

-remove second partition from /etc/fstab (assuming the first partition's entry is still valid, keep using it)

-reboot (I needed to before I could grow my xfs filesystems, might not be needed, but might be too, certainly needed if you get a message about the kernel still using the old partition table, which I expect you would if you have other partitions on the drive still mounted)

-grow filesystem on new partition to make use of new space.

Last edited by lurko; 05-26-2007 at 05:25 PM.
 
Old 05-27-2007, 02:29 AM   #6
kreon28
LQ Newbie
 
Registered: May 2007
Posts: 4

Original Poster
Rep: Reputation: 0
Ok, here it is, my fdisk -l. Maybe that would help:
Code:
Disk /dev/hda: 10.2 GB, 10242892800 bytes
255 heads, 63 sectors/track, 1245 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/hda1   *         1       812   6522358+   b  Win95 FAT32
/dev/hda2           955      1222   2152710   83  Linux
/dev/hda3          1223      1245    184747+   f  Win95 Ext'd (LBA)
/dev/hda4           813       954   1140615   83  Linux
/dev/hda5          1223      1245    184716   82  Linux swap

Partition table entries are not in disk order

Disk /dev/hdb: 2111 MB, 2111864832 bytes
64 heads, 63 sectors/track, 1023 cylinders
Units = cylinders of 4032 * 512 = 2064384 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/hdb1   *         1      1022   2060320+   b  Win95 FAT32
 
Old 05-27-2007, 04:52 AM   #7
jay73
LQ Guru
 
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019

Rep: Reputation: 130Reputation: 130
Why make it so difficult? Get a gparted LiveCD, delete the hda4 partition and then simply move the beginning of the extended partition to the right by dragging the left arrow to the right - the unallocated space will now be fully adjacent to your second primary partition. As a final step, resize/grow hda2 to cover the newly freed-up space. And don't forget that hd5 will become hda4 in the process - you will have to mod your /etc/fstab accordingly.

Last edited by jay73; 05-27-2007 at 04:57 AM.
 
Old 05-27-2007, 09:15 AM   #8
kreon28
LQ Newbie
 
Registered: May 2007
Posts: 4

Original Poster
Rep: Reputation: 0
Gparted did the job! Thank you very much!

Last edited by kreon28; 05-27-2007 at 09:36 AM.
 
Old 05-27-2007, 09:48 AM   #9
lurko
Member
 
Registered: Jun 2006
Location: Ontario, Canada
Distribution: Debian
Posts: 448

Rep: Reputation: 35
You need to grow the filesystem now. The command to grow it will depend on which filesystem you use. Here's a guide for growing ext3 filesystems (covers the partition merge too though). as jay73 says gparted or qparted can probably grow the filesytem for you. Googling "grow filesystem" where filesystem is the filesytem in question should readily produce answers.

I'm still confused by your partition table, how you have a hda3 extended partition and then a hda4 is beyond me. Sorry if I was just promoting paranoia earlier, I'm glad you seem to have things sorted (partition-wise anyway). Do you still have a swap partition on the end there?


@jay73: I was under the impression you couldn't move the startpoint of any partition, only the endpoint.

I think fdisk is as pretty much as simple as it gets. Any complexity I think is due to my being uncertain about the partition table in question(which hasn't changed really ).

edit: I am a slow poster! Glad you got it sorted kreon28

Last edited by lurko; 05-27-2007 at 09:49 AM.
 
Old 05-27-2007, 12:26 PM   #10
jay73
LQ Guru
 
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019

Rep: Reputation: 130Reputation: 130
Quote:
I was under the impression you couldn't move the startpoint of any partition, only the endpoint.
That is correct, as a rule you can't. However, the "extended" partition is something of an exception and you can move its start as much as you want providing there is some empty space to take up on whichever side you're moving it to.
 
  


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
Merging partitions? Jorophose Linux - Newbie 3 04-05-2007 06:23 PM
Merging Harddrive Partitions josegata Linux - Software 2 05-12-2006 06:30 PM
Merging Unalocated Partitions lramos85 Linux - Newbie 6 07-22-2004 02:29 PM
merging partitions question (RH9) LooseCanon Linux - General 2 10-02-2003 02:45 PM
Merging partitions Chrissi Linux - General 7 06-08-2003 08:36 PM


All times are GMT -5. The time now is 02:14 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration