linux - convert a logical partition to a primary partition

07
2014-04
  • ant2009

    Fedora 14 xfce

    I have the following partition setup. I would like to know how can I convert the logical partition sda6 to a primary partition.

    Disk /dev/sda: 320.1 GB, 320072933376 bytes
    255 heads, 63 sectors/track, 38913 cylinders, total 625142448 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x1707a8a5
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/sda1            2048     1026047      512000   83  Linux
    /dev/sda2         1026048   205844479   102409216   83  Linux
    /dev/sda3       205844480   214228991     4192256   82  Linux swap / Solaris
    /dev/sda4       214228992   625141759   205456384    5  Extended
    /dev/sda5       214231040   573562879   179665920   83  Linux
    /dev/sda6       573564928   625141759    25788416    7  HPFS/NTFS
    
    Filesystem            Size  Used Avail Use% Mounted on
    /dev/sda2              97G  5.0G   91G   6% /
    tmpfs                 494M  176K  494M   1% /dev/shm
    /dev/sda1             485M   68M  392M  15% /boot
    /dev/sda5             169G   26G  135G  16% /home
    
    # partition table of /dev/sda
    unit: sectors
    /dev/sda1 : start=     2048, size=  1024000, Id=83
    /dev/sda2 : start=  1026048, size=204818432, Id=83
    /dev/sda3 : start=205844480, size=  8384512, Id=82
    /dev/sda4 : start=214228992, size=410912768, Id= 5
    /dev/sda5 : start=214231040, size=359331840, Id=83
    /dev/sda6 : start=573564928, size= 51576832, Id= 7
    

    I would like to convert sda6 to a primary partition, the reason for this it to install windows 7 starter.

    Many thanks for any suggestions,

  • Answers
  • Mokubai

    With that partition layout you will not be able to change sda6 to a primary partition without first deleting both sda5 and sda4 (the extended partition itself) as you can only have a maximum of 4 primary partitions on a drive. This is a limitation of how drives are partitioned and is why you end up with extended (logical) partitions in the first place.

    http://en.wikipedia.org/wiki/Disk_partitioning

    The total data storage space of a PC hard disk can be divided into at most four primary partitions, or alternatively three primary partitions and an "extended partition". These partitions are described by 16-byte entries that constitute the Partition Table, located in the master boot record.

    The best you can do is delete sda4, sda5 and sda6 and create the primary partition in the emptied space.

    Alternatively you could just buy a new drive to install Win7 on.

  • Hello71

    You can't. There are already 3 primary partitions plus one extended partition on the disk. In any case, there's no reason why Windows 7 (or any >NT version of Windows) won't/can't install on a logical partition.

  • Neal

    Windows does not need to be installed onto a primary partition. It does however need to have a primary partition onto which it can put its boot stuff.

    If you can live without the separate Linux boot partition, I would suggest moving the Linux boot stuff from its own partition (/dev/sda1) to / (/dev/sda2), formatting sda1 as ntfs (and mark it as being active), and then installing Windows onto /dev/sda6: the Windows installer should be quite happy to do it.

    (As an example I've just created a Virtual machine, and, on the hard disk made a primary 512MB partition (marked active and formatted as ntfs) and an extended partition containing one logical partition formatted as ntfs. Windows XP installed quite happily on the logical partition.)


  • Related Question

    linux - Fix bad superblock on logical partition
  • Chris

    I was following http://www.howtoforge.com/linux_resi...xt3_partitions and when i reboot and run:

    root@Microknoppix:/home/knoppix# fsck -n /dev/sda7
    fsck from util-linux-ng 2.17.2
    e2fsck 1.41.12 (17-May-2010)
    fsck.ext2: Superblock invalid, trying backup blocks...
    fsck.ext2: Bad magic number in super-block while trying to open /dev/sda7
    
    The superblock could not be read or does not describe a correct ext2
    filesystem. If the device is valid and it really contains an ext2
    filesystem (and not swap or ufs or something else), then the superblock
    is corrupt, and you might try running e2fsck with an alternate superblock:
    e2fsck -b 8193 <device>
    

    so i ran e2fsck with all the block numbers that you need (forget exactly what tool i used to find where the superblocks are hidden) no dice

    then i ran testdisk and had it look for the superblock, no results

    anyone have any ideas?

    fdisk -l for reference:

    root@Microknoppix:/home/knoppix# fdisk -l
    
    Disk /dev/sda: 320.1 GB, 320072933376 bytes
    255 heads, 63 sectors/track, 38913 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x97646c29
    
        Device Boot      Start         End      Blocks   Id  System
    /dev/sda1               1          64      512000   83  Linux
    Partition 1 does not end on cylinder boundary.
    /dev/sda2              64       38912   312046593    f  W95 Ext'd (LBA)
    /dev/sda5              64         326     2104320   82  Linux swap / Solaris
    /dev/sda6   *         327        2938    20972544   83  Linux
    /dev/sda7            2938       38912   288968672+  83  Linux
    

    To be honest it looks like I lost it... Next step if that happens is to dump the partition to an image file and hope i can find or write some software to parse through the data looking for known file headers, i think.


  • Related Answers
  • Dario

    The link you posted doesn't work, so I'm not quite sure what you where trying to do here, but you should not run fsck / e2fsck on an extended partition. e2fsck is used to check ext2 and ext3 partitions.

    This warning

    The superblock could not be read or does not describe a correct ext2 filesystem. If the device is valid and it really contains an ext2 filesystem (and not swap or ufs or something else), then the superblock is corrupt, and you might try running e2fsck with an alternate superblock: e2fsck -b 8193

    means that the partition is not an ext2 / ext3 partition.

    If you forced the check it might even have caused some damage, and maybe that's why you "lost it".

    Anyway I hope you didn't loose any important data.