After increasing the disk size from 200GB to 300GB of a Hyper-V VM in which Ubuntu Server is installed lsblk shows the following

root@ubuntu:~# lsblk
NAME                                    MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda                                       8:0    0    15G  0 disk
├─sda1                                    8:1    0   243M  0 part /boot
├─sda2                                    8:2    0     1K  0 part
└─sda5                                    8:5    0  14.8G  0 part
  ├─ubuntu--vg-root (dm-0)   252:0    0  14.2G  0 lvm  /
  └─ubuntu--vg-swap_1 (dm-1) 252:1    0   508M  0 lvm  [SWAP]
sdb                                       8:16   0   300G  0 disk
└─sdb1                                    8:17   0   200G  0 part /media/storage
sr0                                      11:0    1  1024M  0 rom

Now we simply want that sdb1 which is currently mounted at /media/storage (but could be temporarily unmounted without problems) gets increased to 300GB so that it uses all space on sdb.

Simply using resize2fs doesn't seem to work. What does work is booting from a GParted CD and performing a resize operation. However, as this is a non-root partition which can be unmounted this seems to be an overkill. So is there a simple way to this with the command line? (Unfortunately googling brings up really lots of stuff with GParted or about root partitions etc. pp. which does not apply here.)


resize2fs will resize the filesystem not the partition. You have to resize your partition (sdb1) before resizing the filesystem.

If you don't want to use parted then you can use fdisk.

Initially you have to find the starting sector of sdb1 partition. To do that simply execute:

fdisk -l /dev/sdb

and note down the number in the Start column


fdisk /dev/sdb

then press d to delete the first partition.

then press n to create a new partition.

then press p to indicate that it will be a primary partition.

then press 1 to indicate that it will be the first partition.

The next step is very important. fdisk will ask for the First sector of the new partition. Use the number you noted earlier.

then fdisk will ask for the last sector. By default fdisk will promt for the last sector of the disk so use that default value.

then press w and fdisk will write the partition table to disk.

You can now resize the filesystem using the resize2fs command

  • 1
    Does deleting the partition and creating a new one retain the data on the old partition? If not, you should probably put a warning in bold type so nobody destroys their data…
    – John Y
    Jan 13 '19 at 15:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.