diff options
author | Alexandru Avadanii <Alexandru.Avadanii@enea.com> | 2019-03-18 16:11:50 +0100 |
---|---|---|
committer | Alexandru Avadanii <Alexandru.Avadanii@enea.com> | 2019-03-18 16:44:52 +0100 |
commit | 36e16f10055c74b46bbc25b85f9adf60b546b136 (patch) | |
tree | d771b3c67e9e406a4ab1d63b226413ca89069acb /mcp/scripts/lib_jump_deploy.sh | |
parent | b84ea4cd4cce6db24a2bc7c392e3be0e7dc4ac78 (diff) |
[lib] nbd: Explicitly map partitions
Certain kernels (e.g. 4.4.0-101+ in Ubuntu) no longer automatically
ack the partition table update after `kpartx -a /dev/nbdX`, see [1].
To avoid another dependency on `parted` packages, use `partx` from
`util-linux`, which is already installed as a dependency of e2fsprogs.
[1] https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1743026
Change-Id: Ibd993fe210c1a11814e89a66759568d4d117d613
Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
Diffstat (limited to 'mcp/scripts/lib_jump_deploy.sh')
-rw-r--r-- | mcp/scripts/lib_jump_deploy.sh | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/mcp/scripts/lib_jump_deploy.sh b/mcp/scripts/lib_jump_deploy.sh index 5efbfa667..ade1a7487 100644 --- a/mcp/scripts/lib_jump_deploy.sh +++ b/mcp/scripts/lib_jump_deploy.sh @@ -121,13 +121,16 @@ function __mount_image { sudo qemu-nbd --connect="${OPNFV_NBD_DEV}" --aio=native --cache=none \ "${image_dir}/${image}" sudo kpartx -av "${OPNFV_NBD_DEV}" - sleep 5 # /dev/nbdNp1 takes some time to come up # Hardcode partition index to 1, unlikely to change for Ubuntu UCA image + sudo partx -uvn 1:1 "${OPNFV_NBD_DEV}" if sudo growpart "${OPNFV_NBD_DEV}" 1; then sudo kpartx -u "${OPNFV_NBD_DEV}" sudo e2fsck -pf "${OPNFV_MAP_DEV}" sudo resize2fs "${OPNFV_MAP_DEV}" + else + sleep 5 # /dev/nbdNp1 takes some time to come up fi + sudo partx -d "${OPNFV_NBD_DEV}" # grub-update does not like /dev/nbd*, so use a loop device to work around it sudo losetup "${OPNFV_LOOP_DEV}" "${OPNFV_MAP_DEV}" mkdir -p "${OPNFV_MNT_DIR}" @@ -497,6 +500,7 @@ function cleanup_mounts { sudo losetup -d "${OPNFV_LOOP_DEV}" fi if [ -n "${OPNFV_NBD_DEV}" ]; then + sudo partx -d "${OPNFV_NBD_DEV}" || true sudo kpartx -d "${OPNFV_NBD_DEV}" || true sudo qemu-nbd -d "${OPNFV_NBD_DEV}" || true fi |