LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 07-05-2010, 04:28 AM   #1
schuurs
Member
 
Registered: Feb 2010
Location: The Netherlands
Distribution: CENTOS6.2 / RHEL5.11 / RHEL 7.4
Posts: 40

Rep: Reputation: Disabled
Move boot sector


Hello,

I have three disk in my system. One SATA (250GB) and two SCSI (73GB) disks.
The Two SCSI disks were installed originally and RHEL3 is installed on it.
The SATA disk is installed a few years later with RHEL5.

As you can see below, the boot sector is still on one of the SCSI disks (sdb1).

Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda1 236545184 15259760 209075624 7% /
/dev/sdc2 68539636 4578792 60479160 8% /users
/dev/sdb1 101089 26847 69023 29% /boot
/dev/sdb3 68437272 36963704 27997104 57% /RHEL3U7
tmpfs 2025916 652 2025264 1% /dev/shm

Can someone tell me how I can move the boot sector from the SCSI disk (sdb) to the SATA disk (sda) without losing data and without re-installation?

Thank you.
 
Old 07-05-2010, 06:35 AM   #2
saikee
Senior Member
 
Registered: Sep 2005
Location: Newcastle upon Tyne UK
Distribution: Any free distro.
Posts: 3,398
Blog Entries: 1

Rep: Reputation: 113Reputation: 113
I am not entirely sure RHEL reaction would be but in a normal set up the /boot is simply a directory and not a boot sector which can be moved and revised in /etc/fstab and /boot/grub/grub.conf. The Grub in the MBR is hard coded to hard disk address of your current sdb1 so you will need to do a "set up" with Grub again in a Grub shell or run "grub-install" in a RHEL root terminal.

It should be relative safe to have both tested and then do a switch over when you are satisfied with the result.

I outline the key steps below. Please check your /boot/grub/device.map to make sure the device name in Linux and Grub. Below I have assumed (hd0) is /dev/sda.

(1) Say you managed to resize disk sda and get some hard disk space to create a sda2, format it in Ext2/3/4, mount it and copy the content of /boot across, including all subdirectories to mounted sda2.

(2) Edit /boot/grub/grub.conf and change the partition reference in the "root" statement. That reference should in Grub and for the 1st partition of the second disk it should be (hd1,0). The equivalent for sda2 should be (hd0,1) as Grub1 counts from 0. The /boot/grub/device.map should confirm (hd0) is /dev/sda and (hd1) =/dev/sdb. If not adjust to suit.

(3) Edit /etc/fstab and replace the partition reference for /boot with device /dev/sda2. RHEL is likely to use label or uuid reference for device name of /boot. It is quite acceptable to use the traditional Linux device name /dev/sda2 as I do this all the time.

(4) Invoke a Grub shell in a RHEL root terminal and issue the following Grub commands
Code:
root (hd0,1)
setup (hd0)
quit
I assume /dev/sda is (hd0) so please check sda is your first boot disk.

(4a) Instead of using a Grub shell the set up can be achieved in a root terminal by command
Code:
grub-install /dev/sda
The system should point to sda2 on a reboot. Your sdb1 would only be visible if you mount it.

If thing works satisfactory you can proceed to use sdb1 for other purpose.

If RHEL objects to the change you may need to amend Selinux. If that is not possible you can always revert back to sdb1.

I have moved RHEL and Fedora entirely to another partitions at the cost disabling Selinux temporarily.

In a nutshell you don't move the boot sector. You simply re-hard coded Grub in the MBR to the hard disk address of a new /boot partition.

Last edited by saikee; 07-05-2010 at 06:36 AM.
 
Old 07-05-2010, 02:52 PM   #3
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,921

Rep: Reputation: 3618Reputation: 3618Reputation: 3618Reputation: 3618Reputation: 3618Reputation: 3618Reputation: 3618Reputation: 3618Reputation: 3618Reputation: 3618Reputation: 3618
You don't really move it. You can simply install a new loader such as grub with correct edits. Mark the partition active and change boot order in bios. You can leave what you have since boot order selects the first active bootable partition in bios order.

Grub usually installs fine but see any notes that may apply to your install.
 
Old 07-05-2010, 03:06 PM   #4
saikee
Senior Member
 
Registered: Sep 2005
Location: Newcastle upon Tyne UK
Distribution: Any free distro.
Posts: 3,398
Blog Entries: 1

Rep: Reputation: 113Reputation: 113
Linux never have a need to boot from an "active" partition. Both Lilo and Grub can boot a partition by-label, by-uuid, by-path or by-id and never consult the booting flag.

Only MS Windows, Solaris and BSD systems use the booting flag and that is why these systems can only boot from the "active" one of the 4 primaries, at least initially.
 
Old 07-06-2010, 01:11 AM   #5
schuurs
Member
 
Registered: Feb 2010
Location: The Netherlands
Distribution: CENTOS6.2 / RHEL5.11 / RHEL 7.4
Posts: 40

Original Poster
Rep: Reputation: Disabled
The reason I am asking this question is as follows.

Some times, the PC cannot find the onboard SCSI controller (after a reboot) during boot of the BIOS firmware.
After a shutdown and startup, it can find the SCSI controller again, but the controller order in the BIOS changed (everything else is still as set).

Initial the SATA controller was placed fourth after the SCI controller. When the BIOS firmware cannot find the SCSI controller during boot
the SCSI information disappears from the BIOS and returns after shutdown. But now, the SATA controller is located in front of the SCSI controller.
Unfortunatly, the system cannot boot after finishing the BIOS boot, because it cannot find the boot sector.

When setting the SATA controller at the end of the booting row (fourth), the system can find the boot sector again and the grub menu will pop-up again and I can choose the RHEL version I want to load.

The system I am using is an "HP XW8200".
 
Old 07-06-2010, 03:21 PM   #6
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,921

Rep: Reputation: 3618Reputation: 3618Reputation: 3618Reputation: 3618Reputation: 3618Reputation: 3618Reputation: 3618Reputation: 3618Reputation: 3618Reputation: 3618Reputation: 3618
Might want to read this.

http://www.linfo.org/active_partition.html
 
Old 01-14-2011, 06:12 AM   #7
schuurs
Member
 
Registered: Feb 2010
Location: The Netherlands
Distribution: CENTOS6.2 / RHEL5.11 / RHEL 7.4
Posts: 40

Original Poster
Rep: Reputation: Disabled
I repartitioned the disk with use of a live CD of gparted 0.7.1-5.

After repartitioning, I used a live usb thump drive with fedora 14 to reinstall grub.

Thank you for your comments
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Boot Sector bharath_neo Linux - Software 2 08-07-2007 02:20 PM
cannot find boot sector for dual boot darinbolson Linux - General 21 02-05-2006 03:42 PM
Boot Sector phoenix7 Linux - General 1 11-25-2004 10:22 AM
Boot Sector on dual boot PC. Remove Mandrake and replace with FreeBSD Phin666 *BSD 1 10-30-2004 05:02 PM
No boot sector found, error at boot areeves88 Linux - General 3 01-18-2003 08:13 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

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

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