-
-
Save dmsimard/bdea83a76d6cc049f808c1110b6c1ca3 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
counter=0 | |
while true | |
do | |
((counter++)) | |
python -c "print('#' * 40)" | |
echo "Attempt $counter" | |
python -c "print('#' * 40)" | |
dd if=/dev/zero of=/root/diskimage bs=1M count=128 | |
losetup /dev/loop0 /root/diskimage | |
partprobe | |
sync | |
parted /dev/loop0 --script -- \ | |
mklabel msdos \ | |
mkpart primary linux-swap 1 64 \ | |
mkpart primary ext2 64 -1 && echo "parted success" || echo "parted failed" | |
mkfs.ext4 /dev/loop0p2 2>&1 >/dev/null && echo "mkfs success" || echo "mkfs failed" | |
mount /dev/loop0p2 /mnt 2>&1 >/dev/null && echo "mount success" || echo "mount failed" | |
sleep 1 | |
### Clean up | |
umount /dev/loop0p2 | |
losetup -D /dev/loop0 | |
done |
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
#!/bin/bash | |
counter=0 | |
while true | |
do | |
((counter++)) | |
python -c "print('#' * 40)" | |
echo "Attempt $counter" | |
python -c "print('#' * 40)" | |
dd if=/dev/zero of=/root/diskimage bs=1M count=128 | |
losetup /dev/loop0 /root/diskimage | |
partprobe | |
sync | |
parted /dev/loop0 --script -- mklabel msdos 2>&1 >/dev/null && echo "mklabel success" || echo "mklabel failed" | |
parted /dev/loop0 --script -- mkpart primary linux-swap 1 64 2>&1 >/dev/null && echo "mkpart swap success" || echo "mkpart swap failed" | |
parted /dev/loop0 --script -- mkpart primary ext2 64 -1 2>&1 >/dev/null && echo "mkpart ext2 success" || echo "mkpart ext2 failed" | |
mkfs.ext4 /dev/loop0p2 2>&1 >/dev/null && echo "mkfs success" || echo "mkfs failed" | |
mount /dev/loop0p2 /mnt 2>&1 >/dev/null && echo "mount success" || echo "mount failed" | |
sleep 1 | |
### Clean up | |
umount /dev/loop0p2 | |
losetup -D /dev/loop0 | |
done |
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
######################################## | |
Attempt 1 | |
######################################## | |
128+0 records in | |
128+0 records out | |
134217728 bytes (134 MB) copied, 0.362966 s, 370 MB/s | |
Error: Partition(s) 1, 2 on /dev/loop0 have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes. | |
mklabel failed | |
Error: Partition(s) 2 on /dev/loop0 have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes. | |
mkpart swap failed | |
mkpart ext2 success | |
mke2fs 1.42.9 (28-Dec-2013) | |
/dev/loop0p2 is mounted; will not make a filesystem here! | |
mkfs failed | |
mount: /dev/loop0p2 is already mounted or /mnt busy | |
/dev/loop0p2 is already mounted on /mnt | |
mount failed | |
######################################## | |
Attempt 2 | |
######################################## | |
128+0 records in | |
128+0 records out | |
134217728 bytes (134 MB) copied, 0.292451 s, 459 MB/s | |
Error: Partition(s) 1 on /dev/loop0 have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes. | |
mklabel failed | |
mkpart swap success | |
mkpart ext2 success | |
mke2fs 1.42.9 (28-Dec-2013) | |
mkfs success | |
mount success | |
######################################## | |
Attempt 3 | |
######################################## | |
128+0 records in | |
128+0 records out | |
134217728 bytes (134 MB) copied, 0.312923 s, 429 MB/s | |
Error: Partition(s) 1 on /dev/loop0 have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes. | |
mklabel failed | |
mkpart swap success | |
mkpart ext2 success | |
mke2fs 1.42.9 (28-Dec-2013) | |
mkfs success | |
mount success | |
######################################## | |
Attempt 4 | |
######################################## | |
128+0 records in | |
128+0 records out | |
134217728 bytes (134 MB) copied, 0.410979 s, 327 MB/s | |
Error: Partition(s) 1 on /dev/loop0 have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes. | |
mklabel failed | |
mkpart swap success | |
mkpart ext2 success | |
mke2fs 1.42.9 (28-Dec-2013) | |
mkfs success | |
mount success | |
######################################## | |
Attempt 5 | |
######################################## | |
128+0 records in | |
128+0 records out | |
134217728 bytes (134 MB) copied, 0.419232 s, 320 MB/s | |
Error: Partition(s) 1 on /dev/loop0 have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes. | |
mklabel failed | |
mkpart swap success | |
mkpart ext2 success | |
mke2fs 1.42.9 (28-Dec-2013) | |
mkfs success | |
mount success | |
######################################## | |
Attempt 6 | |
######################################## | |
128+0 records in | |
128+0 records out | |
134217728 bytes (134 MB) copied, 0.480205 s, 280 MB/s | |
Error: Partition(s) 1 on /dev/loop0 have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes. | |
mklabel failed | |
mkpart swap success | |
mkpart ext2 success | |
mke2fs 1.42.9 (28-Dec-2013) | |
mkfs success | |
mount success | |
######################################## | |
Attempt 7 | |
######################################## | |
128+0 records in | |
128+0 records out | |
134217728 bytes (134 MB) copied, 0.300646 s, 446 MB/s | |
Error: Partition(s) 1 on /dev/loop0 have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes. | |
mklabel failed | |
mkpart swap success | |
mkpart ext2 success | |
mke2fs 1.42.9 (28-Dec-2013) | |
mkfs success | |
mount success | |
######################################## | |
Attempt 8 | |
######################################## | |
128+0 records in | |
128+0 records out | |
134217728 bytes (134 MB) copied, 0.435561 s, 308 MB/s | |
Error: Partition(s) 1 on /dev/loop0 have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes. | |
mklabel failed | |
mkpart swap success | |
mkpart ext2 success | |
mke2fs 1.42.9 (28-Dec-2013) | |
mkfs success | |
mount success | |
######################################## | |
Attempt 9 | |
######################################## | |
128+0 records in | |
128+0 records out | |
134217728 bytes (134 MB) copied, 0.304114 s, 441 MB/s | |
Error: Partition(s) 1 on /dev/loop0 have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes. | |
mklabel failed | |
mkpart swap success | |
mkpart ext2 success | |
mke2fs 1.42.9 (28-Dec-2013) | |
mkfs success | |
mount success | |
######################################## | |
Attempt 10 | |
######################################## | |
128+0 records in | |
128+0 records out | |
134217728 bytes (134 MB) copied, 0.477538 s, 281 MB/s | |
Error: Partition(s) 1 on /dev/loop0 have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes. | |
mklabel failed | |
mkpart swap success | |
mkpart ext2 success | |
mke2fs 1.42.9 (28-Dec-2013) | |
mkfs success | |
mount success | |
######################################## | |
Attempt 11 | |
######################################## | |
128+0 records in | |
128+0 records out | |
134217728 bytes (134 MB) copied, 0.417468 s, 322 MB/s | |
Error: Partition(s) 1 on /dev/loop0 have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes. | |
mklabel failed | |
mkpart swap success | |
mkpart ext2 success | |
mke2fs 1.42.9 (28-Dec-2013) | |
mkfs success | |
mount success | |
######################################## | |
Attempt 12 | |
######################################## | |
128+0 records in | |
128+0 records out | |
134217728 bytes (134 MB) copied, 0.278927 s, 481 MB/s | |
Error: Partition(s) 1 on /dev/loop0 have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes. | |
mklabel failed | |
mkpart swap success | |
mkpart ext2 success | |
mke2fs 1.42.9 (28-Dec-2013) | |
mkfs success | |
mount success | |
######################################## | |
Attempt 13 | |
######################################## | |
128+0 records in | |
128+0 records out | |
134217728 bytes (134 MB) copied, 0.358949 s, 374 MB/s | |
Error: Partition(s) 1 on /dev/loop0 have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes. | |
mklabel failed | |
mkpart swap success | |
mkpart ext2 success | |
mke2fs 1.42.9 (28-Dec-2013) | |
mkfs success | |
mount success | |
######################################## | |
Attempt 14 | |
######################################## | |
128+0 records in | |
128+0 records out | |
134217728 bytes (134 MB) copied, 0.245948 s, 546 MB/s | |
Error: Partition(s) 1 on /dev/loop0 have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes. | |
mklabel failed | |
mkpart swap success | |
mkpart ext2 success | |
mke2fs 1.42.9 (28-Dec-2013) | |
mkfs success | |
mount success | |
######################################## | |
Attempt 15 | |
######################################## | |
128+0 records in | |
128+0 records out | |
134217728 bytes (134 MB) copied, 0.430565 s, 312 MB/s | |
Error: Partition(s) 1 on /dev/loop0 have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes. | |
mklabel failed | |
mkpart swap success | |
mkpart ext2 success | |
mke2fs 1.42.9 (28-Dec-2013) | |
mkfs success | |
mount success | |
######################################## | |
Attempt 16 | |
######################################## | |
128+0 records in | |
128+0 records out | |
134217728 bytes (134 MB) copied, 0.250631 s, 536 MB/s | |
Error: Partition(s) 1 on /dev/loop0 have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes. | |
mklabel failed | |
mkpart swap success | |
mkpart ext2 success | |
mke2fs 1.42.9 (28-Dec-2013) | |
mkfs success | |
mount success | |
######################################## | |
Attempt 17 | |
######################################## | |
128+0 records in | |
128+0 records out | |
134217728 bytes (134 MB) copied, 0.390791 s, 343 MB/s | |
Error: Partition(s) 1 on /dev/loop0 have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes. | |
mklabel failed | |
mkpart swap success | |
mkpart ext2 success | |
mke2fs 1.42.9 (28-Dec-2013) | |
mkfs success | |
mount success | |
######################################## | |
Attempt 18 | |
######################################## | |
128+0 records in | |
128+0 records out | |
134217728 bytes (134 MB) copied, 0.422855 s, 317 MB/s | |
Error: Partition(s) 1 on /dev/loop0 have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes. | |
mklabel failed | |
mkpart swap success | |
mkpart ext2 success | |
mke2fs 1.42.9 (28-Dec-2013) | |
mkfs success | |
mount success | |
######################################## | |
Attempt 19 | |
######################################## | |
128+0 records in | |
128+0 records out | |
134217728 bytes (134 MB) copied, 1.09587 s, 122 MB/s | |
Error: Partition(s) 1 on /dev/loop0 have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes. | |
mklabel failed | |
mkpart swap success | |
mkpart ext2 success | |
mke2fs 1.42.9 (28-Dec-2013) | |
mkfs success | |
mount success | |
######################################## | |
Attempt 20 | |
######################################## | |
128+0 records in | |
128+0 records out | |
134217728 bytes (134 MB) copied, 0.354633 s, 378 MB/s | |
Error: Partition(s) 1 on /dev/loop0 have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes. | |
mklabel failed | |
mkpart swap success | |
mkpart ext2 success | |
mke2fs 1.42.9 (28-Dec-2013) | |
mkfs success | |
mount success | |
######################################## | |
Attempt 21 | |
######################################## | |
128+0 records in | |
128+0 records out | |
134217728 bytes (134 MB) copied, 0.390378 s, 344 MB/s | |
Error: Partition(s) 1 on /dev/loop0 have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes. | |
mklabel failed | |
mkpart swap success | |
mkpart ext2 success | |
mke2fs 1.42.9 (28-Dec-2013) | |
mkfs success | |
mount success |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment