[Solved] Linux mint 20 grub problem

Questions about Grub, UEFI,the liveCD and the installer
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
spamator12
Level 4
Level 4
Posts: 214
Joined: Mon Feb 04, 2019 11:57 am

[Solved] Linux mint 20 grub problem

Post by spamator12 »

I have 3 HDD (SSD).

1 - 256 GB unused
2 - 128GB for linux mint 'HOME' folder
3 - 128GB for 'BOOT' folder (2gb) and for linux main '/' linux mint 20 folder

I have installed linux mint 20 (I'm VERY pleased with it) in a way so I can simply replace/save 'HOME' folder - so my data is mutable.

I have installed windows 7 on disck 1 (the on that has literally nothing on it - so my son can play WoW game, cause wine and lutris run this game but show graphic glitches). And now grub CAN'T start linux. What to do?

EDIT: I guess this forum part - viewforum.php?f=46 suits better for this kind of question, mod can move it if he likes.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 4 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
spamegg
Level 14
Level 14
Posts: 5038
Joined: Mon Oct 28, 2019 2:34 am
Contact:

Re: Linux mint 20 grub problem

Post by spamegg »

You said "now grub can start linux".
Do you mean "grub CAN'T start linux"?
Anyway, we need more information. Can you boot into your system with a GParted Live USB and provide the output of

Code: Select all

inxi -Fxxxz

Code: Select all

cat /etc/fstab

Code: Select all

cat /etc/default/grub
spamator12
Level 4
Level 4
Posts: 214
Joined: Mon Feb 04, 2019 11:57 am

Re: Linux mint 20 grub problem

Post by spamator12 »

@spamegg, yes misclick :)

Gonna make a live USB with some linux and send you data ASAP. It is possible with linux mint installation disk - does it have GParted I could use, or should I download GParted USB?
User avatar
Moem
Level 22
Level 22
Posts: 16229
Joined: Tue Nov 17, 2015 9:14 am
Location: The Netherlands
Contact:

Re: Linux mint 20 grub problem

Post by Moem »

The installation disk (live Mint disk) has GParted preinstalled.
Image

If your issue is solved, kindly indicate that by editing the first post in the topic, and adding [SOLVED] to the title. Thanks!
spamator12
Level 4
Level 4
Posts: 214
Joined: Mon Feb 04, 2019 11:57 am

Re: Linux mint 20 grub problem

Post by spamator12 »

[main problem is with grub - it does not start linux system]
- when I choose to start from second disk:

Code: Select all

error: symbol 'grub_calloc' not found


@Moem thx! But too late, I get GP USB - https://gparted.org/liveusb.php

EDIT:

Oh common, this GP live USB does not discover pendrives, I could not make a file with commands result, or save any screenshots....

Gonna try mint live disk, maybe it recognize hooked USB so I can save result of operations.

EDIT2:

Code: Select all

mint@mint:~$ inxi -Fxxxz
System:
  Kernel: 5.4.0-58-generic x86_64 bits: 64 compiler: gcc v: 9.3.0 
  Desktop: Cinnamon 4.8.5 wm: muffin 4.8.0 dm: LightDM 1.30.0 
  Distro: Linux Mint 20.1 Ulyssa base: Ubuntu 20.04 focal 
Machine:
  Type: Laptop System: Dell product: Precision M6600 v: 01 serial: <filter> 
  Chassis: type: 9 serial: <filter> 
  Mobo: Dell model: X v: A00 serial: <filter> BIOS: Dell v: A18 
  date: 09/14/2018 
Battery:
  ID-1: BAT0 charge: 47.2 Wh condition: 47.2/99.9 Wh (47%) volts: 12.8/11.1 
  model: Sanyo DELL T4DTX44 type: Li-ion serial: <filter> status: Full 
CPU:
  Topology: Quad Core model: Intel Core i7-2720QM bits: 64 type: MT MCP 
  arch: Sandy Bridge rev: 7 L2 cache: 6144 KiB 
  flags: avx lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx bogomips: 35119 
  Speed: 797 MHz min/max: 800/3300 MHz Core speeds (MHz): 1: 799 2: 798 
  3: 798 4: 797 5: 798 6: 798 7: 798 8: 798 
Graphics:
  Device-1: NVIDIA GF104GLM [Quadro 3000M] vendor: Dell driver: nouveau 
  v: kernel bus ID: 01:00.0 chip ID: 10de:0e3a 
  Display: x11 server: X.Org 1.20.8 driver: modesetting unloaded: fbdev,vesa 
  resolution: 1920x1080~60Hz 
  OpenGL: renderer: NVC4 v: 4.3 Mesa 20.0.8 direct render: Yes 
Audio:
  Device-1: Intel 6 Series/C200 Series Family High Definition Audio 
  vendor: Dell driver: snd_hda_intel v: kernel bus ID: 00:1b.0 
  chip ID: 8086:1c20 
  Device-2: NVIDIA GF104 High Definition Audio vendor: Dell 
  driver: snd_hda_intel v: kernel bus ID: 01:00.1 chip ID: 10de:0beb 
  Sound Server: ALSA v: k5.4.0-58-generic 
Network:
  Device-1: Intel 82579LM Gigabit Network vendor: Dell driver: e1000e 
  v: 3.2.6-k port: 8040 bus ID: 00:19.0 chip ID: 8086:1502 
  IF: eno1 state: down mac: <filter> 
  Device-2: Intel Centrino Ultimate-N 6300 driver: iwlwifi v: kernel 
  port: 7000 bus ID: 03:00.0 chip ID: 8086:422b 
  IF: wlp3s0 state: up mac: <filter> 
