LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu
User Name
Password
Ubuntu This forum is for the discussion of Ubuntu Linux.

Notices


Reply
  Search this Thread
Old 02-17-2017, 11:44 AM   #1
Weapon S
Member
 
Registered: May 2011
Location: Netherlands
Distribution: Debian, Archlinux
Posts: 262
Blog Entries: 2

Rep: Reputation: 49
Trying to set cloned partition as new root


I have done similar things in Debian a couple of times, but now it doesn't seem to work.
On a BIOS system (i.e. non-UEFI). I have a working Ubuntu on /dev/sda1, with grub installed to the same disk (/dev/sda). Then I cloned this partition to /dev/sdc1. Then I generated a new UUID for /dev/sdc1 using tune2fs. Then I changed the /etc/fstab on /dev/sdc1 to use the clone as root by UUID. Then I ran update-grub. Then I restarted. Of course now the computer still boots from the disk /dev/sda. The clone was listed in the GRUB start-up menu as expected marked as "Ubuntu (on /dev/sdc1)" or something. I choose to boot into this system. So far so good.
Then I look at blkid (to ensure drive assignment hasn't changed) and /proc/mounts to verify I'm actually in the new system... and I'm not. /dev/sda1 is the root. I'm flabbergasted.
So apparently there is some configuration somewhere that reverts to the old disk partition. I guess it could be in the GRUB line. I'm not very comfortable with advanced configuration of GRUB. Or there could be some Ubuntu specific mechanism. Any way... I don't understand at all why update-grub didn't work.
 
Old 02-17-2017, 12:09 PM   #2
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,510

Rep: Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491
If you have the boot partition on sda1 and cloned it to sdc1, you need to check the UUIDs in the grub.cfg file of at least sdc1 to verify that it is using the correct UUID. If you cloned the sda1 boot files to sdc1, that isn't changing the UUID entries in the grub.cfg file.
 
Old 02-17-2017, 12:20 PM   #3
Weapon S
Member
 
Registered: May 2011
Location: Netherlands
Distribution: Debian, Archlinux
Posts: 262

Original Poster
Blog Entries: 2

Rep: Reputation: 49
Wait. Since I'm booting from sda, all the grub configuration is in sda1, right? Or do I have to chroot into the sdc1 to properly configure GRUB? I don't get it. Could you please explain?

This is what the specific entry on sda1 looks like in /boot/grub/grub.cfg. (I have replaced the UUIDs with **SDA1** and **SDC1**
Code:
menuentry 'Ubuntu 16.04.2 LTS (16.04) (on /dev/sdc1)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-simple-**SDC1**' {
	insmod part_msdos
	insmod ext2
	set root='hd2,msdos1'
	if [ x$feature_platform_search_hint = xy ]; then
	  search --no-floppy --fs-uuid --set=root --hint-bios=hd2,msdos1 --hint-efi=hd2,msdos1 --hint-baremetal=ahci2,msdos1  **SDC1**
	else
	  search --no-floppy --fs-uuid --set=root **SDC1**
	fi
	linux /boot/vmlinuz-4.4.0-62-generic root=UUID=**SDA1** ro
	initrd /boot/initrd.img-4.4.0-62-generic
}
Why is **SDA1** there?

Last edited by Weapon S; 02-17-2017 at 12:21 PM.
 
Old 02-17-2017, 03:48 PM   #4
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,510

Rep: Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491
run sudo blkid and get the UUID for sdc1. Replace the current UUID on the sda1 grub.cfg file where you have **SDA1** and **SDC1** with that UUID.

Quote:
Why is **SDA1** there?
Because you put it there when you copied/cloned sda1 to sdc1. The more interesting questions is why does the 'set root' line show the correct UUID which I expect would be explained by how Grub searches for boot files which is something I've never explored.

Last edited by yancek; 02-17-2017 at 03:58 PM.
 
Old 02-18-2017, 08:47 AM   #5
TxLonghorn
Member
 
Registered: Feb 2004
Location: Austin Texas
Distribution: Mandrake 9.2
Posts: 702

Rep: Reputation: 231Reputation: 231Reputation: 231
Moving the root partition to a new drive
You can skip the part about switching to GPT partitioning with a bios_grub partition, if you want to stick with msdos partitioning - but the rest applies.

EDIT: Actually, after reading your first post again, there is a different way to approach it. AFter you get your fstab edited correctly, you can boot into your current Ubuntu on /dev/sda1 and run
Code:
sudo update-grub
That will put the new Ubuntu on /dev/sdc1 on the Grub menu. Reboot. Chose the new menuentry for the Ubuntu on sdc1. After booting into that, run
Code:
sudo update-grub
and
Code:
sudo grub-install /dev/sdc

Last edited by TxLonghorn; 02-18-2017 at 09:28 AM.
 
Old 04-30-2017, 01:16 AM   #6
Weapon S
Member
 
Registered: May 2011
Location: Netherlands
Distribution: Debian, Archlinux
Posts: 262

Original Poster
Blog Entries: 2

Rep: Reputation: 49
I guess that will be a solid way to work around it. But I still think it is broken, because basically grub doesn't configure things right for a multi-boot Ubuntu (i.e. with two Ubuntu installations).
 
Old 04-30-2017, 11:41 PM   #7
TxLonghorn
Member
 
Registered: Feb 2004
Location: Austin Texas
Distribution: Mandrake 9.2
Posts: 702

Rep: Reputation: 231Reputation: 231Reputation: 231
Quote:
Originally Posted by Weapon S View Post
I guess that will be a solid way to work around it. But I still think it is broken,
You are wrong. It is not broken.

Quote:
Originally Posted by Weapon S View Post
basically grub doesn't configure things right for a multi-boot Ubuntu
Also wrong. What are you talking about? Give an example.

Last edited by TxLonghorn; 04-30-2017 at 11:46 PM.
 
Old 05-03-2017, 12:20 PM   #8
Weapon S
Member
 
Registered: May 2011
Location: Netherlands
Distribution: Debian, Archlinux
Posts: 262

Original Poster
Blog Entries: 2

Rep: Reputation: 49
What do you mean an example? My case is the example. I have Ubuntu. I clone the partition; I generate a new UUID for the partition. I now have a second installation of Ubuntu. I run update-grub.
GRUB detects the two installations, makes separate menu entries for the installation, sets all the parameters correctly for both installations, and then copies the UUID of the root of the current installation to a critical part of grub.cfg for the cloned installation.
If I chroot into the cloned installation and then do update-grub it will probably set the root for both installations, old and cloned, as the cloned root; but at least I'll have the cloned installation working.
I suspect it is some configuration Ubuntu has done to GRUB, and not a fault in GRUB itself.
 
1 members found this post helpful.
Old 05-03-2017, 03:27 PM   #9
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,337

Rep: Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548
I suggest that you check grub.cfg and see if grub is passing the kernel the correct UUID in the root=UUID= parameter. I have had trouble with grub doing that incorrectly in the past.

--------------------
Steve Stites
 
Old 05-04-2017, 06:21 AM   #10
TxLonghorn
Member
 
Registered: Feb 2004
Location: Austin Texas
Distribution: Mandrake 9.2
Posts: 702

Rep: Reputation: 231Reputation: 231Reputation: 231
Quote:
Originally Posted by Weapon S View Post
If I chroot into the cloned installation and then do update-grub it will probably set the root for both installations, old and cloned, as the cloned root.
If you chroot into the cloned installation and then do update-grub, it will update the grub.cfg file on the cloned installation. It will not "set the root for both installations" - whatever that means. Update-grub updates the grub.cfg file - that's it - nothing more. If you have changed the UUID's there will be no confusion between the 2 OS's.
On the other hand, if you boot into the old OS and update Grub, as I suggested, you will then have the new one listed on the Grub menu and then you can boot into it and update grub.cfg and install that grub to sdc (or to any drive).
If there is a problem, review the tutorial I linked to to see if there is a step you missed.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
can't boot into cloned deepin partition jerk Linux - Newbie 1 01-17-2016 09:04 AM
Help: Making Cloned Partition Bootable ladyrico Linux - Newbie 5 02-23-2009 11:57 PM
why must I access a partition as root when permissions are set for me? newbiesforever MEPIS 5 02-07-2008 04:07 PM
How to make a cloned partition boot? Q.. Linux - General 4 12-25-2007 08:41 PM
How do I Set up Debian on a ReiserFS Root Partition? atheist Debian 3 07-12-2004 01:19 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu

All times are GMT -5. The time now is 02:32 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration