Update without rebuilding the whole disk

This commit is contained in:
Marc
2021-11-26 19:06:36 +01:00
parent b24eba4e94
commit d64b9ccd25
4 changed files with 39 additions and 8 deletions
+1
View File
@@ -3,3 +3,4 @@ chibrax.tar.gz
rootfs rootfs
linux-firmware linux-firmware
disk.img disk.img
diskoffset
+1 -4
View File
@@ -1,4 +1,5 @@
#!/bin/bash #!/bin/bash
sudo umount rootfs/proc -R
sudo rm -rf rootfs/ sudo rm -rf rootfs/
sudo rm root.iso sudo rm root.iso
sudo rm chibrax.tar.gz sudo rm chibrax.tar.gz
@@ -24,8 +25,4 @@ sudo cp linux-firmware/* rootfs/usr/lib/firmware/ -r
sudo cp rootfs\ overrides/* rootfs/ -r sudo cp rootfs\ overrides/* rootfs/ -r
echo "chrooted exit when you are done"
sudo chroot rootfs /bin/bash
sudo rm rootfs/var/cache -rf sudo rm rootfs/var/cache -rf
+30
View File
@@ -0,0 +1,30 @@
#!/bin/bash
# we depend on a properly build rootfs
if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit
fi
if [ -z disk.img ]
then echo "Please run createLiveImage.sh first"
exit
fi
CHIBRAX_MOUNT_POINT="/tmp/chibraxMountPoint"
OFFSET=$(cat diskoffset)
losetup --offset $OFFSET -f disk.img
LOOP=$(losetup -a | grep -v deleted | cut -d':' -f 1)
echo ${LOOP} $CHIBRAX_MOUNT_POINT $OFFSET
mkdir $CHIBRAX_MOUNT_POINT -p
mount ${LOOP} $CHIBRAX_MOUNT_POINT
echo "coping rootfs"
cp rootfs/* $CHIBRAX_MOUNT_POINT -r
echo "done"
echo "finishing..."
umount $CHIBRAX_MOUNT_POINT
losetup -d $LOOP
+5 -2
View File
@@ -20,6 +20,8 @@ START_SECTOR=$(file disk.img | cut -d',' -f 8 | cut -d' ' -f3)
echo "Start sector :" $START_SECTOR echo "Start sector :" $START_SECTOR
OFFSET=$((512*$START_SECTOR)) OFFSET=$((512*$START_SECTOR))
echo $OFFSET > diskoffset
losetup --offset $OFFSET -f disk.img losetup --offset $OFFSET -f disk.img
LOOP=$(losetup -a | grep -v deleted | cut -d':' -f 1) LOOP=$(losetup -a | grep -v deleted | cut -d':' -f 1)
@@ -39,7 +41,7 @@ echo "installing grub"
arch-chroot $CHIBRAX_MOUNT_POINT grub-install --target=i386-pc ${LOOP_ROOT} --modules=part_msdos arch-chroot $CHIBRAX_MOUNT_POINT grub-install --target=i386-pc ${LOOP_ROOT} --modules=part_msdos
arch-chroot $CHIBRAX_MOUNT_POINT grub-mkconfig -o /boot/grub/grub.cfg arch-chroot $CHIBRAX_MOUNT_POINT grub-mkconfig -o /boot/grub/grub.cfg
PARTUUID=$(lsblk /dev/loop7 --fs | awk '{print $4}' | grep -v LABEL) PARTUUID=$(lsblk $LOOP --fs | awk '{print $4}' | grep -v LABEL)
echo "menuentry 'Chibrax OS' {" >> $CHIBRAX_MOUNT_POINT/boot/grub/grub.cfg echo "menuentry 'Chibrax OS' {" >> $CHIBRAX_MOUNT_POINT/boot/grub/grub.cfg
echo " set root='hd0,msdos1'" >> $CHIBRAX_MOUNT_POINT/boot/grub/grub.cfg echo " set root='hd0,msdos1'" >> $CHIBRAX_MOUNT_POINT/boot/grub/grub.cfg
@@ -49,4 +51,5 @@ echo "}" >> $CHIBRAX_MOUNT_
umount $CHIBRAX_MOUNT_POINT umount $CHIBRAX_MOUNT_POINT
losetup -d $LOOP_ROOT losetup -d $LOOP_ROOT
losetup -d $LOOP losetup -d $LOOP
chmod 755 disk.img #built by root but used by any, usefull to run the vm without root privileges
chmod 757 disk.img