Linux - NewbieThis 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!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
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
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.
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.
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.
-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.
Ok, here it is, my fdisk -l. Maybe that would help:
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
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.
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
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.