Welcome to Linux Forums!

With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.

Linux Forum ArticlesLinux ForumsLinux Forum DownloadsLinux Hosts
Home|Register|FAQ|Member List|Calendar|Unanswered Posts|Forum Rules|Today's Posts|Advanced Search|
SEARCH FOR IN
Go Back   Linux Forums > GNU Linux Zone > Installation
Reload this Page Updating partition table dynamically
Linux Forums
Linux Forums
Welcome To The Linux Forums!
Welcome to Linux Forums. We pride ourselves in being one of the largest Linux communities on the web, we encourage you to REGISTER on our forums and participate in the community. There are over 150,000 members ready to answer your questions. JOINING US today will allow you to make new posts, get support, send messages to other members and submit downloads to our downloads directory and many other great features!

Installation Need help or have questions about installing Linux, including dual booting with other distros or Windows? put them here!

Reply
 
Thread Tools Display Modes
Old 04-16-2008   #1 (permalink)
tiziano-m
Just Joined!
 
Join Date: Jun 2007
Posts: 7
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.
tiziano-m is offline   Reply With Quote
Old 04-16-2008   #2 (permalink)
anomie
Linux Guru
 
anomie's Avatar
 
Join Date: Mar 2005
Location: Texas
Posts: 1,699
See manpages for partprobe(8).
__________________
FreeBSD Handbook & FAQ // CentOS wiki
anomie is offline   Reply With Quote
Old 04-16-2008   #3 (permalink)
tiziano-m
Just Joined!
 
Join Date: Jun 2007
Posts: 7
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.
tiziano-m is offline   Reply With Quote
Old 04-17-2008   #4 (permalink)
i92guboj
Linux Engineer
 
Join Date: Nov 2007
Location: Córdoba (Spain)
Posts: 1,016
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:

Quote:
p
q
Now, do this on command line:

Code:
fdisk /dev/hda < test.txt
You get the idea... Modify it to suit your needs.
i92guboj is offline   Reply With Quote
Old 04-17-2008   #5 (permalink)
tiziano-m
Just Joined!
 
Join Date: Jun 2007
Posts: 7
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.
tiziano-m is offline   Reply With Quote
Old 04-17-2008   #6 (permalink)
i92guboj
Linux Engineer
 
Join Date: Nov 2007
Location: Córdoba (Spain)
Posts: 1,016
Sure, you want this:

Quote:
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.
i92guboj is offline   Reply With Quote
Old 04-17-2008   #7 (permalink)
tiziano-m
Just Joined!
 
Join Date: Jun 2007
Posts: 7
Thumbs up

Thanks a LOT !!!
tiziano-m is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT. The time now is 11:44 AM.




© 2000 - 2008 - All Rights Reserved - Property of  MAS Media

Content Relevant URLs by vBSEO 3.0.0