项目作者: neurobin

项目描述 :
Fix a broken grub and get back the grub menu
高级语言: Shell
项目地址: git://github.com/neurobin/grubfix.git
创建时间: 2017-03-31T05:26:02Z
项目社区:https://github.com/neurobin/grubfix

开源协议:

下载


A bash script to fix the grub menu.

Usage:

Simply run the script:

  1. sudo ./grubfix

It will guide you step by step:

  1. **********************************************************
  2. Please choose the device where your system is installed.
  3. A star (*) sign after the device id means it's bootable
  4. It is not necessary for a system partition to be bootable
  5. Be careful. We need the device id where the filesystem
  6. resides, not where it is booted from.
  7. **********************************************************
  8. 1) /dev/sdb3 148510720 206970879 58460160 27.9G Linux filesystem
  9. 2) /dev/sdb4 206970880 264634367 57663488 27.5G Linux filesystem
  10. 3) /dev/sdb6 383746048 500103167 116357120 55.5G Linux filesystem
  11. 4) exit
  12. Choose a device (#?): 2
  13. *** you have chosen: /dev/sdb4
  14. *** Giving more info for confirmation
  15. *** 'fdisk -l /dev/sdb4' says:
  16. Disk /dev/sdb4: 27.5 GiB, 29523705856 bytes, 57663488 sectors
  17. Units: sectors of 1 * 512 = 512 bytes
  18. Sector size (logical/physical): 512 bytes / 4096 bytes
  19. I/O size (minimum/optimal): 4096 bytes / 4096 bytes
  20. *** 'blkid /dev/sdb4' says:
  21. /dev/sdb4: UUID="c0664c62-699d-4a8e-ae2f-81ee87975527" TYPE="ext4" PARTLABEL="Basic data partition" PARTUUID="6c56a7a0-b9b0-01d4-d043-2830d85cea00"
  22. === Please confirm (Y/n)?: y
  23. *** /dev/sdb4 confirmed...
  24. ***********************************************************
  25. Please choose the uefi boot device.
  26. Be careful, we need the device id where it is booted from,
  27. not where the root filesystem resides.
  28. ***********************************************************
  29. 1) /dev/sda1 2048 1333247 1331200 650M EFI System
  30. 2) /dev/sdb1 2048 1333247 1331200 650M EFI System
  31. 3) No uefi
  32. 4) exit
  33. Choose a efi device (#?): 1
  34. *** you have chosen: /dev/sda1
  35. *** Giving more info for confirmation
  36. Partition 1 does not start on physical sector boundary.
  37. Partition 2 does not start on physical sector boundary.
  38. Partition 3 does not start on physical sector boundary.
  39. *** 'fdisk -l /dev/sda1' says:
  40. Disk /dev/sda1: 650 MiB, 681574400 bytes, 1331200 sectors
  41. Units: sectors of 1 * 512 = 512 bytes
  42. Sector size (logical/physical): 512 bytes / 4096 bytes
  43. I/O size (minimum/optimal): 4096 bytes / 4096 bytes
  44. Disklabel type: dos
  45. Disk identifier: 0x69737369
  46. Device Boot Start End Sectors Size Id Type
  47. /dev/sda1p1 1869771365 2038460886 168689522 80.4G 69 unknown
  48. /dev/sda1p2 1701519481 3571400945 1869881465 891.6G 73 unknown
  49. /dev/sda1p3 2573 2573 0 0B 74 unknown
  50. /dev/sda1p4 2885681152 2885733566 52415 25.6M 0 Empty
  51. Partition table entries are not in disk order.
  52. *** 'blkid /dev/sda1' says:
  53. /dev/sda1: LABEL="ESP" UUID="9382-8550" TYPE="vfat" PARTLABEL="Basic data partition" PARTUUID="93828d50-bca4-01d4-a842-c149525eea00"
  54. === Please confirm (Y/n)?: y
  55. *** /dev/sda1 confirmed...
  56. *** mounted /dev/sdb4 in /mnt
  57. *** mounted /dev in /mnt/dev
  58. *** mounted /dev/pts in /mnt/dev/pts
  59. *** mounted /proc in /mnt/proc
  60. *** mounted /sys in /mnt/sys
  61. *** chroot: running mount /dev/sda1 /boot/efi ...
  62. *** chroot: running grub-install ...
  63. Installing for x86_64-efi platform.
  64. Installation finished. No error reported.
  65. *** chroot: running update-grub ...
  66. Generating grub configuration file ...
  67. Found theme: /usr/share/grub/themes/manjaro/theme.txt
  68. Found linux image: /boot/vmlinuz-4.19-x86_64
  69. Found initrd image: /boot/intel-ucode.img /boot/initramfs-4.19-x86_64.img
  70. Found initrd fallback image: /boot/initramfs-4.19-x86_64-fallback.img
  71. Found Ubuntu 18.04.2 LTS (18.04) on /dev/sdb3
  72. Found memtest86+ image: /boot/memtest86+/memtest.bin
  73. done
  74. *** chroot: running umount /boot/efi
  75. *** unmounted /mnt/sys
  76. *** unmounted /mnt/proc
  77. *** unmounted /mnt/dev/pts
  78. *** unmounted /mnt/dev
  79. *** unmounted /mnt

If it’s more complex than that, then this script also allows you to open a chroot terminal on your target system, run it with -co option:

  1. sudo ./grubfix -co

In chroot only mode, it will not do any additional task other than opening a terminal window with chroot. You can then use that terminal to configure your target system and install or modify pacakges to correct problems.