How do I stop PC booting the wrong partition ?[SOLVED]

Archived topics about LMDE 1 and LMDE 2
ron_h
Level 4
Level 4
Posts: 342
Joined: Tue Apr 15, 2014 7:03 am
Location: The Illawarra, NSW, AU

Re: How do I stop PC booting the wrong partition ?

Post by ron_h »

I didn't realise I could use Gparted when I went looking for partition clone/copy software, I assume it would need to be Gparted from a Live medium ? Since Clonezilla website made very clear you can only clone to a partition of equal (or greater) size, it seemed like a good idea to make the partitions of identical size.

Ron
ron_h
Level 4
Level 4
Posts: 342
Joined: Tue Apr 15, 2014 7:03 am
Location: The Illawarra, NSW, AU

Re: How do I stop PC booting the wrong partition ?

Post by ron_h »

OK, done that, it's still wrong.

Code: Select all

grep vmlin /boot//grub/grub.cfg
	linux	/boot/vmlinuz-3.11-2-amd64 root=UUID=c456e7bd-e79e-496c-93a1-5c522359fdaa ro  quiet splash
	linux	/boot/vmlinuz-3.11-2-amd64 root=UUID=c456e7bd-e79e-496c-93a1-5c522359fdaa ro single 
	linux /boot/vmlinuz-3.11-2-amd64 root=UUID=c456e7bd-e79e-496c-93a1-5c522359fdaa ro quiet splash
	linux /boot/vmlinuz-3.11-2-amd64 root=UUID=c456e7bd-e79e-496c-93a1-5c522359fdaa ro single
Ron
User avatar
Spearmint2
Level 16
Level 16
Posts: 6900
Joined: Sat May 04, 2013 1:41 pm
Location: Maryland, USA

Re: How do I stop PC booting the wrong partition ?

Post by Spearmint2 »

Code: Select all

cat /boot/grub/grub.cfg |grep UUID; sudo blkid & sudo fdisk -l & sudo parted -l
copy and paste into terminal and run. Post results. It's past 1am so I may not be back till tomorrow to see it.

for a bit of twist on yours, try this instead;

Code: Select all

grep generic /boot//grub/grub.cfg
All things go better with Mint. Mint julep, mint jelly, mint gum, candy mints, pillow mints, peppermint, chocolate mints, spearmint,....
WharfRat

Re: How do I stop PC booting the wrong partition ?

Post by WharfRat »

From the same place

Code: Select all

sudo -i

Code: Select all

mount /dev/sda8 /mnt

Code: Select all

egrep '^UUID|^/dev' /mnt/etc/fstab

Code: Select all

umount -l /dev/sda8

Code: Select all

exit
Just paste back the grep results.
ron_h
Level 4
Level 4
Posts: 342
Joined: Tue Apr 15, 2014 7:03 am
Location: The Illawarra, NSW, AU

Re: How do I stop PC booting the wrong partition ?

Post by ron_h »

Looks like I stuffed up the other day ....

Code: Select all

sudo -i
[sudo] password for ron: 
baby-2 ~ # mount /dev/sda8 /mnt
baby-2 ~ # egrep '^UUID|^/dev' /mnt/etc/fstab
UUID=newuuidhere	/	ext4	rw,errors=remount-ro	0	1
UUID=afc6dcda-65ea-446d-9c95-4d355a03debc	swap	swap	sw	0	0
baby-2 ~ # umount -l /dev/sda8
baby-2 ~ # exit
logout
That 'newuuidhere' shouldn't be there ... i remember I got that command wrong when I first tried it

Code: Select all

sed -i.bak 's/c456e7bd-e79e-496c-93a1-5c522359fdaa/newuuidhere/1' /etc/fstab
So I reran it ... and it looks like that wasn't good enough :-(

Ron
WharfRat

Re: How do I stop PC booting the wrong partition ?

Post by WharfRat »

ron_h wrote:Looks like I stuffed up the other day ....
Yup :D

I was always under the impression that grub used blkid or tune2fs to retrieve the UUID for the partition, but now I see it doesn't.
ron_h wrote:So I reran it ... and it looks like that wasn't good enough
It's a good thing nothing happened given the substitution string wasn't there otherwise you would have messed up the sda6 system.

Get back to where you were before, meaning boot and open the terminal

