From fa2eb4b7153f4653e4d4f5fab1987b09adde40eb Mon Sep 17 00:00:00 2001 From: Mirza Krak Date: Tue, 12 Feb 2019 13:02:15 +0100 Subject: [PATCH] call "truncate" with sudo permissions in do_raw_disk_image_shrink_rootfs The "do_raw_disk_image_shrink_rootfs" changes permissions of input image to "root:root" which requires that all commands are called with "sudo", otherwise it produces an error: $ ./mender-convert raw-disk-image-shrink-rootfs --raw-disk-image input/2018-11-13-raspbian-stretch-lite-expanded-16gb.img *** Data partition size set to default value: 128MB *** *** Total storage size set to default value: 8GB *** 1/1 Shrinking raw disk image root filesystem... dumpe2fs 1.44.5 (15-Dec-2018) resize2fs 1.44.5 (15-Dec-2018) Root filesystem size: minimal: 1441787904 aligned: 1442840576 sectors: 2818048 Raw disk image new endsector: 2916351 truncate: cannot open '/home/mirzak/src/mender-convert/input/2018-11-13-raspbian-stretch-lite-expanded-16gb.img' for writing: Permission denied Changelog: Fix permission denied error in when calling "mender-convert raw-disk-image-shrink-rootfs" Signed-off-by: Mirza Krak --- mender-convert | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mender-convert b/mender-convert index b325111..359ebb0 100755 --- a/mender-convert +++ b/mender-convert @@ -237,7 +237,7 @@ do_raw_disk_image_shrink_rootfs() { sudo losetup -d $loopdevice log "\tRaw disk image new endsector: $endsector" - truncate -s $((($endsector+1) * $sector_size)) $raw_disk_image + sudo truncate -s $((($endsector+1) * $sector_size)) $raw_disk_image log "\tNew root filesystem size (sectors): $new_size_sectors" return 0