Ask a Question
Advertise on boostr.in
boostr.in questions - Question:how to Partitioning with fdisk?
You have just seen how to display partition information using the fdisk command. This command also provides a menu-driven environment for editing the partition table to create or remove partitions.
Before you start modifying partitions, there are some important things to remember. You risk losing your existing data if you do not follow these guidelines.
¬†¬†¬†¬†Back up important data before you start, as with any operation that may cause data loss.
¬†¬†¬†¬†Do not change partitions that are in use. Plan your actions and execute them carefully. Booting a live distribution from CD, DVD, or USB is one good way to ensure that no hard drive partitions are in use.
¬†¬†¬†¬†Know your tool. The fdisk command does not commit any changes to your disk until you tell it to. Other tools, including parted, may commit changes as you go.
¬†¬†¬†¬†Stop if you do make a mistake. Partitioning tools write the partition table. Unless the tool you are using also includes the ability to move, resize, format, or otherwise write to the data area of your disk, your data will not be touched. If you do make a mistake, stop as quickly as possible and seek help. You may still be able to restore your previous partition table definitions and thus recover your partitions and data.
To start fdisk in interactive mode, simply give the name of a disk, such as /dev/hda or /dev/sdb, as a parameter. The following example boots a Knoppix live DVD. You will need root authority, and you will see output similar to Listing 3.
Listing 3. Starting interactive fdisk
knoppix@Microknoppix:~$ su -
root@Microknoppix:~# fdisk /dev/sda
The number of cylinders for this disk is set to 121601.
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)
Command (m for help):
Most modern disks have more than 1024 cylinders, so you will usually see the warning shown in Listing 3. Type m to display a list of available one-letter commands as shown in Listing 4.
Listing 4. Help in fdisk
Command (m for help): m
¬†¬†¬†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):
Use the p command to display the existing partition on this particular disk; Listing 5 shows the output.
Listing 5. Displaying the existing partition table
Command (m for help): p
Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x000de20f
¬†¬†¬†Device Boot ¬†¬†¬†¬†¬†Start ¬†¬†¬†¬†¬†¬†¬†¬†End ¬†¬†¬†¬†¬†Blocks ¬†¬†Id ¬†System
/dev/sda1 ¬†¬†* ¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†1 ¬†¬†¬†¬†¬†¬†¬†9111 ¬†¬†¬†73184076 ¬†¬†¬†7 ¬†HPFS/NTFS
/dev/sda2 ¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†9634 ¬†¬†¬†¬†¬†¬†¬†9730 ¬†¬†¬†¬†¬†779152+ ¬†83 ¬†Linux
/dev/sda3 ¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†9731 ¬†¬†¬†¬†¬†116679 ¬†¬†859067842+ ¬†¬†5 ¬†Extended
/dev/sda5 ¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†9731 ¬†¬†¬†¬†¬†¬†20917 ¬†¬†¬†89859546 ¬†¬†83 ¬†Linux
/dev/sda6 ¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†20918 ¬†¬†¬†¬†¬†¬†39644 ¬†¬†150424596 ¬†¬†83 ¬†Linux
/dev/sda7 ¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†39645 ¬†¬†¬†¬†¬†¬†53905 ¬†¬†114551451 ¬†¬†83 ¬†Linux
Command (m for help):
This particular disk is a 1TB disk with a Windows/XP partition of a little under 80GB. It is a primary partition, and it is marked bootable, as is typical for a Windows system.
Sep 13, 2013
Sep 12, 2013
to add a comment.
Your name to display (optional):
Email me at this address if my answer is selected or commented on:
Email me if my answer is selected or commented on
Privacy: Your email address will only be used for sending these notifications.
To avoid this verification in future, please