Drives:
  Local Storage: total: 484.23 GiB used: 103.9 MiB (0.0%) 
  ID-1: /dev/sda vendor: Samsung model: MZ7PC256HAFU-000L7 size: 238.47 GiB 
  speed: 6.0 Gb/s serial: <filter> rev: 7L1Q scheme: MBR 
  ID-2: /dev/sdb vendor: Kingston model: SV300S37A120G size: 111.79 GiB 
  speed: 6.0 Gb/s serial: <filter> rev: BBF0 temp: 35 C scheme: MBR 
  ID-3: /dev/sdc vendor: Samsung model: SSD 840 PRO Series size: 119.24 GiB 
  speed: 3.0 Gb/s serial: <filter> rev: 6B0Q scheme: MBR 
  ID-4: /dev/sdd type: USB vendor: Generic model: N/A size: 14.73 GiB 
  serial: <filter> rev: 1.11 scheme: MBR 
Partition:
  ID-1: / size: 15.66 GiB used: 63.4 MiB (0.4%) fs: overlay source: ERR-102 
  ID-2: /var/log size: 12.56 GiB used: 40.5 MiB (0.3%) fs: ext4 
  dev: /dev/sdd3 
  ID-3: swap-1 size: 7.48 GiB used: 0 KiB (0.0%) fs: swap dev: /dev/sdb5 
Sensors:
  System Temperatures: cpu: 65.0 C mobo: 48.0 C sodimm: 44.0 C gpu: nouveau 
  temp: 25 C 
  Fan Speeds (RPM): cpu: 0 
Info:
  Processes: 277 Uptime: 2m Memory: 31.32 GiB used: 1.13 GiB (3.6%) 
  Init: systemd v: 245 runlevel: 5 Compilers: gcc: 9.3.0 alt: 9 Shell: bash 
  v: 5.0.17 running in: gnome-terminal inxi: 3.0.38 

================================================

mint@mint:~$ cat /etc/fstab
overlay / overlay rw 0 0
tmpfs /tmp tmpfs nosuid,nodev 0 0

===========================================

mint@mint:~$ cat /etc/default/grub
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
#   info -f grub -n 'Simple configuration'

GRUB_DEFAULT=0
GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=0
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"
mint@mint:~$ 
EDIT3:

Code: Select all

mint@mint:~$ sudo fdisk -l
Disk /dev/loop0: 1.8 GiB, 1912557568 bytes, 3735464 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


Disk /dev/sda: 238.49 GiB, 256060514304 bytes, 500118192 sectors
Disk model: SAMSUNG MZ7PC256
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: 0xeaed9473

Device     Boot   Start       End   Sectors  Size Id Type
/dev/sda1  *       2048   1026047   1024000  500M  7 HPFS/NTFS/exFAT
/dev/sda2       1026048 500115455 499089408  238G  7 HPFS/NTFS/exFAT


Disk /dev/sdb: 111.81 GiB, 120034123776 bytes, 234441648 sectors
Disk model: KINGSTON SV300S3
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: 0x8e9cf7c2

Device     Boot     Start       End   Sectors   Size Id Type
/dev/sdb1            2048 218752047 218750000 104.3G 83 Linux
/dev/sdb2       218753022 234440703  15687682   7.5G  5 Extended
/dev/sdb5       218753024 234440703  15687680   7.5G 82 Linux swap / Solaris


Disk /dev/sdc: 119.25 GiB, 128034594304 bytes, 250067567 sectors
Disk model: Samsung SSD 840 
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: 0xcc78a9e3

Device     Boot     Start       End   Sectors  Size Id Type
/dev/sdc1            2048 247566335 247564288  118G 83 Linux
/dev/sdc2  *    247566336 250066943   2500608  1.2G 83 Linux


Disk /dev/sdd: 14.74 GiB, 15811477504 bytes, 30881792 sectors
Disk model: Mass-Storage    
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: 0x5b137964

Device     Boot   Start      End  Sectors  Size Id Type
/dev/sdd1  *          0  3974271  3974272  1.9G  0 Empty
/dev/sdd2           632     8567     7936  3.9M ef EFI (FAT-12/16/32)
/dev/sdd3       3977216 30881791 26904576 12.8G 83 Linux


Disk /dev/sde: 60.38 GiB, 64826114048 bytes, 126613504 sectors
Disk model: STORAGE DEVICE  
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: 0x00010010

Device     Boot Start       End   Sectors  Size Id Type
/dev/sde1       32768 126613503 126580736 60.4G  7 HPFS/NTFS/exFAT
BTW I still could not copy files to second USB (it says that system could not mount it)... strange...

EDIT4:
I'm thinking about
https://stackoverflow.com/questions/632 ... buntu-boot
BUT I have HOME and BOOT folder on one drive (two partitions) and MAIN ('/') and SWAP on other drive (2 partitions). Will grub know how to set up everything, and if no, how I can point for him what is what manually?
User avatar
AndyMH
Level 21
Level 21
Posts: 13716
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: Linux mint 20 grub problem

Post by AndyMH »

BTW I still could not copy files to second USB (it says that system could not mount it)... strange...
You haven't said which drive it is in your fdisk output, but...

Code: Select all

Disk /dev/sdd: 14.74 GiB, 15811477504 bytes, 30881792 sectors
Disk model: Mass-Storage    
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: 0x5b137964

Device     Boot   Start      End  Sectors  Size Id Type
/dev/sdd1  *          0  3974271  3974272  1.9G  0 Empty
sdd1 is starting at 0, so while fdisk identifies the drive as having a legacy partition table, there is nowhere for it to live. How did you format this drive?

