views:

3241

answers:

4

When trying to partition a hard drive on ESX server I frequently run into the following problem:

 $ fdisk /dev/sdd
 Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
 Building a new DOS disklabel. Changes will remain in memory only,
 until you decide to write them. After that, of course, the previous
 content won't be recoverable.

 Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

 Command (m for help): p

 Disk /dev/sdd: 2684 MB, 2684157952 bytes
 83 heads, 62 sectors/track, 1018 cylinders
 Units = cylinders of 5146 * 512 = 2634752 bytes

    Device Boot    Start       End    Blocks   Id  System

 Command (m for help): w
 The partition table has been altered!

 Calling ioctl() to re-read partition table.

 WARNING: Re-reading the partition table failed with error 22: Invalid argument.
 The kernel still uses the old table.
 The new table will be used at the next reboot.
 Syncing disks.

Rebooting the machine always resolves the problem. However, rebooting is not an acceptable solution.

Any insight into the problem would be appreciated.

+3  A: 

As mentioned here:

Is the drive unmounted when you're repartitioning?? If not, then then it will be in use (by the kernel). You can repartition stuff without rebooting but the drive needs to unmounted first.

If you're trying to repartition the drive that has your root file system then you're out of luck - boot from a Knoppix CD, or something similar, and repartition that way.

Trying to repartition a mounted drive is like trying to change a tyre while the car is still moving...possible; but your car will crash and burn and you'll probably break a few fingers in the process ;)

An implication of this is that maybe all you need to do in order to correct the problem is unmount and remount the drive, rather than rebooting the system.

dsm
A: 

Remounting the drive should be sufficient on modern systems - but, then, changing a partition table which contains mounted partitions doesn't strike me as a very good idea in the first place. You really should unmount, edit partitions, remount if at all possible. (I suspect that avoiding the dangers inherent in resizing a mounted partition on the fly are why the kernel chooses to ignore the change until rebooted.)

On older systems, though, this may simply not be possible due to limitations of prior versions of the technology. A 2.5G drive may be old enough to fall into this category.

Dave Sherohman
A: 

as root: partprobe

A: 

asdf is right - partprobe