Created
October 1, 2018 14:50
-
-
Save cinek810/60aa3afed271c311733837bc57d6dd79 to your computer and use it in GitHub Desktop.
image.expand.exec
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- ./libexec/cli/image.expand.exec 2018-10-01 09:50:15.000000000 -0400 | |
+++ /cm/shared/apps/singularity/libexec/singularity/cli/image.expand.exec 2018-10-01 09:30:41.000000000 -0400 | |
@@ -112,15 +112,32 @@ | |
exit 1 | |
fi | |
+message 1 "Create loop device" | |
+SINGULARITY_LOOP_DEVICE=$(losetup -f) | |
+if [ $? -ne 0 ]; then | |
+ exit 1 | |
+fi | |
+ | |
+message 1 "Binding to loop: $SINGULARITY_LOOP_DEVICE\n" | |
+if ! mount -o bind,offset=31 $SINGULARITY_IMAGE $SINGULARITY_LOOP_DEVICE; then | |
+ exit 1 | |
+fi | |
+ | |
message 1 "Checking image's file system\n" | |
-if ! /sbin/e2fsck -fy "$SINGULARITY_IMAGE"; then | |
+if ! /sbin/e2fsck -fy "$SINGULARITY_LOOP_DEVICE"; then | |
+ umount "$SINGULARITY_LOOP_DEVICE" | |
exit 1 | |
fi | |
message 1 "Resizing image's file system\n" | |
-if ! /sbin/resize2fs "$SINGULARITY_IMAGE"; then | |
+if ! /sbin/resize2fs "$SINGULARITY_LOOP_DEVICE"; then | |
+ umount "$SINGULARITY_LOOP_DEVICE" | |
exit 1 | |
fi | |
+sleep 3 | |
+message 1 "Unmounting loop device: $SINGULARITY_LOOP_DEVICE" | |
+umount "$SINGULARITY_LOOP_DEVICE" | |
+ | |
message 1 "Image is done: $SINGULARITY_IMAGE\n" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment