7

I added a new disk (/dev/vdb) of 2TB with existing data from the previous 1TB disk.

I used fdisk /dev/vdb to extend its only partition /dev/vdb1 to full capacity of 2TB from previous 1TB. (In other words, I deleted vdb1, and then re-created it to fill the disk. See How to Resize a Partition using fdisk - Red Hat Customer Portal).

And then I did:

[root - /]$ fsck -n /dev/vdb1
fsck from util-linux 2.23.2
e2fsck 1.42.9 (28-Dec-2013)
/dev/vdb1: clean, 46859496/65536000 files, 249032462/262143744 blocks

[root - /]$ e2fsck -f /dev/vdb1
e2fsck 1.42.9 (28-Dec-2013)
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/vdb1: 46859496/65536000 files (0.4% non-contiguous), 249032462/262143744 blocks

[root - ~]$ resize2fs /dev/vdb1
resize2fs 1.42.9 (28-Dec-2013)
The filesystem is already 262143744 blocks long.  Nothing to do!

And fdisk -l looks like this:

Disk /dev/vdb: 2147.5 GB, 2147483648000 bytes, 4194304000 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: 0x4eb4fbf8

   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1            2048  4194303999  2097150976   83  Linux

However when I mount it:

mount /dev/vdb1 /mnt

This is what I got from df -h:

/dev/vdb1       985G  935G     0 100% /mnt

Which is still the size of the previous partition.

What am I doing wrong here?

UPDATE

I ran partprobe and it told me to reboot:

Error: Error informing the kernel about modifications to partition /dev/vdb1 -- Device or resource busy.  This means Linux won't know about any changes you made to /dev/vdb1 until you reboot -- so you shouldn't mount it or use it in any way before rebooting.
Error: Failed to add partition 1 (Device or resource busy)

So I rebooted and then ran this again:

mount /dev/vdb1 /mnt

But the added file system is still:

/dev/vdb1       985G  935G     0 100% /mnt

Any ideas? Should I do all the fsck, e2fsck, and resize2fs once again?

This is really weird. After the reboot, I ran partprobe again and it was still this error:

Error: Error informing the kernel about modifications to partition /dev/vdb1 -- Device or resource busy.  This means Linux won't know about any changes you made to /dev/vdb1 until you reboot -- so you shouldn't mount it or use it in any way before rebooting.
Error: Failed to add partition 1 (Device or resource busy)

Why is the device or resource busy? Even after I rebooted?

0

2 Answers 2

4
  1. I used fdisk /dev/vdb to extend its only partition /dev/vdb1 to full capacity of 2TB from previous 1TB... See How to Resize a Partition using fdisk - Red Hat Customer Portal.
  2. And then I did [resize2fs /dev/vdb1]...

We can see this did not change the size of your filesystem. Here is why:

resize2fs reads the size of the partition from the kernel, similar to reading the size of any other file. fdisk tries to update the kernel after it has written the partition table. However this will fail if the disk is in use, e.g. you have mounted one of its partitions.

This is why resize2fs showed the "nothing to do" message. It did not see the extra partition space.

The kernel reads the partition table during startup. So you can simply restart the computer. Then you can run resize2fs, it will see the extra partition space, and expand the filesystem to fit.


I believe fdisk logs a prominent warning when this happens, as screen-shotted in this (otherwise outdated) document.

There is a less friendly but actually up-to-date document, on the Red Hat Customer Portal:

How to use a new partition in RHEL6 without reboot?

From

partprobe was commonly used in RHEL 5 to inform the OS of partition table changes on the disk. In RHEL 6, it will only trigger the OS to update the partitions on a disk that none of its partitions are in use (e.g. mounted). If any partition on a disk is in use, partprobe will not trigger the OS to update partitions in the system because it is considered unsafe in some situations.

So in general we would suggest:

  1. Unmount all the partitions of the disk before modifying the partition table on the disk, and then run partprobe to update the partitions in system.
  2. If this is not possible (e.g. the mounted partition is a system partition), reboot the system after modifying the partition table. The partitions information will be re-read after reboot. If a new partition was added and none of the existing partitions were modified, consider using the partx command to update the system partition table. Do note that the partx command does not do much checking between the new and the existing partition table in the system and assumes the user knows what they are are doing. So it can corrupt the data on disk if the existing partitions are modified or the partition table is not set correctly. So use at one's own risk.
6
  • 4
    In case anyone comes here looking for an answer, this answer did not solve the same issue inside a VirtualBox machine. You should instead download gparted iso, set it as an optical drive, start the VM and resize the guest partition manually using the GUI. Commented Feb 6, 2019 at 22:03
  • 3
    It does not work if you only have one drive. Your answer is 100% correct, I was just adding a hint for anyone looking for the same problem inside VirtualBox, as I was. Commented Feb 6, 2019 at 22:30
  • 1
    I'm running into the same issue with a virtual box machine. resize2fs just says "the filesystem is already *** (4k) bolcks long. Nothing to do!". Commented Jan 10, 2022 at 20:48
  • What I suspect is you're finding this Q&A too verbose and confusing, and not following the same steps as the person did in the edited question. 1: "used fdisk /dev/vdb to extend its only partition /dev/vdb1 to full capacity of 2TB from previous 1TB". 2: reboot. 3: resize2fs. Commented Jan 11, 2022 at 10:19
  • @chech Edited as per above comment, please re-read. To be crystal clear, I suspect you're wrong to say that you had the same issue. If we want to include a signpost to how you extend partitions using fdisk /dev/vdb, I think we'd better edit the question. Commented Jan 11, 2022 at 10:50
2

Although not directly related to the question, resize2fs might not work as expected if the partition is within an extended partition.

See here for more info: Ubuntu ext4 partition is not being extended or resized as expected with growpart or resize2fs

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.