Major correction of the disk image conception
This commit is contained in:
parent
d68604ba60
commit
6866877f03
5
Makefile
5
Makefile
|
@ -276,6 +276,11 @@ test: all install
|
||||||
-rtc base=localtime -m $(ram) -hda $(installdisk) \
|
-rtc base=localtime -m $(ram) -hda $(installdisk) \
|
||||||
-d cpu_reset,guest_errors,pcall,int 2> $(BUILDDIR)/qemu.log &
|
-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
|
test32: all install
|
||||||
@qemu-system-i386 -m $(ram) -hda $(installdisk) -d \
|
@qemu-system-i386 -m $(ram) -hda $(installdisk) -d \
|
||||||
cpu_reset,guest_errors,pcall,int 2> $(BUILDDIR)/qemu.log &
|
cpu_reset,guest_errors,pcall,int 2> $(BUILDDIR)/qemu.log &
|
||||||
|
|
|
@ -36,19 +36,47 @@ dd if=/dev/zero of=$1 bs=512 count=131072 status=progress
|
||||||
|
|
||||||
## Partition the image
|
## Partition the image
|
||||||
echo ${CL2}[create_disk.sh]${NC} Partitionning image... \(parted\)${CL3}
|
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}
|
a
|
||||||
udisksctl loop-setup --no-user-interaction --file $1
|
w
|
||||||
lpblock=$(/sbin/losetup -j $1 | cut -d ':' -f 1)
|
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}
|
echo ${CL2}[create_disk.sh]${NC} Sync image... \(sync\)${CL3}
|
||||||
sync
|
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')
|
mountpoint=$(udisksctl info -b $lpblock | grep MountPoint | cut -d ':' -f 2 | sed 's/ //g')
|
||||||
|
|
||||||
if [ -z $mountpoint ];
|
if [ -z $mountpoint ];
|
||||||
|
@ -57,14 +85,19 @@ then
|
||||||
return 13
|
return 13
|
||||||
fi
|
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}
|
echo ${CL2}[create_disk.sh]${NC} Sync image... \(sync\)${CL3}
|
||||||
sync
|
sync
|
||||||
|
|
||||||
|
## Unmount
|
||||||
echo ${CL2}[create_disk.sh]${NC} Unmount image... \(udisksctl\)${CL3}
|
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}
|
echo ${CL2}[create_disk.sh]${CL} Terminated without error.${CL3}
|
|
@ -31,7 +31,7 @@ NC='\033[1;37m'
|
||||||
set -e #exit if error
|
set -e #exit if error
|
||||||
|
|
||||||
echo ${CL2}[create_disk.sh]${NC} Mount image... \(udisksctl\)${CL3}
|
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)
|
lpblock=$(/sbin/losetup -j $1 | cut -d ':' -f 1)
|
||||||
|
|
||||||
echo ${CL2}[create_disk.sh]${NC} Sync image... \(sync\)${CL3}
|
echo ${CL2}[create_disk.sh]${NC} Sync image... \(sync\)${CL3}
|
||||||
|
|
Loading…
Reference in New Issue