Code: Select all

sudo -i

Code: Select all

mount /dev/sda8 /mnt

Code: Select all

sed -i.bak 's/newuuidhere/015fac40-f127-11e3-ad5a-2b2b889acdff/1' /mnt/etc/fstab
Double check that the substitution worked and if so update grub

Code: Select all

grep 2b2b889acdff /mnt/etc/fstab

Code: Select all

/usr/sbin/update-grub
Then check the grub.cfg file

Code: Select all

grep vmlin /boot//grub/grub.cfg
That should do it.
ron_h
Level 4
Level 4
Posts: 342
Joined: Tue Apr 15, 2014 7:03 am
Location: The Illawarra, NSW, AU

Re: How do I stop PC booting the wrong partition ?

Post by ron_h »

Sadly, no

Code: Select all

ron@baby-2 ~ $ sudo -i
[sudo] password for ron: 
baby-2 ~ # mount /dev/sda8 /mnt
baby-2 ~ # sed -i.bak 's/newuuidhere/015fac40-f127-11e3-ad5a-2b2b889acdff/1' /mnt/etc/fstab
baby-2 ~ # grep 2b2b889acdff /mnt/etc/fstab
UUID=015fac40-f127-11e3-ad5a-2b2b889acdff	/	ext4	rw,errors=remount-ro	0	1
baby-2 ~ # /usr/sbin/update-grub
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-3.11-2-amd64
Found initrd image: /boot/initrd.img-3.11-2-amd64
  No volume groups found
Found Windows Recovery Environment (loader) on /dev/sda1
Found Windows 7 (loader) on /dev/sda3
Found LMDE Cinnamon Edition (1) on /dev/sda8
done

[127]baby-2 ~ # grep vmlin /boot//grub/grub.cfg
	linux	/boot/vmlinuz-3.11-2-amd64 root=UUID=c456e7bd-e79e-496c-93a1-5c522359fdaa ro  quiet splash
	linux	/boot/vmlinuz-3.11-2-amd64 root=UUID=c456e7bd-e79e-496c-93a1-5c522359fdaa ro single 
	linux /boot/vmlinuz-3.11-2-amd64 root=UUID=c456e7bd-e79e-496c-93a1-5c522359fdaa ro quiet splash
	linux /boot/vmlinuz-3.11-2-amd64 root=UUID=c456e7bd-e79e-496c-93a1-5c522359fdaa ro single
Ron
ron_h
Level 4
Level 4
Posts: 342
Joined: Tue Apr 15, 2014 7:03 am
Location: The Illawarra, NSW, AU

Re: How do I stop PC booting the wrong partition ?

Post by ron_h »

It seems to me that using Clonezilla to create a clone on a partition on the same hard drive was not a good decision on my part. Even if this thread ends up SOLVED, I won't be doing things the same way ever again. So I'm starting a new thread to detemine how I should have done it :-)

Ron
WharfRat

Re: How do I stop PC booting the wrong partition ?

Post by WharfRat »

ron_h wrote:It seems to me that using Clonexzilla to create a clone on a partition on the same hard drive was not a good decision on my part. Even if this thread ends up SOLVED, I won't be doing things the same way ever again. So I'm starting a new thread to detemine how I should have done it :-)

Ron
Mount the partition or make sure it's mounted and

Code: Select all

cat /mnt/boot/grub/i386-pc/load.cfg
ron_h
Level 4
Level 4
Posts: 342
Joined: Tue Apr 15, 2014 7:03 am
Location: The Illawarra, NSW, AU

Re: How do I stop PC booting the wrong partition ?

Post by ron_h »

sda6 is mounted, it's the running system. I also mounted sda8

Code: Select all

ron@baby-2 ~ $     cat /mnt/boot/grub/i386-pc/load.cfg
cat: /mnt/boot/grub/i386-pc/load.cfg: No such file or directory
The only subdirectory in /mnt/boot/grub is /locale, and there is no load.cfg file in /mnt/boot/grub or in /mnt/boot/grub/locale

Ron
ron_h
Level 4
Level 4
Posts: 342
Joined: Tue Apr 15, 2014 7:03 am
Location: The Illawarra, NSW, AU

Re: How do I stop PC booting the wrong partition ?

Post by ron_h »

I can't find load.cfg at all

