Super fdisk : The power of the tool
You can use the fdisk tool to create and modify GPT, MBR, Sun, SGI, and BSD partition tables. Because fdisk GPT support is experimental, it is suggested that you use the parted program for disks that have a GUID Partition Table (GPT). Before resizing a partition, make a backup of the data on the file system and test the operation, as the only way to change the size of a partition with fdisk is to delete and recreate the partition.
Partition Resizing
The following process is just provided as a guideline. To resize a partition with fdisk, follow these steps:
- Unmount the device:
# umount /dev/sdb
- Run fdisk disk_name. For example
# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them. Be careful before using the write command.
Command (m for help):
- Use the p option to determine the line number of the partition to be deleted.
Command (m for help): p
Disk /dev/sdb: 16.1 GB, 16106127360 bytes, 31457280
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 label type: dos
Disk identifier: 0x0006d09a
Device Boot Start End Blocks Id System
/dev/sdb1 * 2048 1026047 512000 83 Linux
/dev/sdb2 1026048 31457279 15215616 8e Linux LVM
- Use the d option to delete a partition. If there is more than one partition available, fdisk prompts you to provide a number of the partition to delete:
Command (m for help): d
Partition number (1,2, default 2): 2
Partition 2 is deleted
- To create a partition, use the n option and follow the steps. Allow adequate space for future enlargement. The default behavior of fdisk (hit Enter) is to use all available space on the device. You can indicate the partition's end by sectors, or you can give a human-readable size by using +, for example +500M or +10G.
Command (m for help): n
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
Select (default p): *Enter*
Using default response p
Partition number (2-4, default 2): *Enter*
First sector (1026048-31457279, default 1026048): *Enter*
Using default value 1026048
Last sector, +sectors or +size{K,M,G} (1026048-31457279, default 31457279): +500M
Partition 2 of type Linux and of size 500 MiB is set
- Set the partition type to LVM:
Command (m for help): t
Partition number (1,2, default 2): *Enter*
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'
- When you are certain that the changes are accurate, use the w option to save them, as errors can create instability with the selected partition.
- To ensure consistency, run e2fsck on the device:
# e2fsck /dev/sda e2fsck 1.41.12 (17-May-2010) Pass 1:Checking inodes, blocks, and sizes Pass 2:Checking directory structure Pass 3:Checking directory connectivity Pass 4:Checking reference counts Pass 5:Checking group summary information ext4-1:11/131072 files (0.0% non-contiguous),27050/524128 blocks
- Mount the device:
# mount /dev/sda
If you like this post, please consider donating so that we can continue to maintain our site.?
Leave a comment
Your email address will not be published. Required fields are marked *