Guest User

Untitled

a guest
Nov 18th, 2013
49
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. #Logical partition:
  4. PART_NUM=5
  5. #Extended partition:
  6. EXT_PART_NUM=2
  7.  
  8. IMG_FILE=archlinux-hf-2013-07-22.img
  9.  
  10. dd if=/dev/zero of=$IMG_FILE bs=1024000 conv=notrunc seek=6000 count=1
  11.  
  12. PART_START=$(parted $IMG_FILE -ms unit s p | grep "^${PART_NUM}" | cut -f 2 -d:)
  13. [ "$PART_START" ] || exit 1
  14.  
  15. EXT_PART_START=$(parted $IMG_FILE -ms unit s p | grep "^${EXT_PART_NUM}" | cut -f 2 -d:)
  16. [ "$EXT_PART_START" ] || exit 1
  17.  
  18. fdisk $IMG_FILE <<EOF
  19. p
  20. d
  21. $EXT_PART_NUM
  22. n
  23. e
  24. $EXT_PART_NUM
  25. $EXT_PART_START
  26.  
  27. n
  28. l
  29. $PART_START
  30.  
  31. p
  32. w
  33. EOF
  34.  
  35. sudo kpartx -av $IMG_FILE
  36. sudo e2fsck -f /dev/mapper/loop0p$PART_NUM
  37. sudo resize2fs /dev/mapper/loop0p$PART_NUM
  38. sudo kpartx -dv $IMG_FILE
RAW Paste Data