heinrich23

generate offset disk image and mount it

Mar 25th, 2024 (edited)
8,882
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.61 KB | Source Code | 0 0
  1. #!/usr/bin/bash
  2. # generates an offset disk image from efi partition
  3. # which is added afterwards to a 512k * 8 size /dev/zero image
  4. # mounts the efi image with the corresponding specific offset
  5.  
  6. BLOCKSIZE=`echo '512  * 1024' | bc`
  7. SEEK=8
  8. OFFSET=$(echo "$BLOCKSIZE * $SEEK" | bc)
  9.  
  10. dd if=/dev/zero of=zero.img bs=512k count=8
  11. cp zero.img offset_disk.img
  12. dd if=/dev/nvme0n1p15 of=offset_disk.img bs=$BLOCKSIZE seek=$SEEK oflag=append
  13.  
  14. du -h -s *.img
  15. mkdir -p /mnt/efi
  16. mount -o loop,offset=$OFFSET offset_disk.img /mnt/efi
  17. df -h  | grep efi
  18.  
  19. sleep 1
  20. umount /mnt/efi
  21. rm -f zero.img offset_disk.img
  22. exit 0
  23.  
  24.  
Advertisement
Add Comment
Please, Sign In to add comment