0

I'm trying to do a triple boot with Windows, Ubuntu and Kali. Yet I already have 4 partitions in my SSD. These are:

  1. 100 MB NTFS (System, Active, Primary Partition)
  2. Windows C: (Boot, Page File, Crash Dump, Primary Partition)
  3. 824 MB (Recovery Partition)
  4. 25 GB (Primary Partition) – This is Ubuntu installed.

I'm aware of the Windows and Ubuntu partitions, but of the other two I've no idea why they are in separate partitions instead of with the Windows. How can I "merge" these partitions together to be able to create another one for Kali? Or is it impossible unless I uninstall Ubuntu or Windows?

Selecting the free partition:

image 1

Selecting the guided free partition option which takes the biggest free space automatically:

image 2

6
  • 2
    Use GPT instead of MBR. You can't merge those partitions they must be separate
    – Ramhound
    Apr 16, 2016 at 19:32
  • 1
    This is likely because of how you partitioned the drive but you didn't share any details, DOS MBR allows for 4 primary partitions, or 3 primary and 1 extended partition for a total of 15 partitions (which is an OS limitation implemented in most OS's such as Windows and Linux). Switching to a GPT partition table requires UEFI and technically allows for unlimited partitioning but it is limited to 128 by Windows and most other OS's.
    – acejavelin
    Apr 16, 2016 at 19:53
  • How can I switch to a GPT partition table? I bet my configuration is MBR because it wont let me have any more partitions. Or how can I create an extended partition? Apr 16, 2016 at 19:58
  • @Silvestrini you can't just convert... Move partitions to another drive, rebuild partition table, then move them back. Google is your friend here. You could just delete the Ubuntu partition, make an extended partition, and add your needed partitions as logical ones.
    – acejavelin
    Apr 16, 2016 at 21:51
  • Consider using LVM for your linuxes. It will allow resizing/creating/deleting volumes (something like partitions) with less hassle. In that case you may still need a separate partition for /boot.
    – Martian
    Apr 20, 2016 at 9:22

2 Answers 2

0

Both the 100MB NTFS and the 824MB partitions are automatically created by Windows.

The first one keeps important files in order to allow your computer to boot in recovery mode (as mentioned here), and the second one stores small backups of your system, so you can go to a restore point in case your Windows starts having problems.

You can't delete any of them, or you may have problems booting your Windows partition. Reinstalling Windows won't make any difference, since those two partitions are always there.

If you want to install Kali, you'll have to reduce the space in either your main Windows C: partition (which will probably require moving partitions to the left/right), or the 25GB Ubuntu one.

8
  • I tried shrinking the Windows volume to create a partition for Kali. But when I try to install Kali, it wont let me use the Unallocated space I made. Why would this happen? Apr 16, 2016 at 19:43
  • @Silvestrini Does it give you any error when you try to use that unallocated space?
    – Hewbot
    Apr 16, 2016 at 19:44
  • No, it wont give me an option to format that specific partition. When I select it, it just lets me see information about the partition's location. On the other partitions it gives me the option to format etc. Apr 16, 2016 at 19:45
  • @Silvestrini Would you mind updating your post with a picture of the partitioning tool in Kali's installation program?
    – Hewbot
    Apr 16, 2016 at 19:48
  • I posted two pictures of the installation with Kali. Apr 16, 2016 at 20:16
0

It is very likely you have four primary partitions. Output from Ubuntu's sudo fdisk -l /dev/sda (replace sda with proper name if necessary) would be very useful, but I'll try to help without it.

As for now I can suggest a general scenario to cope with your problem. Have in mind I haven't tested it as a whole.

Having no fdisk output yet, I will make some assumptions. We can correct them later eventually. The assumptions are:

  • the drive is /dev/sda in Linux;
  • it has DOS MBR, not GPT;
  • each of four partitions is a primary partition;
  • logical sector size is 512 B;
  • partition numbers correspond to your numbered list;
  • partition order and numbers match (sda1 precedes sda2 and so on);
  • the bootloader is grub2.

Just like acejavelin said:

DOS MBR allows for 4 primary partitions, or 3 primary and 1 extended partition

The aim is to „convert” your Ubuntu's primary partition to logical partition within extended partition. Kali's partition will be added later as the next logical partition within the extended partition.

