6

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.

  • You can try with partprobe. I don't know if it helps. – taliezin Apr 15 '15 at 16:42
  • @taliezin I just tried, it doesn't help. – Totor Apr 15 '15 at 16:46
  • Sorry, take a look at this. – taliezin Apr 15 '15 at 18:02
  • I just wonder the unusual name - /dev/vda. But I never tried to enlarge ext online, every operation on partition had to always be done when unmounted. Maybe readonly mount could help you... – jaromrax Apr 15 '15 at 18:22
  • @jaromrax it's from virtualisation such as KVM/qemu – roaima Apr 15 '15 at 20:18
1

The kernel will use the old (cached) partition table until you unmount all partitions on the affected disk. Since you can't do it with the / partition, the option you have is to reboot. Next time try to use LVM.

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.

  • The question is about partition resizing. – Totor Feb 17 '16 at 14:43
  • I fail to see where I haven't answered the question. – OMG-1 Jul 26 '18 at 5:40
  • I don't use LVM on my root/ partition. If I had, it would have been a solution. Also partprobe and other similar tools I mention in my question didn't work. – Totor Aug 9 '18 at 11:35

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.