Merge pull request #1799 from vpeter4/virtual

create_virtualimage: robustness creating image at least on Ubuntu
This commit is contained in:
Stefan Saraev 2013-01-23 10:35:03 -08:00
commit eb2f8251c8

View File

@ -185,6 +185,7 @@ echo "storage size: $STORAGE_SIZE MB"
# ensure loopX not in use
echo ""
echo "next two errors can be ignored..."
sync
umount "$LOOP"
losetup -d "$LOOP"
@ -196,6 +197,7 @@ echo "storage size: $STORAGE_SIZE MB"
# write a disklabel
echo ""
echo "creating new partition table: $DISK..."
sync
losetup "$LOOP" "$DISK"
parted -s "$LOOP" mklabel msdos
@ -239,6 +241,7 @@ echo "storage size: $STORAGE_SIZE MB"
# create filesystem on partition1
echo ""
sync
losetup -d "$LOOP"
echo "creating filesystem on partition1..."
OFFSET=$(( 64 * 512 ))
@ -247,6 +250,7 @@ echo "storage size: $STORAGE_SIZE MB"
mke2fs -q -t ext4 -m 0 "$LOOP"
tune2fs -U random -L "System" "$LOOP"
sync
e2fsck -n "$LOOP"
# mount partition
echo ""
@ -292,6 +296,7 @@ EOF
# create filesystem on partition2
echo ""
sync
losetup -d "$LOOP"
echo "creating filesystem on partition2..."
OFFSET=$(( $STORAGE_PART_START * 512 ))
@ -299,8 +304,10 @@ EOF
mke2fs -q -t ext4 -m 0 "$LOOP"
tune2fs -U random -L "Storage" "$LOOP"
sync
e2fsck -n "$LOOP"
# detach loopX
sync
losetup -d "$LOOP"
# cleaning