8

I can enlarge the root (/) partition with fdisk without rebooting (deleting an recreating it with the same 1st sector, but greater last sector).

However, I cannot make the kernel to re-read the partition table :

# partx -va /dev/vda
partx: /dev/vda: adding partition #5 failed: Device or resource busy
partx: /dev/vda: error adding partition 5

# kpartx -va /dev/vda
device-mapper: reload ioctl on vda5 failed: Invalid argument
add map vda5 : 0 41492480 linear 0:0 2048

# hdparm -z /dev/vda
/dev/vda:
 re-reading partition table
 BLKRRPART failed: Device or resource busy

# sfdisk -R /dev/vda
BLKRRPART: Device or resource busy
This disk is currently in use.

I know what I am doing, and the ext filesystems within the partitions support online enlargement.

Is there a way forcing the kernel to update its partition table?

EDIT: I know about LVM, but it is not an answer for this question.

Totor
  • 20,040

2 Answers2

3

The kernel will use the old (cached) partition table until you unmount all partitions on the affected disk.

Since you can't unmount and mount the / partition meantime the system is running, the only option you have is a reboot.

Next time try to use LVM, because it allows you to resize volumes (even the root one) without necessitating changing of the partition table.

asdmin
  • 205
0

To online resize the filesystem, especially /, you need to have some form of abstraction between the physical and virtual layer, e.g. LVM.

To live resize with LVM use:

pvcreate /dev/sdX
vgcreate vg1 /dev/sdX
lvcreate Root -L10G

Then next time the disk is about to be full, you will use lvextend /dev/mapper/vg1-Root -L+10G --resizefs and voilà you got more space.

Read up on LVM on http://linux.die.net/man/8/lvm

EDIT

To politely ask the kernel to update the partition table which is cached you could try partprobe But I would not assume it to work as you need to, as said earlier, remount all your filesystems, which is hard unless you booted into a live vm.

EDIT

You would be able to resize the partition, but that require you to memorize/write down the sizes you see in fdisk which can be a very advanced step for everybody. When you have those numbers, you recreate the partition from the begin size and then let it fill the disk. this is easier if the partition is the last one on the disk, if you have to resize the middle partition you are certainly out of luck

I've done it some times for customers, but it is hairy and nerve wrecking job to do. I would not recommend this way for safety and data keeping.

OMG-1
  • 434