How To Create Unformatted Partition

I needed to create an un-formatted partition of X MB on a disk.  I don't want it from GUI but from command line not sure what should be specified for fdisk.
 
Answer:
 
Please check your own OS information first. Commands and options for fdisk utility varies from OS to OS. 

Here's what I would do on a RHEL system to create 30MB partition! 

Code:
 
[root@testserv-sl6 ~]# fdisk /dev/sdb
 
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
 
         switch off the mode (command 'c') and change display units to
 
         sectors (command 'u').
 
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): p
 
Disk /dev/sdb: 8589 MB, 8589934592 bytes
 
255 heads, 63 sectors/track, 1044 cylinders
 
Units = cylinders of 16065 * 512 = 8225280 bytes
 
Sector size (logical/physical): 512 bytes / 512 bytes
 
I/O size (minimum/optimal): 512 bytes / 512 bytes
 
Disk identifier: 0x00092e03
 
   Device Boot      Start         End      Blocks   Id  System
 
/dev/sdb1               1         244     1953125   83  Linux
 
Partition 1 does not end on cylinder boundary.
 
/dev/sdb2             244         487     1952768   83  Linux
 
Partition 2 does not end on cylinder boundary.
 
/dev/sdb3             487         730     1952768   83  Linux
 
Partition 3 does not end on cylinder boundary.
 
/dev/sdb4             730        1045     2529280   83  Linux
 
Command (m for help): d
 
Partition number (1-4): 1
 
Command (m for help): d
 
Partition number (1-4): 2
 
Command (m for help): d
 
Partition number (1-4): 3
 
Command (m for help): d
 
Selected partition 4
 
Command (m for help): p
 
Disk /dev/sdb: 8589 MB, 8589934592 bytes
 
255 heads, 63 sectors/track, 1044 cylinders
 
Units = cylinders of 16065 * 512 = 8225280 bytes
 
Sector size (logical/physical): 512 bytes / 512 bytes
 
I/O size (minimum/optimal): 512 bytes / 512 bytes
 
Disk identifier: 0x00092e03
 
   Device Boot      Start         End      Blocks   Id  System
 
Command (m for help): n
 
Command action
 
   e   extended
 
   p   primary partition (1-4)
 
p
 
Partition number (1-4): 1
 
First cylinder (1-1044, default 1): 1
 
Last cylinder, +cylinders or +size{K,M,G} (1-1044, default 1044): +30M

Command (m for help): p 
 
Disk /dev/sdb: 8589 MB, 8589934592 bytes
 
255 heads, 63 sectors/track, 1044 cylinders
 
Units = cylinders of 16065 * 512 = 8225280 bytes
 
Sector size (logical/physical): 512 bytes / 512 bytes
 
I/O size (minimum/optimal): 512 bytes / 512 bytes
 
Disk identifier: 0x00092e03
  
   Device Boot      Start         End      Blocks   Id  System
 
/dev/sdb1               1           5       40131    5  Primary
 
Command (m for help): w

See Also
RAID (Redundant Array of Inexpensive/Independent Disks)

Have a Unix Problem
Do you have a UNIX Question?

Unix Books :-
UNIX Programming, Certification, System Administration, Performance Tuning Reference Books

Return to : - Unix System Administration Hints and Tips

(c) www.gotothings.com All material on this site is Copyright.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
All product names are trademarks of their respective companies.
The site www.gotothings.com is in no way affiliated with or endorsed by any company listed at this site.
Any unauthorised copying or mirroring is prohibited.