LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Suse 10.2, Boot partition flipping, Grub intimate details (https://www.linuxquestions.org/questions/linux-general-1/suse-10-2-boot-partition-flipping-grub-intimate-details-596709/)

RaduH 11-02-2007 05:01 PM

Suse 10.2, Boot partition flipping, Grub intimate details
 
Hi all,

I've read quite a bit on the Internet before deciding to post the problem here and I am sure the answer must be out there already, I just didn't find it...

I have a PC with SUSE 10.2 (SLES, if it makes a difference) and I have these two partitions: /dev/sda1 mounted in / and /dev/sda2 mounted in /passive. This /passive is empty. I need to be able to make /passive bea copy of / and boot from it.

Let me explain. I make a big fat tgz of / excluding some directories such as /proc, /sys, /tmp, /var and of course /passive. I copy the tar to /passive and untar it there (or I can even store it on a different machine and then download it to /passive when I want). I create the directories I excluded above manually (and leave them empty). Then I go to /boot/grub/menu.lst and I add an entry which looks just like the first one, I just update (hd0,0) to be hd(0,1), I update root=... to go to sda2 and I update default 0 to be default 1. In /passive/fstab, I swap the mounting locations of sda1 to be /passive and sda2 to be /. I reboot the machine and it starts up just fine booting off of the formerly passive (sda2) partition. Now I have sda1 mounted in /passive.

However, I still used the menu.lst file in sda1 (which is now passive). It turns out I am using more than just this from sda1 but I just cannot figure out what else. The system always boots after I pull such a stunt.

Then I want to do a restore into sda1 (now passive). I begin with a "rm -rf *" in what is not /passive. Then I download a tgz into that directory and untar it. To eliminate issues related to host-specific configuration data (such as host name, ip addresses, mac addresses, etc, I use a tgz created off this same machine). I do the same thing to the /passive/etc/fstab (mount sda1 into / and sda2 into /passive) and then go to the menu.lst file in /passive/boot/grub and make sure I have the entires for booting sda1 and 2, and make sure the default is 0 (sda1). For all i care, it seems I can erase menu.lst from sda2 since it is never used. Until now I just did to sda2 what I had done to sda2 before. After a reset the machine doesn't boot anymore.

I am afraid I am destroying something with my rm -rf I am not restoring when untaring my tarball. The fact that menu.lst is always used off sda1 makes me think I am missing something that would allow me to treat these two partitions symmetrically. I think I don;t understand very well what grub does from the very beginning, especially after stage1 is loaded from the MBR. I read about stage1.5 and stage2, but it is not clear to me if those files are addressed as a fixed (hardcoded) block offset location on the disk (saved in MBR, for example, at install-time) and I am screwing this up by deleting and re-copying the files (they are the same location as referred by a file system path but not same physical disk location.

After this long novel, I think my conclusion is that there's something going on during the early stages of grub and system's coming up to life that I don't really understand, nor did I find the info about (lots of pages go almost there, but not quite there...).

I hope this makes some sense and someone can help me.

Thanks,
Radu

aus9 11-02-2007 10:35 PM

the short answer is when you install grub into mbr, it must be told, and is told, where to find the rest of the booting files eg stage 2.

2) But I think what ever you are doing is not the most clever I have seen.

if you are looking for a smart way of backup have you considered partimage?

if you are testing different settings, then you are better off running a emulator such as virtualbox.

RaduH 11-03-2007 10:07 AM

You're right, it may not be the brightest idea, but it is a constraint imposed to me so I don't really have a choice, I need to make it work ...somehow :) That is using the tgz file as storage and not creating a bit-image of the partition (for that reason partimage may not work if it does what I suspect it does).

Thanks for the links to the tutorial and the troubleshooter. I'll read all that stuff hoping I'd find more details than I already found (which seem not to be enough). I'll also look at partimage, if not to use it now, at least for my enlightenment :)

Oh, one more thing: I know that info is put in the MBR, but I don't know "where" is expressed in block offset (suspect yes)or file system path (guess not) which makes the file immovable from the physical location where it was installed on the disk (unless that pointer info is also updated). Well, off to reading, looks like there's plenty for me to learn.

Thanks for your reply,
Radu

pixellany 11-03-2007 10:25 AM

Quote:

Originally Posted by RaduH (Post 2946835)
Oh, one more thing: I know that info is put in the MBR, but I don't know "where" is expressed in block offset (suspect yes)or file system path (guess not) which makes the file immovable from the physical location where it was installed on the disk (unless that pointer info is also updated). Well, off to reading, looks like there's plenty for me to learn.

Thanks for your reply,
Radu

What goes in the MBR is a pointer to the partition containing /boot (This being where the kernel and the GRUB files are). If you install GRUB using "root (hd0,1)" it will always look for the 2nd partition on the first hard disk--no matter where that is on the physical disks. But you can do something that changes the bios order of the drives (eg swapping master and slave on IDE), and then GRUB will be lost.


All times are GMT -5. The time now is 02:58 AM.