How to create a new partition on a hard disk?
Solution 1
If you install GNU parted (libparted
), you get an extra command line progam parted
.
GNU Parted manipulates partition tables. This is useful for creating space for new operating systems, reorganizing disk usage, copying data on hard disks and disk imaging. The package contains a library, libparted, as well as well as a command-line frontend, parted, which can also be used in scripts.
Solution 2
- Backup every piece of data you can't afford to lose and don't do this on a mission-critical server.
-
umount
the partition you want to split into two or more parts. - Use
resize2fs
to free up the desired amount of space at the end of partition. - Launch
fdisk
.
Unfortunately, this tool doesn't have an option to change the size of partition. You'll need to delete it first and then create the desired new partitions on the unallocated space left from it.
First re-create the partition you've just deleted with lower amount of allocated space. Be sure to specify size enough to hold your resized filesystem. Allocate the rest of unused space as you see fit.
The fdisk
tool doesn't touch your partition table unless you specifically say it to do so. In case of mess up, just terminate it with ^C
and start over.
- Now that you have you new partitions setup, use an appropriate
mkfs
command to create new filesystems. Don't runmkfs
on the original partition number -- only on the new ones! - Take extra care at every step as you risk the need start over in case of mistyped command.
Related videos on Youtube
Navaneeth Sen
Updated on September 17, 2022Comments
-
Navaneeth Sen over 1 year
How do I create a new partition on a hard disk, from the terminal? I've been reading the
man
pages forfdisk
andmkfs
, but they're confusing. I need to know how to create a new partition on a blank drive, as well as on a drive that already has partitions. Some colleagues told me the latter isn't possible and I need to format; is that accurate?-
Gert over 13 yearsAre GUI applications allowed?
-
Navaneeth Sen over 13 yearsNo i want to do it from the command prompt
-
-
Navaneeth Sen over 13 yearsThanks for the reply, but i would like to know more about using fdisk and mkfs in getting this achieved.
-
Navaneeth Sen over 13 yearscan you give me the commands i should use for achieving the same?
-
alex over 13 years@Sen: sorry, no. You'll have to figure it out. Feel free to ask separate questions, specific to the command you'll trying to learn about. Like 'How do I use resize2fs?'
-
Louis Gerbarg over 13 yearsI'd like to add that there is a very good GUI called gparted for libparted (I know GUI's not allowed but it is still worth mentioning).