Make and format partitions on Linux

To format a drive with 1 or more partitions you need to

  • Make partitions on your drive
  • Format the partitions with your desired partition type

Make partitions

List drives with

fdisk -l

select your device you want to make your partitions (the size is a good indicator)

fdisk /dev/sdc
  • Press ‘m’ to have an overview of all the commands
  • Press ‘p’ to delete any unwanted partitions. To make sure you delete the right ones look at the partition numbers.
  • Press ‘n’ for a new partition.
  • Press ‘p’ for a primary partition. (A disk can have 4 primary partitions or 3 primary partitions and a extended partition. The extended partion is needed for any number of logical partitions or drives. Wiki-Link)
  • Press ‘1’ to select the first partition to be written
  • Type in +size{K,M,G} which is the size of your partition and looks like “+100M” . Do not forget the leading ‘+’
  • Press ‘p’ to see if your partition is planned to be written.
  • Press ‘a’ to make your partition bootable. Select 1 as your partition to be bootable.
  • Press ‘n’ to create another partition and hit enter to allocate the remaining space.
  • Press ‘w’ to write your partitions and exit fdisk.

Link for more partition options: click

Formatting the partitions

  • mkfs.ext2 /dev/sdc1 creates an ext2 partition on your first partition.
  • mkfs.ext4 /dev/sdc2 creates an ext4 partition on your second partition.

More information can be found here: click

 

Leave a Reply

Your email address will not be published. Required fields are marked *