Fdisk
Fdisk is fine with MBR
could be limited when used for GPT
, in this case see parted.
Resize partition
Important: this example consider a single partition on the device.
unmount /mnt/disk
fdisk /dev/vdb
Command (m for help): d # delete
Command (m for help): n # new
...
Select (default p):
Using default response p.
Partition number (1-4, default 1):
First sector (2048-146800639, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-146800639, default 146800639):
Created a new partition 1 of type 'Linux' and of size 70 GiB.
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
e2fsck -f /dev/vdb1
e2fsck 1.42.12 (29-août-2014)
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
/dev/vdb: 12/3276800 files (0.0% non-contiguous), 251700/13107200 blocks
resize2fs /dev/vdb1
resize2fs 1.42.12 (29-Aug-2014)
Resizing the filesystem on /dev/vdb to 18350080 (4k) blocks.
The filesystem on /dev/vdb is now 18350080 (4k) blocks long.
mount /dev/vdb1 /mnt/disk/
df -h /mnt/disk
Source
See also interesting comment, saying you cannot downsize an ext2/3/4
partition apparently, and resize2fs only work for this kind of partition (not for LVM as an obvious example)