LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   How can I create extended partition without GParted? (https://www.linuxquestions.org/questions/linux-hardware-18/how-can-i-create-extended-partition-without-gparted-619970/)

saikee 02-10-2008 06:46 AM

Find out what you have got first by terminal command

Code:

su
or
Code:

sudo su
followed by root password if needed. Then post the output of
Code:

fdisk -l
It is the PC standard that a hard disk can only have 4 primaries. If more partitions are needed you must give up one primary for converting it into an extended partition. Linux supports 11 logical partitions but with older kernel versions you can get 59 logical partitions out of a Pata disk.

Both fdisk and cfdisk are part of the CLI. Red Hat family Linux, like Fedora, uses sfdisk in lieu of cfdisk. I don't recall not finding fdisk any of the Linux I tried.

alan_ri 02-10-2008 06:56 AM

Output of the fdisk -l is "unable to seek on /dev/hda".

saikee 02-10-2008 07:39 AM

This to me is the kernel cannot read the hard disk, a sign of hardware trouble.

If this is the case then every operating system you have in the hard disk will have the same trouble with it.

Since you want more OS and have 4 primaries presumably you can boot the OS in any of the primaries to see if it can read the hard disk.

Lastly you can boot up a Linux Live CD and get a third opinion, by issuing the same CLI command "fdisk -l" with another Linux. You would be using a different kernel and a different version of fdisk. I think the most up to date versions of cfdisk and fdisk can be found in Parted Magic, which is a downloadable Live CD using the latest Gparted engine.

In my experience "fdisk" is the most robust of all partitioning programs. It will still be able to read the partition table when all the others fail. It is usually the last line of defence in dealing with problematic hard disk. Thus if fdisk cannot seek it then I would worry about the health of the disk.

I notice in a previous post you didn't get a response from fdisk. You can also try "cfdisk /dev/hda".

alan_ri 02-10-2008 08:22 AM

I have booted the live cd with Damn small on it.This is the output from fdisk -l:

Disk /dev/hda: 80 GB,80026361856 bytes,255 heads,63sectors/tracks,972 cylinders
Units = cylinders of 16065x512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/hda1 1 1824 14651152+ 83 Linux
/dev/hda2 * 1944 3621 13478535 7 HPFS/NTFS
/dev/hda3 3622 8201 36788787 f Win95 Ext'd (LBA)
/dev/hda4 1825 1873 393592+ 82 Linux swap
/dev/hda5 4851 8201 26916907+ b Win95 FAT32
/dev/hda6 3622 4791 9397962 83 Linux
/dev/hda7 4792 4850 473886 82 Linux swap

Why I can't see this in Mandriva.I was running fdisk as root.
I must say this:Window$ are here only because of my brother.
Oooh,do I already have extended partition?Now I can see it,I didn't now it was there.
What do I do now to be able to boot one more system?

jay73 02-10-2008 08:56 AM

Well, if all the space is taken up, you'd have to create some empty space first. You could do that be deleting or shrinking one of the existing partitions. Just bear in mind that this may result in your partitions being renumbered, which can lead to booting and/or mounting issues for operating systems that are already installed. Just make sure that hda6 doesn't change numbers or that it uses something like labels to find its partition(s).
Looking at your partition table, I would guess that your fat32 partition is the best candidate as it appears to be the largest one. Download and burn the gparted livecd to do the resizing. However, this will be and extended partition. Linux is just fine with that but most operating systems (windows, os x, bsd, solaris, ...) absolutely need a primary one in order to be bootable. So if you're not going to install a Linux, using an extended partition is not going to be very helpful.

saikee 02-10-2008 09:10 AM

See what I mean?

Many posters tell lies! Just joking.

I suspect you have two Linux distros there already as you got two swap partitions.

The hda5 appears to be illegal and that may be the reason why Mandriva rejected the disk.

Don't really know what you are after now as your original question has been answered but you want something else now.

The trouble is we do not know how many systems you have got and suspect you have no idea either, yet you want more OS and don't care about the consequence of hda5.

In my view many Linux would not like your hard disk and may refuse to touch it because logical partitions must be in a continuous chain. In a normal circumstance it should be impossible for hda5 to wedge in before hda6 as it is physically at the end of the hard disk. My guess is you or someone has used a partitioning tool that does not understand logical partitions and Linux to create hda5, making its partition table illegal to Linux.

A Logical partition carries the hard disk address for next logical partition and the last one should have cylinder number matching the boundary defined by the extended partition.

In other word I am saying unless you fix the hard disk's illegal problem first you could be wasting time to add additional OS to the hard disk. Also an OS needs a partition to reside in and hard disk space doesn't grow on trees. Thus you must have an empty partition available or unallocated empty space in the hard disk before adding an OS is possible.

DSL reads it because DSL is not a full blown Linux with the latest full sized kernel.

-------------(Edited)-------------------
jay73 has beat me to it so I might as well suggest a cure

If you use fdisk, sourced say from DSL, to delete hda5 assuming it is empty after the data has been transferred elsewhere then after a reboot Mandriva will read the disk again and your previous hda6 and hda7 should revert to hda5 and hda6. This should make the Linux you installed in hda5 bootable again if that is what you have done.

If the above is confirm then using Linux to create a logical partition on space left by the previous hda5 you should find it named as hda7. Thereafter you can install an OS in it.

You don't have to use all the space for hda7 and can have more logical partition until you reach hda15. My guess is if you run Mandriva hda should be called sda unless your Mandriva has a kernel older than 2.6.20.

alan_ri 02-10-2008 09:44 AM

Now I did the booting with Knoppix 5.1:

Disk /dev/hda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hda1 1 1824 14651152+ 83 Linux
/dev/hda2 * 1944 3621 13478535 7 HPFS/NTFS
/dev/hda3 3622 8201 36788787 f W95 Ext'd (LBA)
/dev/hda4 1825 1873 393592+ 82 Linux swap / Solaris
/dev/hda5 4851 8201 26916907+ b W95 FAT32
/dev/hda6 3622 4791 9397962 83 Linux
/dev/hda7 4792 4850 473886 82 Linux swap / Solaris

Partition table entries are not in disk order.

I dont now why is showing Solaris now.Anyway,I used GParted in Knoppix just to see the output and it show me that my /dev/hda is unallocated.
Window$ and 2 Linuxs are working just fine./dev/hda3 is extended partition so what do I do to make another partition to boot another OS.I want to install Linux and I have 11GB of free space.I don't wanna do this with GParted,I wanna do it from the command line,to learn how it's done.I don't think my question is answered.I did't know I had extended partition,but even so I still don't know how to make one from the command line and how to make logical partition also.
Thanks for all the help!
I did't saw what you wrote under edited,I must say that /dev/hda5 is the Windows D drive and is the most sensitive drive at the moment(in meaning of files allocated there),is it safe to transfer all the data from there to Linux partition with "cp"?

syg00 02-10-2008 04:33 PM

Easiest is to use cfdisk to create another (logical) partition - highlight the free space, and use "New". Should be reasonably obvious what to do (make it type 0x83). cfdisk will resize the extended partition automagically for you.

That part is easy. You may (still) not be able to install a Linux if it insists on a primary partition. Fedora (and maybe Ubuntu) do this on a "normal" install.
Manual (expert ???) install may be required to enable you to choose which partition(s) to install into. Depends on the distro.

@saikee - what is your concern with hda5 ???.

saikee 02-10-2008 04:38 PM

Alan,

I could have been wrong in condemning your partition table being illegal as I have assumed you had created your logical partitions in an orderly fashion, from top to the bottom.

Since Knoppix reads it, making it legal because Knoopix can understand it, I now realise you might have when creating hda5 tell the partitioning software to use the space from the bottom up of the extended partition. While installing the second Linux its installer used the space from the top down to create hda6 and hda7, as it is normal to use the hard disk space from the top to the bottom.

This explains why hda5's boundary is between cylinder 4851 to 8201 whilst hda6 boundary commences at cylinder 3622, the same starting point of your Extended partition hda3.

If you are unable to remove hda5 then there is a limited scope of things you can do. Unless you are preparing to cheat and good with using Grub the Linux boot loader then every PC user can only have one extended partition in a hard disk. You have already used up your extended partition and it is now in hda3 so no more extended partition can be created. It is the PC standard. If you manage to change to more than one extended partition neither Linux nor MS system would work with it.

Here is my suggested cure to get another OS in to your hard drive.

If you want to install another system you could

(1) delete hda4 and amend the Linux that uses it to switch to hda7. The hard disk vacated by hda4 is very difficult for reuse. Cylinders from 1825 to 1873 become dead space. Your hard disk currently also has dead space behind hda1, as cylinder 1874 to 1944. You could at a later date use Gparted to make hda1 or hda2 to absorb the dead spaces.

(2) You have at the end of the extended parition between 9729-8201 = 1528 cyclinders which amount to about 11 to 12 Gb unallocated space. This is because the 80Gb hard disk has 9729 cyclinders whereas the maximum entry used in your partition table, at the end of hda3 (or hda5) is cylinder 8201. Therefore if the hda4 is deleted you can use the last 1528 cylinders of the hard disk for the creation of a new hda4. Just type "cfdisk /dev/hda" and you will see the space usage of your hard disk.

Lastly a partition has a type number or ID. Type 82 is for swap but has been also used for Solaris. Current Solaris uses type bf now. The partition type has not been changed. It is just different versions of fdisk showing different text of explanations.

alan_ri 02-10-2008 05:46 PM

syg00 & saikee,this 2 last replies are so much helpful.I see some things clearer now,thanks.syg00,my concern about hda5 is because my brothers important and private files are there,and that is the only thing he had asked me not to delete,so I always had to be very careful with that whenever I was doing something with Linux,BSD etc.(I learned a lot more that way). Is this true now; I have /dev/hda1 Linux(btw.Mandriva)-primary partition /dev/hda2 Windows (C drive)-primary partition /dev/hda3 Extended partition(no more ex. ptt. possible) /dev/hda4 swap-logical partition /dev/hda5 Windows(D drive)-logical partition /dev/hda6 Linux (Parsix)-primary partition /dev/hda7 swap-logical partition and as I remember 550MB and 11GB unallocated space,and I will do as you saikee suggested(hda4),I just need a new logical partition for my new Linux and for any other in the future.

alan_ri 02-10-2008 06:04 PM

I tried cfdisk /dev/hda in Mandriva and this is the output: FATAL ERROR: Bad logical partition 6: Press any key to exit cfdisk. Is this the reason why Mandriva only let me boot Windows and not Parsix,but Parsix worked just fine before I installed Mandriva few days ago.Last time,fdisk and cfdisk on Mandriva didn't work,I really don't understand this.

saikee 02-10-2008 06:19 PM

You don't have to use Mandriva to re-organise the partition table. Any Live CD will do but it is preferable to have a partition that every Linux is happy with. If you have DSL and Knoppix accepting the partition table that is good enough.

cfdisk is weaker than fdisk so you can try "fdisk /dev/hds" and use it to delete hda4. It is quite possible fdisk will work.

Your interpretation of your partitions is correct. It is probable that hda4 is currently being used by Mandriva as a swap. There will be an entry of it in /etc/fstab of the Mandriva partition hda1. You should change the entry hda4 there to hda7 so that after hda4 has been deleted Mandriva will still operational and when it has to use a swap it goes to hda7.

If you create a new partition now it will only be a primary and it will be hda4 after you first delete it.

You have virtually sealed the expansion possibility of your extended partition by putting hda5 at the front. Had you arranged everything in a top to bottom order, with the cylinders in ascending order, then the remaining unallocated 11 to 12 Gb space will be expandable from the end of the extended partition to become hda8, hda9 etc.

alan_ri 02-10-2008 06:31 PM

I understand you saikee,and I will do it as you suggested.You are going to my buddy list,and I'm so sorry I can't buy you a drink now. Mandriva fdisk /dev/hds - unable to open /dev/hds,but I will try with Knoppix.


All times are GMT -5. The time now is 03:27 PM.