And...

Code: Select all

Disk /dev/sde: 60.38 GiB, 64826114048 bytes, 126613504 sectors
Disk model: STORAGE DEVICE  
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: 0x00010010

Device     Boot Start       End   Sectors  Size Id Type
/dev/sde1       32768 126613503 126580736 60.4G  7 HPFS/NTFS/exFAT
The first partition normally starts at sector 2048, so again how did you format this drive?
BUT I have HOME and BOOT folder on one drive (two partitions) and MAIN ('/') and SWAP on other drive (2 partitions).
Unusual, you haven't needed a separate boot partition for years (not to be confused with an EFI partition and all your drives are legacy implying legacy boot).

Code: Select all

/dev/sdc1            2048 247566335 247564288  118G 83 Linux
/dev/sdc2  *    247566336 250066943   2500608  1.2G 83 Linux
Assume these are your boot and / partitions, waste of space because you are very unlikely to use much more than 30GB in / with a separate /home partition.

Code: Select all

/dev/sdb1            2048 218752047 218750000 104.3G 83 Linux
/dev/sdb2       218753022 234440703  15687682   7.5G  5 Extended
/dev/sdb5       218753024 234440703  15687680   7.5G 82 Linux swap / Solaris
Assume this is the drive with your /home partition, why have you put your swap partition in an extended partition (you can have up to 4 primary partitions on a legacy format drive)?
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
spamator12
Level 4
Level 4
Posts: 214
Joined: Mon Feb 04, 2019 11:57 am

Re: Linux mint 20 grub problem

Post by spamator12 »

Disk /dev/sdd: 14.74 GiB, 15811477504 bytes, 30881792 sectors - is mint install disc (pendrive) - not related to a grub a problem
Disk /dev/sde: 60.38 GiB, 64826114048 bytes, 126613504 sectors - this is pendrive - not related with a grub problem

"Assume these are your boot and / partitions, waste of space because you are very unlikely to use much more than 30GB in / with a separate /home partition."

You can always put something at this drive AND you dont have HOME and / folders together on one partition, so when something bad happen it is easier to recover you data.

"Assume this is the drive with your /home partition, why have you put your swap partition in an extended partition (you can have up to 4 primary partitions on a legacy format drive)?"

When I have install mint there was info that... it was better to put swap file on other partition I guess... but maybe I don't remember correctly.

Anyway the idea was to have BOOT folder separately so GRUB can always check it, and load proper systems. Also windows won't replace grub data cause it is on other drive and not related to windows.With BOOT folder partition placed separately I can have many linux systems to choose from - all point to one BOOT (if I get this right), also I can leave BOOT unencrypted and encrypt the rest of the data.


But the original question is not answered anyway.



EDIT:

Code: Select all

mint@mint:~$ sudo fdisk -l
Disk /dev/loop0: 1.8 GiB, 1912557568 bytes, 3735464 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


Disk /dev/sda: 238.49 GiB, 256060514304 bytes, 500118192 sectors
Disk model: SAMSUNG MZ7PC256
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: 0xeaed1473

Device     Boot   Start       End   Sectors  Size Id Type
/dev/sda1  *       2048   1026047   1024000  500M  7 HPFS/NTFS/exFAT
/dev/sda2       1026048 500115455 499089408  238G  7 HPFS/NTFS/exFAT


Disk /dev/sdb: 111.81 GiB, 120034123776 bytes, 234441648 sectors
Disk model: KINGSTON SV300S3
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: 0x8e9cf7c2

Device     Boot     Start       End   Sectors   Size Id Type
/dev/sdb1            2048 218752047 218750000 104.3G 83 Linux
/dev/sdb2       218753022 234440703  15687682   7.5G  5 Extended
/dev/sdb5       218753024 234440703  15687680   7.5G 82 Linux swap / Solaris


Disk /dev/sdc: 119.25 GiB, 128034594304 bytes, 250067567 sectors
Disk model: Samsung SSD 840 
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: 0xcc78a1e3

Device     Boot     Start       End   Sectors  Size Id Type
/dev/sdc1            2048 247566335 247564288  118G 83 Linux
/dev/sdc2  *    247566336 250066943   2500608  1.2G 83 Linux


Disk /dev/sdd: 14.74 GiB, 15811477504 bytes, 30881792 sectors
Disk model: Mass-Storage    
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: 0x5b137364

