Wednesday, May 1, 2019

boot - Remove second hard drive OS from grub



Years ago i installed ubuntu on a hard drive in my computer. A few days ago, after the release of 18.04, i bought a ssd and reinstalled everything on that. The old hdd is still linked in the computer - just to look up things.




GRUB does index the old hdd as secondary boot option. But i will never ever boot the old system again. So is there any way to remove the old hard drive from the grub options?



Short Answer



If you don't want third party utilities you can do it with a move command:



sudo mv /mnt/extra_distro/boot /mnt/extra_distro/boot.old



Then sudo update-grub of course.



Long Answer



Grub's OS_Prober checks each mounted drive for presence of /boot/* entries of vmlinuz* and initrd.img*. Then adds those options to your booted instance of grub. On my system for example:



$ sudo mount-menu.sh
Mount Partition



┌───────────┤ Use arrow, page, home & end keys. Tab toggle option ├────────────┐
│ NAME FSTYPE LABEL SIZE MOUNTPOINT │
│ │
│ sda 931.5G ↑│
│ ├─sda4 ntfs WINRETOOLS 450M ▒│
│ ├─sda2 128M ▒│
│ ├─sda5 ntfs Image 11.4G ▒│
│ ├─sda3 ntfs HGST_Win10 919G /mnt/d ▒│
│ └─sda1 vfat ESP 500M ▒│
│ nvme0n1 477G ▒│

│ ├─nvme0n1p5 ntfs 858M ▒│
│ ├─nvme0n1p3 16M ▒│
│ ├─nvme0n1p1 ntfs 450M ▒│
│ ├─nvme0n1p8 ntfs Shared_WSL+Linux 9G /mnt/e ▒│
│ ├─nvme0n1p6 ext4 Ubuntu18.04 23.7G ▮│
│ ├─nvme0n1p4 ntfs NVMe_Win10 390.4G /mnt/c ▒│
│ ├─nvme0n1p2 vfat 99M /boot/efi ▒│
│ ├─nvme0n1p9 swap Linux Swap 7.9G [SWAP] ▒│
│ └─nvme0n1p7 ext4 NVMe_Ubuntu_16.0 44.6G / ↓│
│ │

│ │

Blog Archive