‘fdisk’ Command To Manage Disk Partitions In Linux
- Fdisk requires root to operate. On Debian and Ubuntu based systems, you can prefix with sudo. On other distros, use su- command to get a root shell and then enter the commands without sudo.
- Take note of the form the device names (disks) are presented. Usually you see following names
- /dev/hd[a-h] for IDE disks
- /dev/sd[a-p] for SCSI disks
- /dev/ed[a-d] for ESDI disks
- /dev/xd[ab] for XT disks
3. Warning: Do not delete, modify, or add partition unless you know exactly what you are about. You ran the risk of losing your data!
The output will be this –
3. You will be prompted to enter the partition number. We enter 2 in our case to delete /dev/sdb2. Save changes by entering ‘w’ at command and reboot for changes.
# sudo fdisk /dev/sdb
2. Enter ‘n’ to create a new partition which will prompt you to specify for either a primary partition or an extended partition. Enter ‘p’ for a primary partition or ‘e’ for an extended partition.
3. You will then be prompted to enter the first cylinder or sector number of the partition to be created. You may press Enter to accept the defaults.
4. You will then be prompted to enter the Last cylinder or sector number of the partition to be created. You may press Enter to use all available space after the first sector or enter a specific size such as +2G or +256M for a 2 gigabyte or 256 megabyte partition respectively.
5. Run ‘w’ command to write the changes and reboot your system.
Use ‘p’ in command mode.Command (m for help): p