Create a partition

From Linuxintro

To create a partition in your Linux system, open a console and proceed like this:

# hwinfo --block --short
disk:                                                           
  /dev/sda             INTEL SSDSC2MH12
  /dev/sdb             ST31000528AS
  /dev/sdc             Generic SD/MMC
  /dev/sdd             Generic Compact Flash
  /dev/sde             Generic SM/xD-Picture
  /dev/sdf             Generic MS/MS-Pro
  /dev/sdg             SMI USB DISK
partition:
  /dev/sda1            Partition
  /dev/sdb1            Partition
cdrom:
  /dev/sr0             HL-DT-ST DVD+-RW GH50N
# fdisk -l /dev/sdg

Disk /dev/sdg: 4026 MB, 4026531840 bytes
124 heads, 62 sectors/track, 1022 cylinders, total 7864320 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x5d170100

Disk /dev/sdg doesn't contain a valid partition table
# fdisk /dev/sdg
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x48b9a664.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

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

Command (m for help): p

Disk /dev/sdg: 4026 MB, 4026531840 bytes
124 heads, 62 sectors/track, 1022 cylinders, total 7864320 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x48b9a664

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-7864319, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-7864319, default 7864319): 
Using default value 7864319

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.