Device     Boot   Start      End  Sectors  Size Id Type
/dev/sdd1  *          0  3974271  3974272  1.9G  0 Empty
/dev/sdd2           632     8567     7936  3.9M ef EFI (FAT-12/16/32)
/dev/sdd3       3977216 30881791 26904576 12.8G 83 Linux
mint@mint:~$ sudo mount /dev/sdc2 /mnt
mint@mint:~$ sudo grub-install --root-directory=/mnt/ /dev/sdc
Installing for i386-pc platform.
grub-install: warning: Sector 59 is already in use by the program `FlexNet'; avoiding it.  This software may cause boot or other problems in future.  Please ask its authors not to store data in the boot track.
Installation finished. No error reported.
mint@mint:~$ 
did NOT worked. The is still error about 'grub_calloc' when I choose second disk when booting to a system.

EDIT:

I have tried "boot-repair-disk-64bit" (https://sourceforge.net/p/boot-repair-cd/home/Home/) to no avail. I don;t know why when I use any of the "live" USB it cannot mount other usb to send screens/logs so I can post them here.
spamator12
Level 4
Level 4
Posts: 214
Joined: Mon Feb 04, 2019 11:57 am

Re: Linux mint 20 grub problem

Post by spamator12 »

I have tried https://easylinuxtipsproject.blogspot.c ... epair.html without positive results...

I really need to reset this grub cause I need to have working linux distro. Does somebody know confused is going on?
spamator12
Level 4
Level 4
Posts: 214
Joined: Mon Feb 04, 2019 11:57 am

Re: Linux mint 20 grub problem

Post by spamator12 »

I have managed to run mint 20, but my wi-fi disapered, my graphic drivers were suspend... and after reboot and try to run it again...

https://imgur.com/a/k2oUjNn



I have no idea confused is going on.

Grub should lie in BOOT, right? Maybe I should mount the 'HOME' + 'SWAP' and 'BOOT' + '/' ---- together and then try to grub-install ??

So if I have:

/dev/sdb1 2048 218752047 218750000 104.3G 83 Linux - ROOT (/)
/dev/sdb2 218753022 234440703 15687682 7.5G 5 Extended
/dev/sdb5 218753024 234440703 15687680 7.5G 82 Linux swap / Solaris - SWAP

/dev/sdc1 2048 247566335 247564288 118G 83 Linux - HOME
/dev/sdc2 * 247566336 250066943 2500608 1.2G 83 Linux - BOOT

I should mount them together:
sudo mount /dev/sdb1 /mnt
sudo mount /dev/sdb2 /mnt
sudo mount /dev/sdb5 /mnt

sudo mount /dev/sdc1 /mnt
sudo mount /dev/sdc2 /mnt

and then run:
grub-install --root-directory=/mnt /dev/sdc

?? Or somehow linux know where are the rest of home/boot/root folder on which drives ?
bodge99

Re: Linux mint 20 grub problem

Post by bodge99 »

Hi,
If you try:

Code: Select all

sudo mount /dev/sdb1 /mnt
sudo mount /dev/sdb2 /mnt
sudo mount /dev/sdb5 /mnt
You will find that it won't do what you think it will.

The first command will mount sdb1 to /mnt.
The second command will mount sdb2 to /mnt . You won't "see" sdb1 on /mnt if you 'ls /mnt', only the contents of sdb2.
The third command will mount sdb5 to /mnt. If you list /mnt now, you'll only see the contents of sdb5 here. sdb1 and sdb2 are now invisible on /mnt.
If you now unmount sdb5, you'll see the contents of sdb2 on /mnt.. and so on. Not what you want!

To perform maintenance on a non-booting system by "running it" from within another Linux:

Booting from a flashdrive, or other Linux installation, mount your system partition to /mnt

Code: Select all

sudo mount /dev/sdb1 /mnt
Now mount your home partition thus:

Code: Select all

sudo mount /dev/sdc1 /mnt/home
N.B. The mount point /mnt/home **must** exist. It will do, if your existing setup used this directory layout.

Boot is mounted in a similar way:

Code: Select all

sudo mount /dev/sdc2 /mnt/boot
When you have created the correct directory tree under /mnt , you'll need to bind mount some directories and chroot to /mnt . You can then perform your required maintenance on a "working" system. An example here is to reinstall Grub to a legacy system.

Code: Select all

sudo mount --bind /dev /mnt/dev
sudo mount --bind /dev/pts /mnt/dev/pts
sudo mount --bind /proc /mnt/proc
sudo mount --bind /sys /mnt/sys
Now chroot to the system under /mnt

Code: Select all

sudo chroot /mnt
You can now install or update Grub as required..
Assuming that your system drive is now seen as sda then:

Code: Select all

sudo grub-install /dev/sda
sudo grub-install --recheck /dev/sda
sudo update-grub

You have now reset your grub and grub menu.

Lastly:

Exit the chroot shell, unmount the bind mounts and the home, boot and system partitions. Finally restart the computer.

To leave the chroot system, simply type 'exit'.

Now unbind the directories and unmount the system partitions using the following sequence:

Code: Select all

sudo umount /mnt/sys 
sudo umount /mnt/proc 
sudo umount /mnt/dev/pts 
sudo umount /mnt/dev 
sudo umount /mnt/home
sudo umount /mnt/boot
sudo umount /mnt
Bodge99
spamator12
Level 4
Level 4
Posts: 214
Joined: Mon Feb 04, 2019 11:57 am

Re: Linux mint 20 grub problem

Post by spamator12 »

@Bodge99 COOL!

VERY informative, so I leave SWAP (extended partition) and do not bind it anywhere. Will linux know that it need to use it, and it's there?

Now I'm at :

Code: Select all

sudo chroot /mnt
But this does not create any new disk. Windows in on SDA (sda1 - 500MB BOOT /// sda2 - 237GB - system).

So I should replace grub on SDA? I Guess this will update windows... grub... right?

So the correct drive is sdc (BOOT)?

EDIT: making some screenshoots.

GParted:
https://imgur.com/a/zvlAMBP

Devices (on working system):
https://imgur.com/a/j2028dp
Last edited by spamator12 on Wed Apr 07, 2021 1:57 pm, edited 1 time in total.
bodge99

Re: Linux mint 20 grub problem

Post by bodge99 »

Hi,

A chroot'ed system is actually one Linux system running within another system.. The bind mounted directories essentially allow the the "secondary" chroot'ed system to use the running facilities provided by the host. The important thing to remember is that the chroot system is logically totally separate from the host system.

Chroot won't create any new disks.. This could be done with CLI tools if you so require. Whilst you are within the chroot environment, you are essentially running your borked system without actually having booted it. It is designed to allow certain types of system maintenance to be performed.. the types that normally requires a running system. This is why it is important to mount your home and boot partitions to the correct locations **before** you enter the chroot environment.

All essential system services (e.g. kernel services and the creation of /dev devices etc.) are provided transparently from the host system.

You can perform any task on the chroot'ed system that you would on a normally booted system (except starting the GUI... although this **is** possible [arguably not worth the effort]).
You won't need to worry about your swap partition here as you won't be doing anything that needs a large amount of memory (normally!). When the system is repaired and booting normally, it's location will be picked up as normal from the entry in /etc/fstab .

Essentially, "fix" your chroot'ed system by using whatever CLI tools that you need.. If you have reinstalled Grub and updated your grub.cfg correctly then your system should now boot normally on restart.
If you have a legacy system and (within the chroot environment) your system drive is sda, then install Grub to sda . If your system drive "appears" as sdb, then install Grub to sdb . There are other methods that you can use to repair a damaged boot sector.. but these are potentially riskier for the inexperienced user.

Be aware that any detected drives may appear slightly differently.. e.g. what was sdb may appear as sdc etc. Don't forget that these allocations are dynamic and can vary depending on how your specific hardware is detected at boot time. The safest thing to do is to not assume **anything**.. look to see exactly how the system has identified every drive. "sudo fdisk -l" is your friend here.

Bodge99
spamator12
Level 4
Level 4
Posts: 214
Joined: Mon Feb 04, 2019 11:57 am

Re: Linux mint 20 grub problem

Post by spamator12 »

Thanks! Again VERY informative, you are a really good teacher. Everything is MUCH clearer now.

On the pictures however there are more disks. I can see Windows BOOT and SYSTEM - dunno it is ok - I guess it is..., right?

What can you see on the last picture is BOOT partition - and this is... questionable.

Maybe I mount BOOT folder first, and then I mount HOME folder, and HOME replace BOOT with its own BOOT (but grub HAVE my custom theme, so I guess it's not the case here - or maybe both BOOT folders had the same grub config?). That could explain, why I can see BOOT partition unmounted - and it should be mounted and grub should be installed and be read from IT.

So should I repeat the procedure by mounting '/' - ROOT first, then HOME, and then BOOT partitions (to bu sure that home boot is replaced with proper BOOT)?

My idea was that I will always put GRUB on custom BOOT partition - so it could manage multi systems...

But I guess that windows always use his bootloader and place it on its own partition, and it replace grub configuration (is read FIRST). Right? So with windows it must be corrected.

Cause with multiple linux systems I could use one BOOT partition with grub have all systems info, and it will work just fine - that was the idea, why I use custom partition for BOOT, but maybe I get it wrong?
bodge99

Re: Linux mint 20 grub problem

Post by bodge99 »

Hi,

It sounds like you are "getting there".. I don't know exactly how much Linux experience you have, or how much of the many Linux concepts you have grasped yet..
It's a learning curve.. There is no such thing as a "silly question" and "nobody was born knowing this stuff".

In some ways, it's slightly harder if you are moving from a Windows environment.. You will have picked up the "Windows way of doing things".. certain concepts are different.. e.g. storage devices. If you plug in a formatted USB flashdrive into a Windows machine, it will be detected and and assigned a drive letter.
Linux doesn't use the concept of drive letters. It uses a directory "tree" structure in which any (mounted) device is connected somewhere within the "tree".

The system helps here somewhat. I've just formatted a 16GB flashdrive using the Mint "USB Stick Formatter". With Mint, this flashdrive will be automounted to a specific location (/media/bob/USB STICK). To illustrate how a different distro handles this, Artix Linux uses the location /run/media/bob/USB STICK. If you format the same flashdrive to (for example) Ext4, neither system will automount it. You would then have to manually mount this flashdrive in order to use it.
All of this is just convention.. none of these examples are "wrong".. just different.

Now moving on to problems & questions.. In my experience, the vast majority of problems that the novice Linux user has are relatively easy to solve, **when you know how**.. This leads directly to "how do I ask a question that will allow folk to help me?". I don't mean to sound "trite".. but the questioner knows "exactly what they mean" and the kind, helpful folk on forums such as these naturally make assumptions as to what exactly is being asked.. There can sometimes be a bit of misunderstanding occuring on both sides..

If you look at some of the "solved" threads on this forum, you'll often see folk asking for further info, or to format code listings or CLI output in a certain way (the use of code tags etc.). This makes it easier to "take in" information which should help with the process of problem solving.

Now, back to your problem..
Looking at your images, it would now seem that I may have made an incorrect assumption.. (re. boot partition).

If I understand correctly, you have installed Windows 7 and Mint onto your system.. As Grub is not "appearing", then did you install Windows after Mint?

As you appear to have a legacy system then some understanding of the boot process might be helpful.

On power on, after completing the Bios POST procedure, the Bios firmware loads data contained within the first sector of the assigned boot drive into memory. It then scans this for a valid Master Boot Record (MBR). If a valid MBR is found, the firmware then passes execution to the bootloader to select a partition to boot from. I'm ignoring any "boot order" within your Bios settings here.

If you install Linux (with Grub) onto an empty disk, the MBR will point to (and pass control to) the Grub bootloader.
If you now install Windows, the MBR will be overwritten with code that points to the Windows bootloader.

Now, Grub can handle booting Windows, but, by default Windows is "totally blind" to any Linux installation.

You can either configure Windows to use Grub or use Grub to boot Windows. With both methods, you need to know the location of Grub.
As it's been quite a while since I've set up a dual boot legacy system with a separate boot partition, I'll need to refresh my memory.. Give me a little time.. I'll look this evening.

More later.

Bodge99
Last edited by bodge99 on Fri Apr 09, 2021 6:23 am, edited 1 time in total.
User avatar
AndyMH
Level 21
Level 21
Posts: 13716
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: Linux mint 20 grub problem

Post by AndyMH »

A bit more detail, on a legacy boot system. The first 446 bytes of the first sector (512 bytes) on the drive contain the boot loader code. The rest of the first sector is the partition table. Not much space for the partition table, which is why you are limited to four primary partitions. Nor is there much room for bootloader code, so with grub, this code passes control to the second stage bootloader. This hides in the gap between the end of the partition table and the start of the first partition (normally at 1MB = 2048 sectors). The second stage bootloader looks for and passes control to the /boot folder in your / partition on a linux system (or your /boot partition, but a long time since you needed one of these).
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
bodge99

Re: Linux mint 20 grub problem

Post by bodge99 »

Hi,

N.B. Please see the "Gotcha" at the end of this post.
The following was performed on two legacy laptops of slightly different vintages..
I've written everything up in "painful detail" as this might help others.

The same disks were used in both laptops. Both disks were fully wiped before each installation.

First disk: 360 GB SSD fitted to the internal Sata port.
Second disk: 750 GB HDD fitted into a DVD caddy.

Each system Bios detected the SSD as the first drive.

The system was booted from a USB flashdrive using Mint 20.1 Cinnamon.
The first drive was formatted fully with NTFS. The idea here is to let Mint install the MBR & first stage loader to the first drive, knowing that the subsequent Windows 10 installation would overwrite everything here.

Mint was installed to the second drive. The system drive was set at 740GB Ext4 (sdb1), with a boot partition 10GB Ext4 (sdb2). The system was rebooted after the installation was completed to prove everything so far. N.B. Most folk won't need a separate boot partition.. I've just used one because the OP has.

Windows 10 was then installed from USB to sda. I deleted the existing partition here and let Windows allocate its own partitions.
This resulted in:-
sda1 ntfs (system reserved)
sda2 ntfs (windows)
sda3 ntfs (msftres)

As expected, the Windows installation had replaced the first stage Grub bootloader.

Now, reinstall Grub functionality:

Boot from the Mint flashdrive, mount the existing Linux partitions under /mnt. Bind mount the required system directories and enter the chroot environment. Next reinstall Grub and update the local grub.cfg . Finally, exit and "tidy up".

I'll place the exact commands used in a list. Comments are within braces which are not meant to be entered.

Code: Select all

sudo su                             {Become Root.}

mount /dev/sdb1 /mnt                {Create your system tree under /mnt}
mount /dev/sdb2 /mnt/boot

mount --bind /dev /mnt/dev          {Bind mount some essential directories...} 
mount --bind /dev/pts /mnt/dev/pts  {...from the host system.}
mount --bind /proc /mnt/proc
mount --bind /sys /mnt/sys

chroot /mnt                         {Enter the chroot environment.}

grub-install /dev/sda               {Reinstall Grub & update /boot/grub/grub.cfg}
grub-install --recheck /dev/sda
update-grub

exit                                {Leave the chroot environment.}

umount /mnt/sys                     {unmount everything.} 
umount /mnt/proc                    {i.e. tidy up, leaving things how I found them.}
umount /mnt/dev/pts 
umount /mnt/dev 
umount /mnt/boot
umount /mnt

exit                                {Return to being a normal user.}
On restart, boot Mint and rerun update-grub. See "Gotcha" below.

Back to the original problem..

I'm assuming here that sdb1 is your system partition (i.e. / ), sdc1 is your /home and sdc2 is /boot.
I would recommend that you check before proceeding.
To do this, boot from your Mint flashdrive, open a terminal and mount the three partitions as shown below:
Perform all actions from the same terminal.

Code: Select all

sudo su
mount /dev/sdb1 /mnt
mount /dev/sdc1 /mnt/home
mount /dev/sdc2 /mnt/boot


Check the contents of your mounted partitions:

Code: Select all

ls /mnt
This should return something like this:

Code: Select all

bin    dev   lib    libx32      mnt   root  srv       tmp
boot   etc   lib32  lost+found  opt   run   swapfile  usr
cdrom  home  lib64  media       proc  sbin  sys       var
Next, check your boot directory:

Code: Select all

ls /mnt/boot
Should return something like this:

Code: Select all

System.map-5.4.0-58-generic  initrd.img-5.8.0-33-generic
System.map-5.8.0-33-generic  initrd.img.old
config-5.4.0-58-generic      lost+found
config-5.8.0-33-generic      vmlinuz
grub                         vmlinuz-5.8.0-33-generic
initrd.img
Looking at the home directory in more detail,

Code: Select all

ls -R /mnt/home
Should return something like this:

Code: Select all

/mnt/home:
bob

/mnt/home/bob:
Desktop    Downloads  Pictures  Templates
Documents  Music      Public    Videos

/mnt/home/bob/Desktop:

/mnt/home/bob/Documents:

/mnt/home/bob/Downloads:

/mnt/home/bob/Music:

/mnt/home/bob/Pictures:

/mnt/home/bob/Public:

/mnt/home/bob/Templates:

/mnt/home/bob/Videos:

If you have identified your partitions correctly, then proceed:

Code: Select all

mount --bind /dev /mnt/dev           
mount --bind /dev/pts /mnt/dev/pts  
mount --bind /proc /mnt/proc
mount --bind /sys /mnt/sys

chroot /mnt                         

grub-install /dev/sda               
grub-install --recheck /dev/sda
update-grub

exit                                

umount /mnt/sys                      
umount /mnt/proc                    
umount /mnt/dev/pts 
umount /mnt/dev 
umount /mnt/boot
umount /mnt/home
umount /mnt

exit             
**GOTCHA**
On reboot, the first laptop was fully able to boot either Windows or Mint successfully.
The second laptop would initially not boot Windows (it hung).. The fix was to restart and run update-grub from Mint.
To avoid this potential problem, boot Mint and rerun update-grub before attempting to boot Windows.

Bodge99
spamator12
Level 4
Level 4
Posts: 214
Joined: Mon Feb 04, 2019 11:57 am

Re: Linux mint 20 grub problem

Post by spamator12 »

Code: Select all

sudo mount /dev/sdb1 /mnt
[/ - ROOT]

Code: Select all

sudo mount /dev/sdc1 /mnt/home
[/HOME]

Code: Select all

sudo mount /dev/sdc2 /mnt/boot
[/BOOT]

Code: Select all

sudo mount --bind /dev /mnt/dev
sudo mount --bind /dev/pts /mnt/dev/pts
sudo mount --bind /proc /mnt/proc
sudo mount --bind /sys /mnt/sys

Code: Select all

sudo chroot /mnt
Now I wanted grub to be installed at /BOOT [mounted /dev/sdc2] so:

Code: Select all

sudo grub-install /dev/sdc2
gives...
[Installing for i386-pc platform.
grub-install: warning: File system `ext2' doesn't support embedding.
grub-install: warning: Embedding is not possible. GRUB can only be installed in this setup by using blocklists. However, blocklists are UNRELIABLE and their use is discouraged..
grub-install: error: will not proceed with blocklists.]

