Partition Hard Disk using fdisk command on Linux Fedora system

Step by step procedure to Partition Hard Disk on Linux Fedora using fdisk command

 

   The step by step example below use fdisk command to make new partition on new external USB hard disk.  The example below show step by step partitioning hard disk drive using fdisk command on Linux Fedora. The aim from this fdisk command is to make new partition on 40 G external USB hard disk.  Make sure you login as root user or use the su command, otherwise you may not be able to run certain command that show in the example below.

 

1.  Insert USB hard disk to the Linux Fedora system, verify and get the device name e.g sdb device (for second hard disk device on the system) as show on article "Step by step how to check external USB hard disk drive name on Linux Fedora".

 

2.  Make sure you get the external USB device name, use the device name to replace the external USB device name that I use on the example below

Please note: The sdb is the device name for my external USB hard disk... replace with the device name to fit your system configuration.  The mistakes that you made here (specify the right name for hard disk device) can result total data lost and feel disappointed for about a month or the rest of your life :-) ...

 

3.  Open Linux terminal and start type the fdisk command as shown on example below, to invoke fdisk tool to start partitioning process; if you not log in as root user, replace the fdisk /dev/sdb with su - -c "fdisk /dev/sdb" command and you may need to enter the root password.

Partition Hard Disk on Linux Fedora using fdisk command

[root@fedora ~]# fdisk /dev/sdb

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel with disk identifier 0xef6614b7.

Changes will remain in memory only, until you decide to write them.

After that, of course, the previous content won't be recoverable.

 

 

The number of cylinders for this disk is set to 38154.

There is nothing wrong with that, but this is larger than 1024,

and could in certain setups cause problems with:

1) software that runs at boot time (e.g., old versions of LILO)

2) booting and partitioning software from other OSs

   (e.g., DOS FDISK, OS/2 FDISK)

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

 

Command (m for help):

 

Fdisk Command Help

 

4.  First rules of fdisk command, remember the 'm' key:  Type in m key and hit Enter key to get the fdisk tool help messages..

Command (m for help): m

Command action

   a   toggle a bootable flag

   b   edit bsd disklabel

   c   toggle the dos compatibility flag

   d   delete a partition

   l   list known partition types

   m   print this menu

   n   add a new partition

   o   create a new empty DOS partition table

   p   print the partition table

   q   quit without saving changes

   s   create a new empty Sun disklabel

   t   change a partition's system id

   u   change display/entry units

   v   verify the partition table

   w   write table to disk and exit

   x   extra functionality (experts only)

 

Command (m for help):

 

Display List of Partition

 

5.  Hit the 'p' key to display existing partition table on the USB disk

Command (m for help): p

 

Disk /dev/sdb: 40.0 GB, 40007761920 bytes

64 heads, 32 sectors/track, 38154 cylinders

Units = cylinders of 2048 * 512 = 1048576 bytes

Disk identifier: 0x836cebc0

 

   Device Boot      Start         End      Blocks   Id  System

 

Command (m for help):

 

Delete Partition, Create New Partition

 

6.  To delete partition, use the 'd' key if you want to delete the existing partition if you need to, if not proceed with the 'n' to create new partition on the external USB disk

Command (m for help): n

Command action

   e   extended

   p   primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-38154, default 1):

Using default value 1

Last cylinder or +size or +sizeM or +sizeK (1-38154, default 38154):

Using default value 38154

 

Command (m for help):

 

View Partition Table Created

 

7.  Use the 'p' command again to verify the partition table

Command (m for help): p

 

Disk /dev/sdb: 40.0 GB, 40007761920 bytes

64 heads, 32 sectors/track, 38154 cylinders

Units = cylinders of 2048 * 512 = 1048576 bytes

Disk identifier: 0x836cebc0

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1       38154    39069680   83  Linux

 

Command (m for help):

 

Write Partition Table to Hard Disk

 

8.  Use 'w' command to write the partition table to disk and exit the fdisk tool:

Command (m for help): w

The partition table has been altered!

 

Calling ioctl() to re-read partition table.

Syncing disks.

[root@fedora ~]#

 

Verify and list partition table

 

Verify the partition table that we create earlier is write to disk, and list the partition table available and partition that can be use.

[root@fedora ~]# fdisk -l /dev/sdb

 

Disk /dev/sdb: 40.0 GB, 40007761920 bytes

64 heads, 32 sectors/track, 38154 cylinders

Units = cylinders of 2048 * 512 = 1048576 bytes

Disk identifier: 0x00b4c6f2

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1       38154    39069680   83  Linux

[root@fedora ~]#

 

In order to start using the USB hard disk drive as storage system on Linux Fedora system you may need to format the hard for file system, if you plan to use the external USB disk only on Linux system you may need to format the disk with ext3 filesystem or if you want to make the USB hard disk portable between Linux Fedora and Windows XP or other Windows operating system, you have to consider to format the external USB hard disk drive to use the vfat filesystem.

 

Keywords: partition hard disk, partition, hard disk partition, linux hard disk partition, partition linux hard disk, using fdisk, linux partition, make linux partition

 

1 comment

22
Dec

If you are under Windows, you

If you are under Windows, you can use Easeus partition manager, which is free, to create a partition on a hard disk.