I’ll be asked for the hex code of the type. If I want to change its type, I can use the t command and specify the partition’s number. The n command I just ran recreated the swap partition I deleted earlier - or did it? If I run the p command again, I’ll see that the new /dev/sda5 partition is a “Linux” partition instead of a “Linux swap” partition. For example, +10000 results in the end of the partition being 10000 sectors after its beginning. If you don’t specify a unit after the + sign, fdisk uses sectors as the unit. You can also specify a specific size, such as +5G for a five gigabyte partition or +512M for a 512 megabyte partition.
If you want to use up all available space after the initial sector, just press Enter. Last, specify the last sector of the partition on the disk. Press Enter to accept the default sector, which is the first free sector on the disk. Next, specify the sector of the disk you want the partition to start at.
A disk can only have four primary partitions. You can create a logical or primary partition ( l for logical or p for primary). Use the n command to create a new partition. The partition appears deleted, but fdisk doesn’t write these changes to disk until you use the w command. For example, if I wanted to delete the partition at /dev/sda5, I’d type 5.Īfter deleting the partition, you can type p again to view the current partition table. You’ll be asked for the number of the partition you want to delete, which you can get from the p command. Use p to print the current partition table to the terminal from within command mode. Type m and press Enter to see a list of the commands you can use. In command mode, you use single-letter commands to specify actions you want to take. If you want to edit system partitions, boot from a live CD first. Don’t edit partitions while they’re in use.