PROBLEM
I had accidentally deleted the partition containing GRUB (/dev/sda1) due to which my Linux Mint installed on /dev/sda5 stopped booting.
Solution
So, I wanted to reinstall GRUB and edit it to boot my Linux Mint. I wanted GRUB and booting sectors on /dev/sda1 while my OS was in /dev/sda5. (I am using these as my defaults for this blog. Please use fdisk -l to figure out your partition names and numbers).
Getting a live USB : I created a new USB bootable drive of KDE Neon (It is a derivative of Ubuntu).
Installing GRUB : After booting KDE Neon, I opened the terminal and created the partition using fdisk.
Fdisk :
- $ sudo fdisk -l
Disk /dev/sda: 232.9 GiB, 250059350016 bytes, 488397168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x6c778d7d
/dev/sda2 97298430 488396799 391098370 186.5G 5 Extended
/dev/sda5 97298432 467601407 370302976 176.6G 83 Linux
/dev/sda6 467603456 488396799 20793344 9.9G 82 Linux swap / Solaris
- Here you can see that /dev/sda1 is missing
- So I used parted to see the free partitions
- $ sudo parted /dev/sda unit s print free
Model: ATA Samsung SSD 750 (scsi)
Disk /dev/sda: 488397168s
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 63s 97298429s 97298367s Free Space boot
2 97298430s 488396799s 391098370s extended
5 97298432s 467601407s 370302976s logical ext4
6 467603456s 488396799s 20793344s logical linux-swap(v1)
488396800s 488397167s 368s Free Space
- Enter the parted program in interactive mode
- $ sudo parted /dev/sda
- mkpart primary ext4 63s 97298429s
- quit
- The partition would have been created. You can check this by
- $ sudo fdisk -l
Installing GRUB
- $ mkdir /home/neon/temp
- $ sudo mount /dev/sda /home/neon/temp
- This mounts /dev/sda1 (the newly parted drive to a directory
- $ sudo grub-install --root-directory=/home/neon/temp /dev/sda
After this reboot the machine
GRUB Command Line
- (grub) set root=(hd0,5)
- (grub) linux /boot/vmlinuz-4.4.0-21-generic /dev/sda5
- (grub) initrd /boot/initrd.img-4.4.0-21-generic
- (grub) boot
ReplyDeleteVery Nice Article:
Hi Readers, If you wanna track your expenses and save money online or offline, Just Download Timelybills.app. It will show you all the ways to manage your expenditure without consuming your whole day. Please feel free to check out here. Thank you!
Timelybills.app