Skip to content

Commit

Permalink
Show more status updates during bcache and gpt conversions.
Browse files Browse the repository at this point in the history
  • Loading branch information
g2p committed Mar 15, 2013
1 parent 7e06556 commit 0fa4170
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion blocks/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,7 @@ def lv_to_gpt(device, debug):

with tempfile.TemporaryDirectory(suffix='.blocks') as tdname:
vgcfgname = tdname + '/vg.cfg'
print('Loading LVM metadata... ', end='', flush=True)
quiet_call(
['vgcfgbackup', '--file', vgcfgname, '--', vgname])
aug = augeas.Augeas(
Expand All @@ -996,6 +997,7 @@ def lv_to_gpt(device, debug):
aug.set('/raw/vgcfg', vgcfg.read())

aug.text_store('LVM.lns', '/raw/vgcfg', '/vg')
print('ok')

# There is no easy way to quote for XPath, so whitelist
assert all(ch in ASCII_ALNUM_WHITELIST for ch in vgname), vgname
Expand Down Expand Up @@ -1053,14 +1055,20 @@ def lv_to_gpt(device, debug):
['git', 'diff', '--no-index', '--patience', '--color-words', '--',
vgcfgname, vgcfgname + '.new'])

print(
'Inserting a free extent before LV contents... ',
end='', flush=True)
quiet_call(
['vgcfgrestore', '--file', vgcfgname + '.new', '--', vgname])
# Make sure LVM updates the mapping, this is pretty critical
quiet_call(['lvchange', '--refresh', '--', device.devpath])
print('ok')

# Reopen, with a different mapping
dev_fd = os.open(device.devpath, os.O_SYNC|os.O_RDWR|os.O_EXCL)
print('Copying the GPT superblock... ', end='', flush=True)
synth_gpt.copy_to_physical(dev_fd)
print('ok')
os.close(dev_fd)


Expand Down Expand Up @@ -1142,7 +1150,9 @@ def to_bcache(device, debug):
os.close(dev_fd)
del dev_fd

print('Modifying the partition table... ', end='', flush=True)
print(
'Shifting partition to start on the bcache superblock... ',
end='', flush=True)
ptable.shift_left(part_start, part_start1)
print('ok')

Expand Down

0 comments on commit 0fa4170

Please sign in to comment.