so I try to install it on windows BOOT partition by:

Code: Select all

sudo grub-install /dev/sda1
but it gives...
[Installing for i386-pc platform.
grub-install: warning: File system `ext2' doesn't support embedding.
grub-install: warning: Embedding is not possible. GRUB can only be installed in this setup by using blocklists. However, blocklists are UNRELIABLE and their use is discouraged..
grub-install: error: will not proceed with blocklists.]

So I gues GRUB can only be instaled on beginning of a disc - NOT partition.

Code: Select all

sudo grub-install /dev/sda
gives proper
[Installing for i386-pc platform.
Installation finished. No error reported.]

So if I install grub on dev/sdc - it will NOT choose dec2 (BOOT), but it will install grub at the beginning of a sdc disc - and I don't want that.

Code: Select all

sudo grub-install --recheck /dev/sda
sudo update-grub
gives...
[Found Windows 7 on /dev/sda1
Found Windows 7 on /dev/sda2]

- it should found windows 7 on /dev/sda2 - cause /dev/sda1 is windows BOOT, but I guess you can delete this info from GRUB (by editing its setting, so It will not be visible).

Code: Select all

exit
[important! - we must quit chroot]

Code: Select all

sudo umount /mnt/sys
sudo umount /mnt/proc
sudo umount /mnt/dev
sudo umount /mnt/dev/pts
sudo umount /mnt/boot
sudo umount /mnt/home
sudo umount /mnt
now exit + reboot.

NOW, I still have BOOT partition on my devices lists, just as windows SYSTEM and it's BOOT. So it means that:
a) - mounting boot folder after home folder will NOT replace default home boot folder,
b) - or linux just don't accept/merge BOOT partition...

Anyway I was able to successfully install grub (as before, after @bodge99 showed me how to do this EXACTLY) and I'm able to choose linux/windows system, so I'm very pleased. The info I put here is just for learning purposes. Thinking logically linux should have merge BOOT partition with help of chroot. I do not see /ROOT partition and /HOME partition individually (when I enter the folders they show difference in size - but they are merged). The same should be with BOOT... I think.

Lets continue the discussion, but I'm making this as solved.
bodge99

Re: [Solved] Linux mint 20 grub problem

Post by bodge99 »

Hi,

You seem to be getting there..

You have a legacy system. Grub installs to sda (MBR & first stage boot loader). Don't forget that these are "outside" of any partitions in a fixed location at the beginning of the drive.
Other Grub files (modules etc.) will install to /boot .
It's perfectly possible to have bootloaders on other disks.. How this is "handled" on any specific computer is Bios dependent.

What you are doing here is setting Grub to have overall boot control. The Windows bootloader is now used as a secondary one.

You now know how to reinstall Grub on a legacy system.. You could now take the opportunity and rationalize your partition layout..
I'd keep the separate home partition.. but I would consider not using a separate boot partition. The contents of this directory are quite small. It only holds your Grub files and your kernel & initrd files etc.
If you wish to do this then just ask here and I'll write something up which should help.

Be aware that the use of chroot only allows you activate a system that already exists on one or more partitions.
You manually set up the required directory structure before you enter the chroot environment. Here, you have essentially performed the actions that a normal system boot uses /etc/fstab for. i.e. connect any required partitions "into" the directory tree.

Below is the fstab from a Mint system that uses three partitions. The system partition (/) is sda2, sda1 is used as a boot partition and sda3 is used as swap. Note that the swap partition is not mounted anywhere. This partition is used as a block device (don't worry about this for now).

Ignoring the UUID's here, this file indicates that sda2 is mounted to / and sda1 is mounted to /boot .

The important thing here is that sda2 is mounted **first**. Now sda2 will already have the mountpoint /boot existing.
The action of mounting sda1 to /boot allows the **contents** of sda1 to appear within /boot.
No files are moved anywhere. The running system "sees" the contents of /boot as if they were actually placed on /sda .

Code: Select all

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system>                             <mount point>   <type>  <options>                <dump>  <pass>
# / was on /dev/sda2 during installation
UUID=1f52ed80-c870-4514-9c4e-7eeba1912ce9   /               ext4    noatime,errors=remount-ro   0       1
# /boot was on /dev/sda1 during installation
UUID=f9a15e14-ffdf-4221-9fee-06b4e5564bc9   /boot           ext4    noatime,errors=remount-ro   0       2
# swap was on /dev/sda3 during installation
UUID=4231f3fa-cf63-4286-83ed-d04e9ff6f82c   none            swap    sw                          0       0
One thing to note here, the comments (lines beginning with #) are only correct at installation time. If you make any additions or changes to your partition layout (e.g. adding a discrete /usr partition etc. ) then the system allocation of sda(x) may change.
If you reformat any partition then its filesystem UUID will change. The system will now not boot (properly or at all). You would need to alter the relevant UUID in the fstab to match the partition's filesystem new UUID.

As a further example, here is the fstab from a Slackware system:
This particular computer has several Linux distributions installed.

Code: Select all

/dev/sdb8		/		ext4	defaults,noatime			1   1
/dev/sda1		/boot/efi	vfat	defaults				1   0
#/dev/cdrom		/mnt/cdrom	auto	noauto,owner,ro,comment=x-gvfs-show	0   0
#/dev/fd0		/mnt/floppy	auto	noauto,owner				0   0
devpts			/dev/pts	devpts	gid=5,mode=620				0   0
proc			/proc		proc	defaults				0   0
tmpfs			/dev/shm	tmpfs	defaults				0   0
This is a UEFI system. The system partition is ext4 and is on sdb8 . The EFI partition is fat32 (although marked as vfat) on sda1.
This fstab uses the older convention (i.e. UUID's are not used here.) I have actually converted this fstab to use UUID's as this makes things "more robust".

Bodge99
spamator12
Level 4
Level 4
Posts: 214
Joined: Mon Feb 04, 2019 11:57 am

Re: [Solved] Linux mint 20 grub problem

Post by spamator12 »

Great post! I did have some work to do, but I have found time to read more about info you mentioned in your post (block device, UEFI booting).

Few questions (off course you answer when you have some free time):
A) When you change UUID inside working system - it will update the info right?

I understand that when you change something from outside the system (with help of other system), the primary system won't have a chance to get proper UUID. But when you are doing a UUID change in a currently working system, it can recognize and update it self, right?

B) It is possible to change the partition that is booted as first? If I change '/' to 'boot' partition, will it work (reinstall grub)? Cause I think that there must by '/' first, so 'boot' could be refer to '/'.
"No files are moved anywhere. The running system "sees" the contents of /boot as if they were actually placed on /sda ."
This is true when you have dev/sda1 as '/' and dev/sdb1 as 'boot'?

C)
"I have actually converted this fstab to use UUID's"
With what exactly did you connect the UUID (order appearance?)? Cause I see nothing there as you could refer UUID to.

D) if you want users to have different partitions - for example user1 sdg1, user2 sdg2, user3, sdg3 etc. how to do that?

Sorry if I'm to lazy to discover this as my own :) Doing homework with you is much faster and fun!
bodge99

Re: [Solved] Linux mint 20 grub problem

Post by bodge99 »

Hi,
The UUIDs that we are referring to here are filesystem UUIDs. The UUID is generated whenever a filesystem is created (i.e when a partition is formatted). If you reformat the partition, the filesystem UUID changes. You can also manually change any filesystem UUID.
In both of these cases, you would have to manually adjust your fstab and rerun 'update-grub' etc. if you alter your system's UUID.
There may be other things that need to be altered, depending on what you change.

Most users won't ever need to do this.

If "moving /boot to /" you mean having the **contents** of your boot partition moved to the system partition then yes.

You'll have to boot from a flashdrive to perform changes to your system partition.

Overview:
Boot from flashdrive
Mount the system partition.
Mount the boot partition
Copy everything from the boot partition to {mountpoint}/boot/
Remove the boot partition line in your fstab.
Unmount everything and delete or reuse the old boot partition for something else.

Where possible, always **copy** files in preference to moving files.. This is safer. if you make a mistake (been there, done that!) then your original files are still untouched. You can always delete the originals later..

For your computer:
You don't need to mount your home partition here.
***Double check these.***
The system partition is 'sdb1'
The boot partition is 'sdc2'

Code: Select all

sudo su 				{Become Root}
mkdir /mntSystem /mntBoot 		{Create two directories}
mount /dev/sdb1 /mntSystem
mount /dev/sdc2 /mntBoot		{Both partitions have been added to the directory tree.}
cp -R /mntBoot/* /mntSystem/boot/	{Copy everything over. All files & directories etc.}
cp /mntSystem/etc/fstab /mntSystem/etc/fstabORIG	{make a copy of your system 'fstab'.}
exit					{Become a normal user again}
You now need to edit your fstab and remove (or comment out) the boot partition mount.
I'll use 'Xed' here.. Use whatever you wish, but run a GUI text editor using 'sudo', not as Root.

Code: Select all

sudo xed /mntSystem/etc/fstab


In the next bit, the '/boot' line is critical. Don't comment out an incorrect line.
Look for a line similar to:

Code: Select all

UUID=f9a15e14-ffdf-4221-9fee-06b4e5564bc9   /boot           ext4    noatime,errors=remount-ro   0       2
Your UUID will be different. Change this to:

Code: Select all

# UUID=f9a15e14-ffdf-4221-9fee-06b4e5564bc9   /boot           ext4    noatime,errors=remount-ro   0       2
Save the file and exit.
Done! Now reboot.

More later.. I've got a rush laptop to fix.

Bodge99
Locked

Return to “Installation & Boot”