You are not logged in.

#1 2019-04-18 00:44:19

jimjamz
Member
From: Nagasaki, Japan
Registered: 2016-04-04
Posts: 189

Overwriting original GRUB with a Bunsenlabs installation to USB

I have a BL installation on my laptop's SSD (sda) with grub to choose my selected partition.

I have two USB sticks - one is empty (sdb) and the other contains BL Live (sdc).
I installed Bunsenlabs from the BL Live to the empty USB stick successfully.
However, upon completion, I realised that I had overwritten my original grub entries, which start BL from my SSD.
Now when powering on, if the USB sticks are not connected, grub rescue appears because it is looking for grub at sdb, not sda.

How can I revert the changes I have made, so that I can restore/re-install grub to look to sda instead of sdb?

Additionally, it might be useful to have both set up as grub entries so that I could choose between my original BL installation on sda and the new BL installation on the USB (sdb).  How can I achieve this?

Offline

#2 2019-04-18 04:52:49

ohnonot
...again
Registered: 2015-09-29
Posts: 5,592

Re: Overwriting original GRUB with a Bunsenlabs installation to USB

disable booting from USB first in your BIOS.

boot into the BL installation on your hard drive, and issue

grub-install /dev/sda

(supposing your SSD registers as /dev/sda)
and

update-grub

i'm not sure if it'll automatically pick up the usb sticks. they probably should be mounted when you do that.

Last edited by ohnonot (2019-04-18 04:54:02)

Offline

#3 2019-04-18 06:13:03

jimjamz
Member
From: Nagasaki, Japan
Registered: 2016-04-04
Posts: 189

Re: Overwriting original GRUB with a Bunsenlabs installation to USB

I'm using an Apple Macbook and am not able to boot from the USB automatically.  This would have to be manually done by holding the ALT key on startup.

When starting the laptop without the USB stick plugged in, it goes straight to grub rescue.  This is because, since the BL installation to the USB, it is looking for grub at sdb instead of sda.

Because I cannot get into the BL installation on sda, can I just use my other USB stick, BL Live, to start a live session and run the commands you suggested?

Last edited by jimjamz (2019-04-18 06:14:55)

Offline

#4 2019-04-18 06:53:11

hhh
Gaucho
From: High in the Custerdome
Registered: 2015-09-17
Posts: 16,169
Website

Re: Overwriting original GRUB with a Bunsenlabs installation to USB


I don't care what you do at home. Would you care to explain?

Offline

#5 2019-04-18 09:16:29

jimjamz
Member
From: Nagasaki, Japan
Registered: 2016-04-04
Posts: 189

Re: Overwriting original GRUB with a Bunsenlabs installation to USB

The added twist is that sda is LUKS encrypted.

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: gpt
Disk identifier: 0A88BA3C-EF26-4291-AD41-EF9331042E6D

Device        Start       End   Sectors   Size Type
/dev/sda1        40    409639    409600   200M EFI System
/dev/sda2    409640  23845871  23436232  11.2G Apple HFS/HFS+
/dev/sda3  23846912  24319999    473088   231M Linux filesystem
/dev/sda4  24320000 488396799 464076800 221.3G Linux filesystem

Using these guides:
https://ubuntuforums.org/showthread.php?t=2266650
https://sowhatisthesolution.wordpress.c … ed-system/

I was able to mount my encrypted partition:

cryptsetup luksOpen /dev/sda4 sda4_crypt

but was not able to idenify any volume groups or logical volumes:

$ sudo vgscan
  Reading volume groups from cache.
$
$ sudo lvscan
$

Now that the encrypted partition (sda4) is opened with LUKS, I can see the directories that I need to mount (/dev, /proc /sys etc...), which are now mounted under /media/user/475cac44-f48a-4d17-8659-611a06e1f961:

