Question re removing/adding SATA devices


Results 1 to 15 of 15

Thread: Question re removing/adding SATA devices

  1. #1
    Join Date
    Oct 2006
    Posts
    41

    Question re removing/adding SATA devices

    My PC boots Ubuntu 7.04 off /dev/SDC. Two other drives are on board, recognised as /dev/SDA and /dev/SDB. If I remove the drives currently identified as SDA and SDB, will SDC become SDA on reboot, meaning Linux will fall over with a grub error, or will the device remain SDC and the boot process work as it does with SDA and SDB present?

  2. #2
    Join Date
    Sep 1999
    Posts
    3,202
    Your fstab file (in /etc) should reference the hard drive by a unique number, not the device name/number.

    cat /etc/fstab and look for something like
    Code:
    UUID=b99684c6-2d7b-4a8c-b9a7-0c94c6846489 / ext3 defaults,errors=remount-ro 0 1
    If you have teh UUID references, it won't matter. And you should have 'em, since this is how Ubuntu 7.x sets things up...

  3. #3
    Join Date
    Apr 2001
    Location
    SF Bay Area, CA
    Posts
    14,936
    But /etc/fstab can't be read before the root FS is mounted. So while /etc/fstab does have to be correct (referring to devices by UUID, or possibly LABEL), you may also have to change one or more of the parameters that get sent to Ubuntu's initramfs. The initramfs is what mounts the root FS; everything else is mounted by the boot scripts based on /etc/fstab.

    (But I'm guessing you won't have to worry about it. )

    If all else fails, you can remove the two drives for testing, see if you can boot up, and if not, put them back in and try to fix the problem.

  4. #4
    Join Date
    Jun 2004
    Location
    Newcastle upon Tyne
    Posts
    2,978
    I think there are two issues. One is with Grub and the other with Ubuntu Linux.

    Since recent versions of Ubuntu use uuid reference to find the root partition the disk order is no longer a problem. A reduction of the first two disks does not alter the uuid so Linux is OK.

    However Grub boots the Linux by idenifying the partition number and disk number in the "root" statement. This needs to be amended, possibly like from
    Code:
    root (hd2,1)
    to
    Code:
    root (hd0,1)
    otherwise Grub would complain "disk does not exist"

    Grub also has /boot/grub/device.map that defines (hd0), (hd1) and (hd2) for sda, sdb and sdc. That may need to be altered too.

    Mind you as Linux uses only one swap (normally), so removing sda and sdb may cause the swap missing and the distro may not like it.
    Linux user started Jun 2004 - No. 361921
    Using a Linux live CD to clone XP
    To install Linux and keep Windows MBR untouched
    Adding extra Linux & Doing it in a lazy way
    A Grub menu booting 100+ systems & A "Howto" to install and boot 145 systems
    Just cloning tips Just booting tips A collection of booting tips

    Judge asked Linux "You are being charged murdering Windoze by stabbing its heart with a weapon, what was it?" Replied Linux "A Live CD"

  5. #5
    Join Date
    Oct 2006
    Posts
    41
    clearly then, Linux still has some rote basics to catch up on in the user friendliness "it just works" category. I have a 400GB NTFS drive to remove, it's not even mounted in Linux yet removing it is likely to cause me to have to fiddle. Not a great endorsement.

    Don't get me wrong, I choose Linux over Windows every time, but simple things like adding or removing drives should not be enough to stop an OS booting without a user having to go and fiddle with settings in some text files prior to rebooting.
    Last edited by UbuntuBantu; 07-06-2007 at 08:08 AM.

  6. #6
    Join Date
    Jun 2004
    Location
    Newcastle upon Tyne
    Posts
    2,978
    UbuntuBantu

    Let's look at the matter realistically.

    Every system you install, regardless if it is a modern MS system (Win2k, xp & Vista), a Linux, a BSD or a Solaris, the operating system will has inside it a record on which disk and which partition it was installed. Most record it as disk (x) where x is a number.

    By removing some disks in the setup you destroy the disk order and none of them will work. You can only avoid such a problem if the OS you boot to is in the 1st disk. A XP or a Vista installed in the 2nd disk with refuse to work if the 1st disk is removed.

    Thus the problem is not system specific but one should be aware of.

    It so happen Linux is a lot easier to put right if you move it from partition to partition and from hard disk to hard disk. You normally need a re-installation with a MS system if its disk reference is invalid.

    If you use Grub to boot any system the very first thing you declare is the root of that partition by a statement like
    Code:
    root (hdx,y)
    where x is the disk number and y the partition number.

    Therefore it is not a big deal if you physically change the disk order and tell Grub the new disk number is now z and not x.

    You will find Linux as friendly as you want if you install it in the 1st disk and therefore able to add or delete other disks without affecting its booting procedure.

    Last point I don't think you know how lucky you are by having Grub. This is because if a system doesn't boot you can press "c" to drop into a Grub prompt to talk to Grub directly. There you can ask Grub to show you the disk order (by "geometry (hd0)" command), display the booting configuration (by "cat /boot/grub/menu.lst" command) and the type the correct entries at the terminal to boot the system up manually. There is no PC system Grub cannot boot in a Grub prompt.

    The text file you do not want to edit is the manual comands you could have to use to boot the operating systems manually. The matter is therefore entirely in your hand to control everything. No boot loader give you more flexibility or a better services than Grub.
    Last edited by saikee; 07-06-2007 at 09:07 AM.
    Linux user started Jun 2004 - No. 361921
    Using a Linux live CD to clone XP
    To install Linux and keep Windows MBR untouched
    Adding extra Linux & Doing it in a lazy way
    A Grub menu booting 100+ systems & A "Howto" to install and boot 145 systems
    Just cloning tips Just booting tips A collection of booting tips

    Judge asked Linux "You are being charged murdering Windoze by stabbing its heart with a weapon, what was it?" Replied Linux "A Live CD"

  7. #7
    Join Date
    Oct 2006
    Posts
    41
    Ok, thanks for the explanation. I guess I've ordinarily installed OS' in drive 1 so never come across a situation where windows refuses to boot after adding/removing drives (a situation I've encountered more than once under Linux, even just adding drives [admittedly there were ide and sata drives in the box]).

    Time to find out where the grub config files are stored.

  8. #8
    Join Date
    Oct 2006
    Posts
    41
    Ok, here we go...

    I edited grub files and changed references to hd2, to hd0, disconnected old hda and hdb and then started up. Who would've guessed..."operating system not found". Reconnect drives and it turns out grub is installed on the 400gb drive, presumably in its mbr. What can I do to work around this?

    Of course, now I also have grub telling me it cannot mount the selected partition so I guess I'll be fiddling a little more than I wanted to.

    [Edit:] set root, loaded kernel and tried to boot from grub command line and pc crashed... any ideas how to get this box up again - I did make copies of menu.lst and device.map - the copies are located at ~/Desktop/grub/
    Last edited by UbuntuBantu; 07-06-2007 at 10:28 AM.

  9. #9
    Join Date
    Jun 2004
    Location
    Newcastle upon Tyne
    Posts
    2,978
    The matter is quite simple if you press "c" key to get a Grub prompt.

    You tell Grub to find the partition that has menu.lst, by command
    Code:
    find menu.lst
    Grub should respond with an answer like
    Code:
    (hdx,y)
    Adjust the value of x and y to suit your own case.

    If you want to boot the system immediately the command is
    Code:
    configfile (hdx,y)/boot/grub/menu.lst
    or
    Code:
    configfile (hdx,y)/grub/menu.lst
    if you have put /boot in a separate partition. Omit "/boot" in subsequent instructions.

    If you want to restore Grub in the MBR of disk (hdx) the command is
    Code:
    root (hdx,y)
    setup (hdx)
    If you want to boot the mbr of disk (hdx) the command is
    Code:
    chainloader (hdx)+1
    If Grub can't pull up the Linux you ask Grub to display the menu.lst by
    Code:
     cat (hdx,y)/boot/grub/menu.lst
    You can then type the lines one by one to correct any obvious mistake. When everything has been typed the green light for Grub to fire up the linux is
    Code:
    boot
    If you still have a problem. Post here the content of Ubuntu's

    (1) /boot/grub/menu.lst
    (2) /etc/fstab
    Linux user started Jun 2004 - No. 361921
    Using a Linux live CD to clone XP
    To install Linux and keep Windows MBR untouched
    Adding extra Linux & Doing it in a lazy way
    A Grub menu booting 100+ systems & A "Howto" to install and boot 145 systems
    Just cloning tips Just booting tips A collection of booting tips

    Judge asked Linux "You are being charged murdering Windoze by stabbing its heart with a weapon, what was it?" Replied Linux "A Live CD"

  10. #10
    Join Date
    Oct 2006
    Posts
    41
    I tried using the grub command line and it responded with file not found when I sent it looking for menu.lst. I whipped out the good old ubuntu livecd and replaced the edited grub files with the originals - box is up and running again.

    I want to remove the two NTFS drives for the time being, possibly permanently. The contents of /boot/grub/menu.lst as follows:
    Code:
    ## ## End Default Options ##
    
    title		Ubuntu, kernel 2.6.20-16-generic
    root		(hd2,0)
    kernel		/boot/vmlinuz-2.6.20-16-generic root=UUID=b0a3da1b-3e0a-45c0-98d8-b66617d57c70 ro quiet splash
    initrd		/boot/initrd.img-2.6.20-16-generic
    quiet
    savedefault
    
    title		Ubuntu, kernel 2.6.20-16-generic (recovery mode)
    root		(hd2,0)
    kernel		/boot/vmlinuz-2.6.20-16-generic root=UUID=b0a3da1b-3e0a-45c0-98d8-b66617d57c70 ro single
    initrd		/boot/initrd.img-2.6.20-16-generic
    
    title		Ubuntu, kernel 2.6.20-15-generic
    root		(hd2,0)
    kernel		/boot/vmlinuz-2.6.20-15-generic root=UUID=b0a3da1b-3e0a-45c0-98d8-b66617d57c70 ro quiet splash
    initrd		/boot/initrd.img-2.6.20-15-generic
    quiet
    savedefault
    
    title		Ubuntu, kernel 2.6.20-15-generic (recovery mode)
    root		(hd2,0)
    kernel		/boot/vmlinuz-2.6.20-15-generic root=UUID=b0a3da1b-3e0a-45c0-98d8-b66617d57c70 ro single
    initrd		/boot/initrd.img-2.6.20-15-generic
    
    title		Ubuntu, memtest86+
    root		(hd2,0)
    kernel		/boot/memtest86+.bin
    quiet
    
    ### END DEBIAN AUTOMAGIC KERNELS LIST
    Contents of /boot/grub/device.map as follows:
    Code:
    (hd0)	/dev/sda
    (hd1)	/dev/sdb
    (hd2)	/dev/sdc
    Contents of /etc/fstab as follows:
    Code:
    # /etc/fstab: static file system information.
    #
    # <file system> <mount point>   <type>  <options>       <dump>  <pass>
    proc                                       /proc           proc         defaults                          0  0  
    # /dev/sdc1
    UUID=b0a3da1b-3e0a-45c0-98d8-b66617d57c70  /               ext3         defaults,errors=remount-ro        0  1  
    # /dev/sdc5
    UUID=4bf8b36e-0eda-4900-a5b2-49a5880dfc93  none            swap         sw                                0  0  
    /dev/scd0                                  /media/cdrom0   udf,iso9660  user,noauto                       0  0  
    /dev/fd0                                   /media/floppy0  auto         rw,user,noauto                    0  0
    What do I need to change in order to move the MBR to /dev/sdc and boot this box without the current /dev/sda and /dev/sdb? My plan is to make the necessary edits, save them, shut the box down, remove said drives, reboot machine. On reboot I presume /dev/sdc will become /dev/sda?

  11. #11
    Join Date
    Jun 2004
    Location
    Newcastle upon Tyne
    Posts
    2,978
    Your case has been accurately predicted by ph34r and bwkaz that your Ubunru is using uuid method for identifying the partitions making future changes easy.

    Lets talk it through what will happen it appears you want to retain sdc the 3rd disk and remove the sda and sdb.

    (1) menu.lst

    I think the 5 occurrences of (hd2,0) need to be changed into (hd0,0), so that Grub does not have to find the files from the 3rd disk. I have modified your menu.lst. The changes needed are in red.
    Code:
    ## ## End Default Options ##
    
    title		Ubuntu, kernel 2.6.20-16-generic
    root		(hd0,0)
    kernel		/boot/vmlinuz-2.6.20-16-generic root=UUID=b0a3da1b-3e0a-45c0-98d8-b66617d57c70 ro quiet splash
    initrd		/boot/initrd.img-2.6.20-16-generic
    quiet
    savedefault
    
    title		Ubuntu, kernel 2.6.20-16-generic (recovery mode)
    root		(hd0,0)
    kernel		/boot/vmlinuz-2.6.20-16-generic root=UUID=b0a3da1b-3e0a-45c0-98d8-b66617d57c70 ro single
    initrd		/boot/initrd.img-2.6.20-16-generic
    
    title		Ubuntu, kernel 2.6.20-15-generic
    root		(hd0,0)
    kernel		/boot/vmlinuz-2.6.20-15-generic root=UUID=b0a3da1b-3e0a-45c0-98d8-b66617d57c70 ro quiet splash
    initrd		/boot/initrd.img-2.6.20-15-generic
    quiet
    savedefault
    
    title		Ubuntu, kernel 2.6.20-15-generic (recovery mode)
    root		(hd0,0)
    kernel		/boot/vmlinuz-2.6.20-15-generic root=UUID=b0a3da1b-3e0a-45c0-98d8-b66617d57c70 ro single
    initrd		/boot/initrd.img-2.6.20-15-generic
    
    title		Ubuntu, memtest86+
    root		(hd0,0)
    kernel		/boot/memtest86+.bin
    quiet
    
    ### END DEBIAN AUTOMAGIC KERNELS LIST
    (2) device.map

    Once you remove sda and sdb Linux will give sda status to the only disk detected. Therefore you should disable sdb and sdc simply by prefixing a # as follow

    Code:
    (hd0)	/dev/sda
    #(hd1)	/dev/sdb
    #(hd2)	/dev/sdc
    (3) /etc/fstab

    I believe there is no change needed here because Ubuntu boots the root of Ubuntu by

    UUID=b0a3da1b-3e0a-45c0-98d8-b66617d57c70 and the swap by
    UUID=4bf8b36e-0eda-4900-a5b2-49a5880dfc93.

    The uuid numbers are stamped on the partitions in sdc when there were formatted. This new way of find the correct partitions is designed for dealing with situations like what you have got here.

    Let us know the progress.
    Linux user started Jun 2004 - No. 361921
    Using a Linux live CD to clone XP
    To install Linux and keep Windows MBR untouched
    Adding extra Linux & Doing it in a lazy way
    A Grub menu booting 100+ systems & A "Howto" to install and boot 145 systems
    Just cloning tips Just booting tips A collection of booting tips

    Judge asked Linux "You are being charged murdering Windoze by stabbing its heart with a weapon, what was it?" Replied Linux "A Live CD"

  12. #12
    Join Date
    Apr 2003
    Location
    UK
    Posts
    1,180
    Saikee missed something from his otherwise excellent instruction, and that is that GRUB is not installed to the MBR of your current sdc. This means you'll have to reinstall GRUB.

    This is what you need to do:

    Remove the drives you don't want.
    Boot from a live cd.
    Mount your Ubuntu partition somewhere, lets say to /mnt/ubuntu
    Run "grub-install /dev/sda --root-directory=/mnt/ubuntu --recheck"
    Make the suggested changes to your menu.lst

    This will also rewrite your device.map file so you shouldn't need to edit that.

  13. #13
    Join Date
    Jun 2004
    Location
    Newcastle upon Tyne
    Posts
    2,978
    Thanks retsaw. You are right I did miss the boot loader bit.

    An alternative (lazier way) to restore Grub is as follow

    While there are 3 disks and Linux is still running and both menu.lst and device.map have been edited and before the PC is power down I would activate the Grub shell and setup Grub in the sdc disk by
    Code:
    sudo grub
    root (hd2,0)
    setup (hd2)
    Grub will put stage1 in the MBR of sdc disk and hard code it to the partition (hd2,0). This will work when sda and adb are removed because Grub uses hardware address in the setup.

    retsaw recommendation is the other alternative. My proposal is lazier. Both are the proper methods to restore Grub. Just use one if the other fails to give the desirable result.

    Thanks to retsaw as I didn't realise grub-install adjusts the device.map too although I am aware it is altered at some stage
    Last edited by saikee; 07-07-2007 at 05:18 AM.
    Linux user started Jun 2004 - No. 361921
    Using a Linux live CD to clone XP
    To install Linux and keep Windows MBR untouched
    Adding extra Linux & Doing it in a lazy way
    A Grub menu booting 100+ systems & A "Howto" to install and boot 145 systems
    Just cloning tips Just booting tips A collection of booting tips

    Judge asked Linux "You are being charged murdering Windoze by stabbing its heart with a weapon, what was it?" Replied Linux "A Live CD"

  14. #14
    Join Date
    Oct 2006
    Posts
    41
    Thanks for assisting me with this. I'll try this tonight and report my results tomorrow. I might add also that in all the years lurking and/or posting in Linux forums, Justlinux is the one I keep coming back to - knowledgeable individuals who go out of their way to help. Thanks again.

  15. #15
    Join Date
    Apr 2003
    Location
    UK
    Posts
    1,180
    Quote Originally Posted by saikee
    Thanks to retsaw as I didn't realise grub-install adjusts the device.map too although I am aware it is altered at some stage
    It is actually the --recheck option that causes this, otherwise GRUB will just assume the device.map is correct and uses it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •