How to create a new partition on a Linux Server

This article describes how to configure a new partition from free space on a dedicated server, or a virtual machine with full virtualization (such as VMware or XenServer):

  1. Verify the partitions available on the server: fdisk -l
  2. Choose which device you wish to use (such as /dev/sda or /dev/sdb)
  3. Run fdisk /dev/sdX (where X is the device you would like to add the partition to)
  4. Type ‘n’ to create a new partition.
  5. Specify where you would like the partition to end and start.  You can set the number of MB of the partition instead of the end cylinder.  For example:  +1000M
  6. Type ‘p’ to view the partition, and type ‘w’ to save the partition
  7. Run the command ‘partprobe’ to have the OS detect the new partition table.  If it still does not detect the partition table, you might need a reboot.
  8. Format the partition by doing:  ‘mke2fs -j /dev/sdaX’ – where X is the number of the partition you have created.
  9. Create a directory where you wish to mount the new drive, for example: /newpartition.  ‘mkdir -p /newpartition’
  10. To mount, you can use the following command: ‘mount /dev/sdaX /newpartition’
  11. If you would like the drive to be mounted automatically each time you boot, add the following to /etc/fstab: ‘/dev/sdaX /newpartition ext3 defaults 1 2’

Make sure you have backups before you perform any formatting, or creating new partitions!



  • Steve Smith

    Even though this article is ancient by tech standards – it super helped me out with a project this weekend. I made a few tweaks since I’m using EC2 instances. For example, I unmount the volume I’m working on at the end and mount it to a “recovery” instance so I can move directories around and not have the conflict of doing it on a live operating system. The command I use is: ‘sudo cp -rv –preserve=all /mnt/main/usr/* /mnt/usr/’. This command preserves all of the permissions and ownership of all of the files and directories (important if you want to use this for binaries – the first time I quickly found out that sudo and none of my binaries worked because they were no longer owned by root or didn’t have the setuid bit set anymore). I also start the process off with ‘sudo lsblk’ in addition to ‘sudo fdisk -l’.