summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorRobert Collins <rbtcollins@hp.com>2013-04-02 17:08:06 +1300
committerRobert Collins <rbtcollins@hp.com>2013-04-04 10:21:06 +1300
commita01f907cecc24c18cbe3d32921247125294dd2b9 (patch)
tree399ca19ce6d3f2e449ef9768decd7b60220090cc /bin
parentf3d6e5ccdad2520ee4261835517e1db2c80b8f3a (diff)
downloadnova-a01f907cecc24c18cbe3d32921247125294dd2b9.tar.gz
nova-a01f907cecc24c18cbe3d32921247125294dd2b9.tar.xz
nova-a01f907cecc24c18cbe3d32921247125294dd2b9.zip
Simplify and correct the bm partition sizes.
The sfdisk code that landed uses -D, which ends up subtracting space from the first partition - this plays havoc with precisely sized disk images due to a bug in the automatic adjustment code. Instead we directly specify the spare space to be allowed. Additionally, sfdisk can be used much more simply, avoiding any room for us to make arithmetic errors, and reducing the opportunity for race conditions with udev so this change does that. Change-Id: I7f95e867d8775f49698cbbf4b1be40e69db9d538
Diffstat (limited to 'bin')
-rwxr-xr-xbin/nova-baremetal-deploy-helper24
1 files changed, 7 insertions, 17 deletions
diff --git a/bin/nova-baremetal-deploy-helper b/bin/nova-baremetal-deploy-helper
index a9d5ecfc7..7336162e3 100755
--- a/bin/nova-baremetal-deploy-helper
+++ b/bin/nova-baremetal-deploy-helper
@@ -99,23 +99,13 @@ def logout_iscsi(portal_address, portal_port, target_iqn):
def make_partitions(dev, root_mb, swap_mb):
"""Create partitions for root and swap on a disk device."""
- stdin_command = ('0 0;\n0 0;\n0 0;\n0 0;\n')
- utils.execute('sfdisk', '-D', '-uM', dev, process_input=stdin_command,
- run_as_root=True,
- check_exit_code=[0])
- # create new partitions
- commandp1 = '- %d 83;\n;\n;\n;' % root_mb
- p1outraw, err = utils.execute('sfdisk', '-D', '-uM', '-N1', dev,
- process_input=commandp1,
- run_as_root=True,
- check_exit_code=[0])
- # get end location of 1st partition
- p1re = re.compile('^%s-part1.*$' % dev, re.U + re.M)
- p1balist = p1re.findall(p1outraw)
- p1endraw = p1balist[1]
- p1end = int(p1endraw.split()[2])
- commandp2 = ('%d %d 82\n;\n;' % (p1end + 1, swap_mb))
- utils.execute('sfdisk', '-D', '-uM', '-N2', dev, process_input=commandp2,
+ # Lead in with 1MB to allow room for the partition table itself, otherwise
+ # the way sfdisk adjusts doesn't shift the partition up to compensate, and
+ # we lose the space.
+ # http://bazaar.launchpad.net/~ubuntu-branches/ubuntu/raring/util-linux/
+ # raring/view/head:/fdisk/sfdisk.c#L1940
+ stdin_command = ('1 %d 83;\n- %d 82;\n0 0;\n0 0;\n' % (root_mb, swap_mb))
+ utils.execute('sfdisk', '-uM', dev, process_input=stdin_command,
run_as_root=True,
check_exit_code=[0])
# avoid "device is busy"