cmdref.net - Cheat Sheet and Example

cmdref.net is command references/cheat sheets/examples for system engineers.

User Tools

Site Tools


Sidebar








Etc


Reference














.

os:linux:command:fdisk.html



Linux Commands Cheat Sheet

fdisk : How to use fdisk command in Linux with examples

Check partition

# fdisk -l

Disk /dev/sda: 146.7 GB, 146773311488 bytes
255 heads, 63 sectors/track, 17844 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          14      104448   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              14         275     2096512   82  Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/sda3             275       17845   141131072   83  Linux
Partition 3 does not end on cylinder boundary.

Disk /dev/sdb: 595.9 GB, 595926712320 bytes
255 heads, 63 sectors/track, 72450 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1       72450   581954593+  83  Linux
#
# fdisk -l /dev/sdb

Disk /dev/sdb: 104 MB, 104857600 bytes
64 heads, 32 sectors/track, 100 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
# fdisk -l  -o +UUID


Create new partition

# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. 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 72450.
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): p

Disk /dev/sdb: 595.9 GB, 595926712320 bytes
255 heads, 63 sectors/track, 72450 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   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-72450, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-72450, default 72450):
Using default value 72450

Command (m for help): p

Disk /dev/sdb: 595.9 GB, 595926712320 bytes
255 heads, 63 sectors/track, 72450 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1       72450   581954593+  83  Linux

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

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
#







os/linux/command/fdisk.html.txt ยท Last modified: 2018/02/09 by admin

Page Tools