Find the answer to your Linux question:
Results 1 to 7 of 7
Hello Everybody I need to be able to refresh the paritition table (re-synch disks) without rebootting the machine. After manually editing the MBR (master boot record) using dd or hexedit, ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jun 2007
    Posts
    9

    Updating partition table dynamically


    Hello Everybody

    I need to be able to refresh the paritition table (re-synch disks) without rebootting the machine.
    After manually editing the MBR (master boot record) using dd or hexedit, I need a way to force the system to refresh the partitions table on the fly.

    I figured that if I run fdisk and then and just use the 'w' (write) even if nothing was changed on fdisk, it will refresh the tables with the new settings on the MBR, but I need to implement this functionality in a script, therefore can't use that option.

  2. #2
    Linux Guru anomie's Avatar
    Join Date
    Mar 2005
    Location
    Texas
    Posts
    1,692
    See manpages for partprobe(8).

  3. #3
    Just Joined!
    Join Date
    Jun 2007
    Posts
    9
    Hi I tryed partprobe it takes a long time and after that if I execute 'cat /proc/partitions' I don't get the updated table.

    fdisk still does it with no problems.


    partprobe -h
    Usage: partprobe [OPTION] [DEVICE]...
    Inform the operating system about partition table changes.

    -d, --dry-run do not actually inform the operating system
    -s, --summary print a summary of contents
    -h, --help display this help and exit
    -v, --version output version information and exit

    When no DEVICE is given, probe all partitions.

  4. #4
    Linux Guru
    Join Date
    Nov 2007
    Location
    Córdoba (Spain)
    Posts
    1,513
    Quote Originally Posted by tiziano-m View Post
    Hi I tryed partprobe it takes a long time and after that if I execute 'cat /proc/partitions' I don't get the updated table.

    fdisk still does it with no problems.
    You can always feed fdisk from a file, instead of stdin.

    Create a file called "test.txt" containing this:

    p
    q
    Now, do this on command line:

    Code:
    fdisk /dev/hda < test.txt
    You get the idea... Modify it to suit your needs.

  5. #5
    Just Joined!
    Join Date
    Jun 2007
    Posts
    9
    Hey THANKS, that did it ! ! !

    Now, just to be a pain and not have an extra file, is there a way to send that stdin directly form the line instead of creating another file?

    Ends up being that the only command I have to send is 'w' that's all, not even a 'new line' or enter, after 'write' fdisk autommatically quits.

    I tryed:
    fdisk /dev/sda < 'w'
    and others variants too, but it didn't work.

  6. #6
    Linux Guru
    Join Date
    Nov 2007
    Location
    Córdoba (Spain)
    Posts
    1,513
    Sure, you want this:

    fdisk /dev/sda << EOF
    w
    EOF

    [rest of the script]
    Everything until the EOF mark (end of file) is not interpreted by bash. Instead, it's used to feed fdisk. EOF closes the stream and returns the control to bash.

  7. #7
    Just Joined!
    Join Date
    Jun 2007
    Posts
    9

    Thumbs up

    Thanks a LOT !!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •