Skip to content

Instantly share code, notes, and snippets.

@NrI3
Last active December 2, 2018 16:25
Show Gist options
  • Select an option

  • Save NrI3/0781f1d3e38ddfa0c4b060c3eee33db0 to your computer and use it in GitHub Desktop.

Select an option

Save NrI3/0781f1d3e38ddfa0c4b060c3eee33db0 to your computer and use it in GitHub Desktop.
Install grub on USB or HardDisk
:: List disk and system file mounted
# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdb 8:16 0 298,1G 0 disk
├─sdb1 8:17 0 30G 0 part
└─sdb2 8:18 0 5G 0 part
:: List device
# fdisk -l
Disco /dev/sdb: 298,1 GiB, 320072933376 bytes, 625142448 sectores
Unidades: sectores de 1 * 512 = 512 bytes
Tamaño de sector (lógico/físico): 512 bytes / 512 bytes
Tamaño de E/S (mínimo/óptimo): 512 bytes / 512 bytes
Tipo de etiqueta de disco: dos
Identificador del disco: 0x47ad2441
Disposit. Inicio Comienzo Final Sectores Tamaño Id Tipo
/dev/sdb1 2048 62916607 62914560 30G 83 Linux
/dev/sdb2 62916608 73402367 10485760 5G b W95 FAT32
:: Umount all system file of /dev/sdb1 for start installation
:: Create directory to mount sdb1
# mkdir /mnt/usb
:: Mount directory
# mount /dev/sdb1 /mnt/usb
:: Create directory for config file of grub
# mkdir -p /mnt/usb/etc/default
:: Copy grub binary
# cp /etc/default/grub /mnt/usb/etc/default/
# cp -a /etc/grub.d/ /mnt/usb/etc/
:: install grub on /dev/sdb
# grub-install --target=i386-pc --debug --boot-directory=/mnt/usb/boot /dev/sdb
:: Creating config file
# grub-mkconfig -o /mnt/usb/boot/grub/grub.cfg
:: CONFIG FILE /etc/boot/grub/grub.cfg
:: Create fat32 partition in hd0
:: copy iso files into it
menuentry "Start Windows Installation" {
set root=(hd0,msdos2)
insmod ntfs
insmod search_label
search --no-floppy --label WIN7
ntldr /bootmgr
boot
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment