Major correction of the disk image conception

This commit is contained in:
Adrien Bourmault 2019-11-18 23:28:44 +01:00
parent d68604ba60
commit 6866877f03
3 changed files with 49 additions and 11 deletions

View File

@ -276,6 +276,11 @@ test: all install
-rtc base=localtime -m $(ram) -hda $(installdisk) \
-d cpu_reset,guest_errors,pcall,int 2> $(BUILDDIR)/qemu.log &
@qemu-system-x86_64 -vga std -soundhw pcspk -s \
-rtc base=localtime -m 8192 -hda /dev/sdc \
-d cpu_reset,guest_errors,pcall,int &
test32: all install
@qemu-system-i386 -m $(ram) -hda $(installdisk) -d \
cpu_reset,guest_errors,pcall,int 2> $(BUILDDIR)/qemu.log &

View File

@ -36,19 +36,47 @@ dd if=/dev/zero of=$1 bs=512 count=131072 status=progress
## Partition the image
echo ${CL2}[create_disk.sh]${NC} Partitionning image... \(parted\)${CL3}
/sbin/parted --script $1 mktable msdos mkpart primary 2048s 100% set 1 boot on
#/sbin/parted --script $1 mktable msdos mkpart primary 2048s 100% set 1 boot on
/sbin/fdisk $1 > /dev/null <<EEOF
n
p
1
## Format
echo ${CL2}[create_disk.sh]${NC} Formatting image... \(mkdosfs\)${CL3}
/sbin/mkdosfs -F32 -f 2 $1
echo ${CL2}[create_disk.sh]${NC} Mount image... \(udisksctl\)${CL3}
udisksctl loop-setup --no-user-interaction --file $1
lpblock=$(/sbin/losetup -j $1 | cut -d ':' -f 1)
a
w
EEOF
## Mount
echo ${CL2}[create_disk.sh]${NC} Mount image... \(losetup\)${CL3}
lpblock=$(/sbin/losetup -f)
sudo losetup $lpblock $1 -o 1048576
echo ${CL2}[create_disk.sh]${NC} Sync image... \(sync\)${CL3}
sync
## Format
echo ${CL2}[create_disk.sh]${NC} Formatting image... \(mkdosfs\)${CL3}
sudo mkdosfs -F32 -f 2 $lpblock
echo ${CL2}[create_disk.sh]${NC} Sync image... \(sync\)${CL3}
sync
## Detach
echo ${CL2}[create_disk.sh]${NC} Unmount image... \(udisksctl\)${CL3}
sudo losetup -d $lpblock
## Mount
echo ${CL2}[create_disk.sh]${NC} Mount image... \(losetup\)${CL3}
lpblock=$(/sbin/losetup -f)
sudo losetup $lpblock $1 -o 1048576
lpblockbase=$(/sbin/losetup -f)
sudo losetup $lpblockbase $1
sudo udisksctl mount -b $lpblock --no-user-interaction
## Sync
echo ${CL2}[create_disk.sh]${NC} Sync image... \(sync\)${CL3}
sync
# Get the mountpoint
mountpoint=$(udisksctl info -b $lpblock | grep MountPoint | cut -d ':' -f 2 | sed 's/ //g')
if [ -z $mountpoint ];
@ -57,14 +85,19 @@ then
return 13
fi
echo ${CL2}[create_disk.sh]${NC} Install grub into $lpblock as $mountpoint... \(grub-install\)${CL3}
## Install Grub
echo ${CL2}[create_disk.sh]${NC} Install grub into $lpblockbase as $mountpoint... \(grub-install\)${CL3}
sudo grub-install --force --target=i386-pc --root-directory=$mountpoint --boot-directory=$mountpoint/boot --no-floppy --modules="part_msdos biosdisk fat multiboot configfile" $lpblock
sudo grub-install --force --target=i386-pc --root-directory=$mountpoint --boot-directory=$mountpoint/boot --no-floppy --modules="part_msdos biosdisk fat multiboot configfile" $lpblockbase
## Sync
echo ${CL2}[create_disk.sh]${NC} Sync image... \(sync\)${CL3}
sync
## Unmount
echo ${CL2}[create_disk.sh]${NC} Unmount image... \(udisksctl\)${CL3}
udisksctl unmount --no-user-interaction -b $lpblock
sudo udisksctl unmount --no-user-interaction -b $lpblock
sudo losetup -d $lpblock
sudo losetup -d $lpblockbase
echo ${CL2}[create_disk.sh]${CL} Terminated without error.${CL3}

View File

@ -31,7 +31,7 @@ NC='\033[1;37m'
set -e #exit if error
echo ${CL2}[create_disk.sh]${NC} Mount image... \(udisksctl\)${CL3}
udisksctl loop-setup --no-user-interaction --file $1
udisksctl loop-setup --offset 1048576 --no-user-interaction --file $1
lpblock=$(/sbin/losetup -j $1 | cut -d ':' -f 1)
echo ${CL2}[create_disk.sh]${NC} Sync image... \(sync\)${CL3}