Browse Source

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 <mirza.krak@northern.tech>
1.1.x
Mirza Krak 6 years ago
parent
commit
fa2eb4b715
  1. 2
      mender-convert

2
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

Loading…
Cancel
Save