add floppy commands
This commit is contained in:
parent
c1f468a8b1
commit
fddf498930
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
.idea/
|
||||
.vscode/
|
||||
|
59
src/floppy-attach
Executable file
59
src/floppy-attach
Executable file
@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
MEDIADIR="/media/gmgauthier"
|
||||
format=0 # Don't format disk images that already exist
|
||||
|
||||
# get name of freshly created blank disk, or create one
|
||||
if [ $# -eq 0 ]; then
|
||||
echo ">>> NEW 1.44MB DISK IS BEING CREATED..."
|
||||
PREFIX="floppy"
|
||||
RANDO=$(od -An -N4 -i < /dev/urandom|sed 's/[ -]//g')
|
||||
DISK="$PREFIX$RANDO"
|
||||
dd if=/dev/zero of=$DISK.img bs=1k count=1440
|
||||
format=1
|
||||
else
|
||||
DISK=$1
|
||||
if [ $# -eq 1 ]; then
|
||||
echo "Second argument should be disk size in kbytes: 360, 720, 1440"
|
||||
exit 1
|
||||
fi
|
||||
SIZE=$2
|
||||
if ! [ -f $DISK.img ]; then
|
||||
dd if=/dev/zero of=$DISK.img bs=1k count=$SIZE
|
||||
format=1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Find the next available loop device on the system
|
||||
echo ">>> LOOP DEVICE IS BEING IDENTIFIED..."
|
||||
list=$(losetup -O name|sed 's/\/dev\/loop//g'|sed 's/NAME//g'|sort - --sort=human-numeric)
|
||||
### listarr=(${(@s: :)list}) # zsh version of the array generator
|
||||
listarr=($(echo $list | tr " " "\n")) #bash version of array generator
|
||||
lastdev=${listarr[-1]}
|
||||
lastdevnum=$((lastdev))
|
||||
nextdev=$((lastdevnum+1))
|
||||
|
||||
# allocate the next available loop device, format the disk, and mount it.
|
||||
nextdevname="/dev/loop$nextdev"
|
||||
echo ">>> LOOP DEVICE $nextdevname RESERVED FOR DISK: $DISK.img"
|
||||
|
||||
sudo losetup $nextdevname $DISK.img
|
||||
|
||||
if [ $format -eq 1 ]; then
|
||||
echo ">>> DISK IMAGE IS RAW AND WILL BE FORMATTED"
|
||||
sudo mkfs -t vfat $nextdevname
|
||||
fi
|
||||
|
||||
if ! [ -d $MEDIADIR/$DISK ]; then
|
||||
echo ">>> MOUNT DIRECTORY NOT FOUND. CREATING DIRECTORY NOW."
|
||||
sudo mkdir $MEDIADIR/$DISK
|
||||
fi
|
||||
|
||||
echo ">>> DISK $DISK.img MOUNTING AT LOCATION: $MEDIADIR/$DISK"
|
||||
sudo mount $DISK.img $MEDIADIR/$DISK
|
||||
|
||||
if [ $format -eq 1 ]; then
|
||||
echo ">>> DISK INFORMATION BEING COPIED TO $DISK.img"
|
||||
sudo fdisk -l $nextdevname >> $DISK-fdisk.txt
|
||||
sudo cp $DISK-fdisk.txt $MEDIADIR/$DISK/$DISK.txt && rm $DISK-fdisk.txt
|
||||
fi
|
8
src/floppy-burn
Executable file
8
src/floppy-burn
Executable file
@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if [[ $# -ne 1 ]]; then
|
||||
echo "Supply the disk image filepath to burn to disk"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sudo dd if="$1" of=/dev/sda bs=512 conv=sync ; sync
|
23
src/floppy-make
Executable file
23
src/floppy-make
Executable file
@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
DISKDIR="/home/gmgauthier/Retro/BLANKS"
|
||||
|
||||
# get name of freshly created blank disk, or create one
|
||||
if [ $# -eq 0 ]; then
|
||||
echo ">>> NEW 1.44MB DISK IS BEING CREATED..."
|
||||
PREFIX="floppy"
|
||||
RANDO=$(od -An -N4 -i < /dev/urandom|sed 's/[ -]//g')
|
||||
DISK="$PREFIX$RANDO"
|
||||
dd if=/dev/zero of=$DISKDIR/$DISK.img bs=1k count=1440
|
||||
else
|
||||
DISK=$1
|
||||
if [ $# -eq 1 ]; then
|
||||
echo "Second argument should be disk size in kbytes: 360, 720, 1440"
|
||||
exit 1
|
||||
fi
|
||||
SIZE=$2
|
||||
if ! [ -f $DISK.img ]; then
|
||||
dd if=/dev/zero of=$DISKDIR/$DISK.img bs=1k count=$SIZE
|
||||
fi
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user