Ron
WharfRat

Re: How do I stop PC booting the wrong partition ?

Post by WharfRat »

ron_h wrote:I can't find load.cfg at all

Ron
Well, that's strange. If this is a clone of sda6 then it should be there. I've never touched that file, even when I rsync clone my running system to a flash and the flash to another computer.

Lets just manually adjust grub and see if it boots. Use your text editor to change the UUID entry in grub.cfg. Just make a copy first.

Code: Select all

sudo cp -a /boot/grub/grub.cfg /boot/grub/grub.cfg.bak
I forget if mentioned your desktop or not, but your editor is either pluma, gedit or kate/ So

Code: Select all

sudo youreditor /boot/grub/grub.cfg&
Change the UUID's for the last two vmlinuz lines with sda8's to read:

linux /boot/vmlinuz-3.11-2-amd64 root=UUID=015fac40-f127-11e3-ad5a-2b2b889acdff ro quiet splash
linux /boot/vmlinuz-3.11-2-amd64 root=UUID=015fac40-f127-11e3-ad5a-2b2b889acdff ro single

Save the file and reboot.
ron_h
Level 4
Level 4
Posts: 342
Joined: Tue Apr 15, 2014 7:03 am
Location: The Illawarra, NSW, AU

Re: How do I stop PC booting the wrong partition ?

Post by ron_h »

