Is it possible to enlarge the / partition without rebooting?

5,255

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.

Share:
5,255

Related videos on Youtube

Totor
Author by

Totor

Updated on September 18, 2022

Comments

  • Totor
    Totor almost 2 years

    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.

    • taliezin
      taliezin about 9 years
      You can try with partprobe. I don't know if it helps.
    • Totor
      Totor about 9 years
      @taliezin I just tried, it doesn't help.
    • taliezin
      taliezin about 9 years
      Sorry, take a look at this.
    • jaromrax
      jaromrax about 9 years
      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...
    • roaima
      roaima about 9 years
      @jaromrax it's from virtualisation such as KVM/qemu
    • Jannis
      Jannis about 9 years
      doesn't the resize2fs tool already do this job?
    • shubham
      shubham about 9 years
    • Totor
      Totor about 9 years
      @shubham No, this question doesn't involve resizing partitions. It's LVM stuff.
    • Rabin
      Rabin about 9 years
      @Totor, not directly relevant, but you should consider using LVM and not disk partitions.
  • Totor
    Totor over 8 years
    The question is about partition resizing.
  • OMG-1
    OMG-1 almost 6 years
    I fail to see where I haven't answered the question.