ls -la /media/user/475cac44-f48a-4d17-8659-611a06e1f961/
total 112
drwxr-xr-x   22 root root  4096 Jul  4  2018 .
drwxr-x---+   4 root root    80 Apr 18 08:57 ..
drwxr-xr-x    2 root root  4096 Mar  9 17:16 bin
drwxr-xr-x    2 root root  4096 Jun 16  2018 boot
drwxr-xr-x    5 root root  4096 Feb 20 20:46 dev
drwxr-xr-x  131 root root 12288 Apr 17 08:23 etc
drwxr-xr-x    3 root root  4096 Jun 16  2018 home
lrwxrwxrwx    1 root root    29 Jun 16  2018 initrd.img -> boot/initrd.img-4.9.0-6-amd64
lrwxrwxrwx    1 root root    29 Jun 16  2018 initrd.img.old -> boot/initrd.img-4.9.0-6-amd64
drwxr-xr-x   18 root root  4096 Apr 13 12:20 lib
drwxr-xr-x    2 root root  4096 Jun 16  2018 lib64
drwx------    2 root root 16384 Jun 16  2018 lost+found
drwxr-xr-x    4 root root  4096 Apr 17 08:23 media
drwxr-xr-x    6 root root  4096 Nov 25 14:41 mnt
drwxr-xr-x    4 root root  4096 Sep  8  2018 opt
drwxr-xr-x    2 root root  4096 Feb 23  2018 proc
drwx------   12 root root  4096 Apr 17 01:35 root
drwxr-xr-x    3 root root  4096 Feb 20 20:46 run
drwxr-xr-x    2 root root 12288 Apr 17 03:30 sbin
drwxr-xr-x    2 root root  4096 Apr 28  2018 srv
drwxr-xr-x    2 root root  4096 Feb 23  2018 sys
drwxrwxrwt    8 root root  4096 Apr 17 08:23 tmp
drwxr-xr-x   10 root root  4096 Jun 16  2018 usr
drwxr-xr-x   11 root root  4096 Jun 16  2018 var
lrwxrwxrwx    1 root root    26 Jun 16  2018 vmlinuz -> boot/vmlinuz-4.9.0-6-amd64
lrwxrwxrwx    1 root root    26 Jun 16  2018 vmlinuz.old -> boot/vmlinuz-4.9.0-6-amd64

However, I'm not sure if I should proceed to mount these directories and re-install GRUB until I've activated the volume group (vgchange) and/or mounted the logical volume first.

What should I do next?

Offline

#6 2019-04-18 21:20:23

hhh
Gaucho
From: High in the Custerdome
Registered: 2015-09-17
Posts: 16,169
Website

Re: Overwriting original GRUB with a Bunsenlabs installation to USB

I'm just feeding you my Internet searches. I have no experience with LUKS and it's been ages since I've had to recover grub. See if this guide works (adapt it for Debian, you'll see. Use the BL live-session to run the commands, replace Ubuntu with Debian or whatever, etc...)

https://ubuntuforums.org/showthread.php?t=2266650

-edit-

https://gist.github.com/samuelcolvin/43 … d0c9bfb068

Last edited by hhh (2019-04-18 21:23:52)


I don't care what you do at home. Would you care to explain?

Offline

#7 2019-04-18 23:42:25

jimjamz
Member
From: Nagasaki, Japan
Registered: 2016-04-04
Posts: 189

Re: Overwriting original GRUB with a Bunsenlabs installation to USB

Unfortunately, those links still pose the same concern I have (the first link being the same one I already posted earlier).  vchange -ay and lvscan still show nothing about the logical volumes I have.  Therefore, in my case, I would not know how to determine that /dev/ubuntu-vg/root (if I were using Ubuntu) as I cannot determine the volume group (In BunsenLabs, once the partition is mounted there is no /dev-???-vg/root.

What about using the Restore Mode option in BL Live boot options?  Could I not use the Restore Mode over the sda to reinstall grub?

Offline

Board footer

Powered by FluxBB