I made the backup then started gedit (I'm using Cinnamon) for grub.cfg. In your example code, do I have to specify the & that is at the end of the file ID ?

I have NOT yet made the changes. This is what I see for entries 5 and 6 in the grub menu, which do indeed boot the wrong partition !

Code: Select all

menuentry "LMDE Cinnamon 64-bit, 3.11-2-amd64 (/dev/sda6) (on /dev/sda8)" --class gnu-linux --class gnu --class os {
	insmod part_msdos
	insmod ext2
	set root='(hd0,msdos8)'
	search --no-floppy --fs-uuid --set=root 015fac40-f127-11e3-ad5a-2b2b889acdff
	linux /boot/vmlinuz-3.11-2-amd64 root=UUID=c456e7bd-e79e-496c-93a1-5c522359fdaa ro quiet splash
	initrd /boot/initrd.img-3.11-2-amd64
}
menuentry "LMDE Cinnamon 64-bit, 3.11-2-amd64 (/dev/sda6) -- (recovery mode) (on /dev/sda8)" --class gnu-linux --class gnu --class os {
	insmod part_msdos
	insmod ext2
	set root='(hd0,msdos8)'
	search --no-floppy --fs-uuid --set=root 015fac40-f127-11e3-ad5a-2b2b889acdff
	linux /boot/vmlinuz-3.11-2-amd64 root=UUID=c456e7bd-e79e-496c-93a1-5c522359fdaa ro single
	initrd /boot/initrd.img-3.11-2-amd64
For the entries 1 & 2 in the menu, all UUID references are to the sda6 UUID
WharfRat

Re: How do I stop PC booting the wrong partition ?

Post by WharfRat »

do I have to specify the & that is at the end of the file ID ?
No, but if you do it will put the editor in the background freeing-up the terminal in case you need to get into it.

You can change the menu options to

Code: Select all

menuentry "LMDE Cinnamon 64-bit, 3.11-2-amd64 on /dev/sda8)" --class gnu-linux --class gnu --class os {

menuentry "LMDE Cinnamon 64-bit, 3.11-2-amd64 recovery mode (on /dev/sda8)" --class gnu-linux --class gnu --class os {
and the kernel lines to

Code: Select all

linux /boot/vmlinuz-3.11-2-amd64 root=UUID=015fac40-f127-11e3-ad5a-2b2b889acdff ro quiet splash

linux /boot/vmlinuz-3.11-2-amd64 root=UUID=015fac40-f127-11e3-ad5a-2b2b889acdff ro single
You can just copy and paste the lines.
ron_h
Level 4
Level 4
Posts: 342
Joined: Tue Apr 15, 2014 7:03 am
Location: The Illawarra, NSW, AU

Re: How do I stop PC booting the wrong partition ?

Post by ron_h »

Many thanks again. I did copy/paste the lines, although I changed LMDE to LMDETEST which looks better (to my eyes) in the GRUB menu.

I confirm that I can now boot to the LMDE system or the LMDETEST system, which is what I started this thread for.

As long as I don't run update-grub or grub-mkconfig, or install another system in a different partition, I assume grub.cfg will remain unchanged. However, if I do any of those things, would I be right to assume that grub.cfg will become incorrect again with respect to sda8 ? If so, then I think I need to reinstall LMDETEST but not by a cloning method, rather by a filesystem copy method such as fsarchiver. That however is a whole different exercise, beyond the scope of this thread.

Ron
WharfRat

Re: How do I stop PC booting the wrong partition ?

Post by WharfRat »

ron_h wrote:As long as I don't run update-grub or grub-mkconfig, or install another system in a different partition, I assume grub.cfg will remain unchanged. However, if I do any of those things, would I be right to assume that grub.cfg will become incorrect again with respect to sda8 ? If so, then I think I need to reinstall LMDETEST but not by a cloning method, rather by a filesystem copy method such as fsarchiver. That however is a whole different exercise, beyond the scope of this thread.

Ron
It appears likely that an update to the kernel or initrd will mess up the grub file again. You can check with

Code: Select all

sudo /usr/sbin/grub-mkconfig
It will dump the new menu to the screen so you can take a look at it.

You can always save the grub file and just copy it back with changes to the kernel and initrd versions to reflect the new entries. I use symlink references in grub so I don't have to modify the grub file, just adjust the symlinks in /boot.

Also since this is LMDE and not the main edition, you might want to try posting your experience to the LMDE forum. Maybe there's a grub bug with this edition.

I've cloned my running system to a flash drive using rsync several times, chrooted and made the same modifications I had you do without any problems.

Whatever you decide to do good luck with it :wink:
User avatar
austin.texas
Level 20
Level 20
Posts: 12003
Joined: Tue Nov 17, 2009 3:57 pm
Location: at /home

Re: How do I stop PC booting the wrong partition ?

Post by austin.texas »

Boot into Mint on sda6 and edit the /etc/fstab file on sda8.
Change from:
UUID=c456e7bd-e79e-496c-93a1-5c522359fdaa / ext4 rw,errors=remount-ro 0 1
to:
UUID=015fac40-f127-11e3-ad5a-2b2b889acdff / ext4 rw,errors=remount-ro 0 1
Then run: sudo /usr/sbin/update-grub putting the new Mint on the GRUB menu.
When you boot into Mint on sda8, run sudo /usr/sbin/update-grub again there.
Mint 18.2 Cinnamon, Quad core AMD A8-3870 with Radeon HD Graphics 6550D, 8GB DDR3, Ralink RT2561/RT61 802.11g PCI
Linux Linx 2018
User avatar
Spearmint2
Level 16
Level 16
Posts: 6900
Joined: Sat May 04, 2013 1:41 pm
Location: Maryland, USA

Re: How do I stop PC booting the wrong partition ?

Post by Spearmint2 »

and this is why some like to use boot partitions where multiple systems may reside.
All things go better with Mint. Mint julep, mint jelly, mint gum, candy mints, pillow mints, peppermint, chocolate mints, spearmint,....
ron_h
Level 4
Level 4
Posts: 342
Joined: Tue Apr 15, 2014 7:03 am
Location: The Illawarra, NSW, AU

Re: How do I stop PC booting the wrong partition ?

Post by ron_h »

I am sure it is as a result of the fact that sda8 started life as a clone of sda6 but when I looked at fstab on sda8, it showed the right UUID for sda8 but pointed to sda6 rather than sda8. It would appear that the referenced partition is then what ends up being booted in spite of the fact that the UUID does not match the one in the fstab. I have corrected the fstab on sda8 to point to sda8. Hopefully everything is now kosher and I have 2 boot partitions where everything internally cross references correctly. I will run an update-grub but (I'm chicken) not now. Later today maybe.

I started this thread in Newbie Questions in Main Edition, it is now in LMDE Newbie Questions as someone has moved it.

Many thanks to all who've helped me get to this stage.

Ron
WharfRat

Re: How do I stop PC booting the wrong partition ?

Post by WharfRat »

Ron,

This will not write to the grub.cfg file, it will just dump to the terminal so you can see if that problem will persist.

Code: Select all

sudo /usr/sbin/grub-mkconfig
Locked

Return to “LMDE Archive”