Preparing

  1. Read whole my answer before you start, to get the whole picture. Some steps may be skipped depending on your current partition alignment and your desired partition alignment; i mean messing with Windows mostly.
  2. Backup your important data.
  3. Read twice, think twice, check your numbers three times – then do.
  4. Get any decent Live CD/DVD Linux – e.g. Knoppix or Ubuntu installer (in Try Ubuntu mode; maybe Kali installer has such a mode also, I don't know). Most important is to have gparted. Your already installed Ubuntu is no use here, because we cannot have its partition mounted at the time.
  5. If you need to resize Windows partition (see Moving Partitions section), boot into Windows and run chkdsk on C:. It will probably require restart, so restart and boot back into Windows.
  6. Again, if you need to resize Windows partition, press WIN+R on your keyboard and type shutdown -s -t 0, press enter. Do not boot again to Windows until you resize its partition. If it happens by accident, shutdown with said command. (This step may be important on Windows 8, 8.1, 10 to shut it down completely. It will do no harm regardless of version, so do it anyway.)
  7. Boot into Ubuntu. Check whether the /etc/fstab and /boot/grub/grub.cfg refer to partitions by /dev/sdaX or by UUID. Every occurrence of /dev/sda4 will have to be replaced by /dev/sda5 later and we will get to it. References by UUID should be problem-free.

Moving Partitions

Boot Linux from Live CD. If the Live CD of your choice automounts /dev/sda*umount them.

Run sudo gparted /dev/sda. If my assumptions are correct, it will show:

  • tiny sda1 at the beginning,
  • large sda2 with Windows right next to sda1,
  • small sda3 following sda2,
  • finally sda4 with Ubuntu near or at the end.

I don't know where you have left place for Kali. Probably it is at the very end, just after Ubuntu; or just before.

gparted lets you queue the operations, so you can cancel anyone of them before you do some real change.

Do not touch sda1. Do not touch the beginning of sda2. Doing otherwise may render your Windows unbootable. You can shrink Windows partition by moving the end of sda2 and it should not affect the boot. Do it if you want to gain more space for Kali and/or Ubuntu. In that case move also sda3 so there is no free space between sda2 and sda3.

Move/resize Ubuntu's sda4 so there is 1 MB gap (free space) between sda3 and sda4 This gap is essential. Leave space for Kali at the very end of the disk.

Note: I think we need the gap to be just one sector only, so 1 MB is a lot more than enough; gparted may make it even bigger. Unfortunately this tool works with megabytes, not sectors. Command line tool parted can work with sectors but it is less friendly and probably cannot resize ntfs – that's why i chose gparted.

Apply all the changes and wait for the result. Moving partitions needs time.

Hopefully it will go well. Do sanity check by booting to Ubuntu, Windows. It is expected that chkdsk will run on resized Windows partition.

Creating Extended and Logical Partition

Boot from Live CD/DVD again. Save your MBR (Master Boot Record, it contains partition table) to a file:

sudo dd if=/dev/sda of=~/mbr.dd bs=512 count=1

In case you make some error, you can restore the partition table with:

sudo dd if=~/mbr.dd of=/dev/sda

Unfortunately the MBR backup is not enough when it comes to logical partitions, yet it can minimize the damage to primary partitions if you mess with them. From now on be extra careful.

Run sudo fdisk /dev/sda; it is interactive with its own set of commands. Changes are saved to disk with w command, not earlier. In case of trouble quit with q command and start over.

Being inside fdisk invoke p command to see partition table. Write down (on paper) the start and the end sector of /dev/sda4, since it is the primary partition we need to delete and then recreate as logical. Verify your notes three times.

The start sector of /dev/sda2 may be by one greater than the end sector of /dev/sda1; that means there is no gap between them. The same applies for sda3 and sda2 pair. However there should be a gap between sda4 and sda3. Get the end sector of /dev/sda3, add one and write the result down as extended start. Verify the numbers three times. Make sure that it is a smaller number than the start of sda4.

Delete the partition number 4 with d command. Note that it would not really destroy your Ubuntu, even if you wrote the change to disk right now. Data is still there, fdisk has only lost track of where the partition was. You will recreate it as logical partition in a few moments.

Make new partition with n command; let it be extended partition. fdisk will suggest a start sector with the number being exactly your extended start value – check if it matches, hit enter if so. Then it will suggest an end sector as the last usable sector of the disk – it's the right thing, hit enter.

Again, make new partition with n command. It will be logical partition with number 5. Give the start and the end sector exactly as they were for original sda4 partition.

You may notice that these numbers make sda4 partition include sda5. That is correct, logical partitions must all lay inside extended partition. Kali Linux should be able to create its own extended partition(s) inside sda4 since there is space left.

The new partition table is still in memory only (disk is not yet affected). Examine it with p command. Before you write it with w, triple check a few things:

  1. sda5 should show ID=83 by default; that value is right for Linux. Use t command to change it to 83 if it's different.
  2. sda5 should show start and end sectors as they were for original sda4.
  3. The new sda4 should start at the sector just after the last sector of sda3; that number should be less than sda5 start sector.

The 3rd position on the above list is very important. In a moment you will write changes to disk. Information about partitions 1-4 will be stored into MBR. This change can be reverted with MBR backup we have made. But the information about logical partition sda5 will be stored at the beginning of the extended partition sda4. It is crucial that sda4 starts in a right place where there is no data – that is the gap we created. If you miss that gap you may lose some data in a moment.

Having it all triple checked, invoke w command to write changes to disk. fdisk should tell kernel about the new partitions, so there should be /dev/sda5 available to mount. This is now your Ubuntu.

(In case there is no /dev/sda5 node, try sudo partprobe to fix it.)

Updating Files (if needed)

At the beginning I suggested to check if your Ubuntu fstab and/or grub.cfg uses /dev/sda4 instead of UUID. Old sda4 will be sda5 from now on, so the files may have to be updated. I think it is safe to do, even if the files do not mention sda4, so when in any doubt do it. First mount:

sudo mount -o rw /dev/sda5 /mnt

You will find those files as /mnt/etc/fstab and /mnt/boot/grub/grub.cfg. Do not confuse with /etc/fstab which belongs to Live CD Linux and has nothing to do with your Ubuntu. Make a backup just in case and replace every sda4 with sda5. This can be done by one command:

sudo sed -i.backup 's/sda4/sda5/' /mnt/etc/fstab /mnt/boot/grub/grub.cfg

Finally reboot and check if both systems boot as they should. Kali Linux should now be able to utilize free space during install.

Not the answer you're looking for? Browse other questions tagged .