Announcement

Collapse
No announcement yet.

Need to switch grub from one hard drive to another

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Need to switch grub from one hard drive to another

    My SSD keeps wrenching away priority from my HDD and causing boot-up to malfunction, so I have to go into the BIOS and manually tell it to boot my HDD, which loads grub, which lets me select the SSD or HDD.

    There was a reason for wanting to start on the HDD before, but now I have Kubuntu installed on both. I want to just remove GRUB from the HDD and then install it on the SSD. I've seen things on how to install GRUB, but not how to remove it and put it onto another hard drive. How do I achieve this?

    Thanks,

    #2
    Read this:
    https://wiki.archlinux.org/index.php...nd_restoration
    Boot Info Script

    Comment


      #3
      I can't imagine you mean to "remove" grub. Grub is installed along with your Linux install. If you remove it, you remove your ability to boot.

      I think what you want is to have grub bootable from the SSD. You still must have grub installed, you just need to add the boot record portion to the SSD. The best set up is to have the grub MBR on both drives. That way if one fails, the other is also bootable.

      This is very simple. I'll assume your HDD is /dev/sda and your SSD is /dev/sdb

      Boot up your Linux install from the HDD. Open a terminal. Type:

      sudo grub-install /dev/sdb

      Reboot.

      You should now have grub boot loader in both drives' MBR and both should boot. If the SSD doesn't boot in this configuration, it might be because your BIOS changes the drive sequence when you re-configure it. Post back if this happens, you'll have a couple more steps needed. Swapping drive cables might do the trick also.

      Since you're muking about with your MBR, now would be a good time to make a back up of it and your partition table. This simple command copies your MBR and partition table:

      sudo dd if=/dev/sda of=ssdmbr.bin bs=512 count=1

      Do this for both drives (use hddmbr.bin for drive 2) then save the files on a thumb drive for emergencies.

      Please Read Me

      Comment


        #4
        Some exposition:
        Old set-up:
        HDD = Kubuntu
        SSD = Windows 7

        I decided I just don't really use Windows much nor do I have any particular need for it. So, I switched to the current set-up:

        HDD = still Kubuntu (untouched, in case something screwy happens)
        SSD = new Kubuntu

        Now that I've explained that, its time to explain what just happened. From the HDD Kubuntu, I installed GRUB on /dev/sdb. However, the options when I see the GRUB on the SSD (/dev/sdb) still list Ubuntu (the HDD Kubuntu) and Windows 7.

        So I made the HDD the first choice to boot from again, because THAT grub lists Kubuntu HDD and Kubuntu SSD. Booted into SSD and ran update-grub, hoping it would read the OS's and change its listing to SSD Kubuntu and HDD Kubuntu. Rebooted and made the SSD priority. Its grub still lists Kubuntu and Windows 7.

        How do I kill Windows 7? It's like a recurring nightmare at this point. I just want it to go away and for GRUB to list the correct options.

        Other random info that may or may not be relevant:

        - The partitions on sdb are sdb1 (kubuntu), sdb2 (extended, 7.95gb) and ... looks like a sub-partition, if thats possible? Something weird, but the last one is listed as a dropdown from sdb2 in gparted, and its named sdb5, has an exclamation point in a triangle next to it, is listed as "unknown" for its format, and is also 7.95gb.

        - SDB1 has no mount point

        - SDA1 has its mountpoint as /

        - sda1 has the flag boot

        -sdb1 has no flags, nor do any other sdb partitions.

        Comment


          #5
          You'd have to run update-grub again after booting to the SSD.

          No partitions will have any mount points until and unless you mount them. A Kubuntu install at boot will only mount the root partition, swap, and /home if you created one at install time. To mount any others at boot you have to add them yourself. Normally, you wouldn't want everything mounted because you wouldn't need to access other installs anyway and you could accidentally mess something up.

          Grub updater will detect all installed OS's (mostly) and add them to the menu. If you delete the windows partition and run update-grub windows won't be there any more. If you haven't deleted all the windows partitions it may still be picking them up. You probably have a windows recovery partition somewhere. Most windows installs I've looked at lately have 3 or 4 partitions.

          The boot-flag doesn't matter anymore unless your computer is way old. If you have an extended partition, you're still using the older partition format - which is fine. GPT is the newer format, but your computer has to support it.

          The switching about of devices and names is a little confusing and I don't want to give advice without knowing what is what. You said /dev/sdb was the SSD, but then you say you booted to the SSD and it's /dev/sda. Please list all the partitions and the info you have. An easy way to do this is to boot to the SSD, open a terminal and type:

          sudo blkid -o list -c /dev/nul

          then copy-n-paste the output.

          Please Read Me

          Comment


            #6
            Also:

            sudo fdisk -l

            might be helpful too.

            Please Read Me

            Comment


              #7
              Thanks for sticking with me to help out.

              Output from blkid

              device fs_type label mount point UUID
              -------------------------------------------------------------------------------
              /dev/sda1 ext4 (not mounted) 35913859-86d1-4700-80d7-2b0cee93a50b
              /dev/sda2 ext4 KubuntuBackup (not mounted) 44c2dc44-a925-4a4d-bc27-49f5a20b4a39
              /dev/sda4 ntfs Network Drive (not mounted) 061F4F1B1FDEA768
              /dev/sr0 iso9660 EXPANSION (not mounted)
              /dev/sdb1 ext4 / 47e60e7d-57a9-4e79-8dd6-6369bf20a2db

              Output from fdisk
              Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
              255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 sectors
              Units = sectors of 1 * 512 = 512 bytes
              Sector size (logical/physical): 512 bytes / 4096 bytes
              I/O size (minimum/optimal): 4096 bytes / 4096 bytes
              Disk identifier: 0x00070865

              Device Boot Start End Blocks Id System
              /dev/sda1 * 2048 821223423 410610688 83 Linux
              /dev/sda2 821223424 843036671 10906624 83 Linux
              /dev/sda3 1936848894 1953523711 8337409 5 Extended
              Partition 3 does not start on physical sector boundary.
              /dev/sda4 1053274112 1468555263 207640576 7 HPFS/NTFS/exFAT
              /dev/sda5 1936848896 1953523711 8337408 82 Linux swap / Solaris

              Partition table entries are not in disk order

              Disk /dev/sdb: 250.1 GB, 250059350016 bytes
              255 heads, 63 sectors/track, 30401 cylinders, total 488397168 sectors
              Units = sectors of 1 * 512 = 512 bytes
              Sector size (logical/physical): 512 bytes / 512 bytes
              I/O size (minimum/optimal): 512 bytes / 512 bytes
              Disk identifier: 0x000b1051

              Device Boot Start End Blocks Id System
              /dev/sdb1 2048 471719935 235858944 83 Linux
              /dev/sdb2 471721982 488396799 8337409 5 Extended
              /dev/sdb5 471721984 488396799 8337408 82 Linux swap / Solaris

              Lastly, I have run sudo update-grub on the SSD and it didn't fix it. I got this output
              Generating grub configuration file ...
              Found linux image: /boot/vmlinuz-3.13.0-39-generic
              Found initrd image: /boot/initrd.img-3.13.0-39-generic
              Found linux image: /boot/vmlinuz-3.13.0-32-generic
              Found initrd image: /boot/initrd.img-3.13.0-32-generic
              Found memtest86+ image: /boot/memtest86+.elf
              Found memtest86+ image: /boot/memtest86+.bin
              Found Ubuntu 14.04.1 LTS (14.04) on /dev/sda1
              done

              Comment


                #8
                Update - after running update-grub that second time to show output, I turned on my computer this morning, booting to the grub on sdb, and it said something like

                "Warning: no such device found (lots of characters and numbers)
                grub rescue > " and waited for me to talk to it.

                So I went from getting a wrong list to it not even recognizing a device on startup. However, grub on sda still works fine and allowed me to boot into sdb.

                Comment


                  #9
                  Were the "lots of letters and numbers" a UUID like this: 35913859-86d1-4700-80d7-2b0cee93a50b? If so, it was looking for a partition you removed or re-formatted somehow.

                  Try a full grub-reinstall. Booting to hard drive as you have.
                  Then redo the grub install to the SSD but add the --root-directory option like so:

                  sudo grub-install --root-directory=/boot /dev/sdb

                  Then update grub and reboot again to the SSD and report your results.

                  Once you have this working, I'd suggest a couple things regarding your partitioning and some basic partition info:

                  MBR formatted drives like yours can have up to 4 Primary partitions or 3 Primary partitions plus 1 Extended partition. An Extended partition can hold many Logical partitions (more than you'll need). Partition numbers 1-4 are reserved for the Primary/Extended partitions so all Logical partitions begin at 5. If you're in the habit of re-arranging your partitions every so often, you'll find moving free space from one partition to another difficult so it's best avoided whenever possible

                  I find it a good practice to use a consistent scheme for partition use to avoid personal confusion. One of the things that can be confusing is partition numbering as deleting and creating partitions can cause re-munbering and partitions to be numbered out of sequence, like yours are now on the hard drive.

                  My personal preference is to make swap partition 1 since you rarely or never mess with it once created, partition 2 is for my main install, partition 3 for my backup install, partition 4 Extended, partition 5 for a personal data partition (Docs, Music, etc.) or a separate /home partition (almost the same things). I do all my drives this way.

                  Partition 4 on the hard drive is a windows leftover and should be deleted anyway, So I would also delete the swap partition and the Extended partition also and start over with that part of the disk. I wouldn't bother with partition 1 or 2 unless you want to re-size them - now would be the time to do it if you want to. Make swap partition 3 then make the remainder your Extended partition and fill it with whatever you want.

                  Some comments about using an SSD: There's lots of out-dated info out there about SSD's. I have several in use of many brands and models and all types of computers and I have studied this topic extensively and written about it often here. My advise is to use the SSD as much as possible because it will outlast your need for it anyway. Why have a high performance device like that and then not use it to it's fullest benefit? Put swap and your home on it along with your main install. If you end up needing swap space your system will slow down considerably. Why not use the fastest device for it? With 250GB you have the room for 4-8GB swap. Also, do not use Trim (Discard) as a mounting option. It causes needless wear and slows things down. Instead, do it manually a couple times a year or no more than monthly using a cron job. With your SSD you could easily use 4 primary partitions - swap, 2 installs, and a data or /home partition - and nothing else. Then use your HDD for backups and "playground" installs (new distros you want to try out, etc). You can also have 2 smaller swap partitions - one on the SSD and one on the HDD - rather than a single large one. Then set the SSD swap as higher priority than the HDD swap, thus ensuring the faster swap is used first.

                  Finally, some forum advice: When you post output from the console like you did above, enclose it with the "code" tags (use the # button from the formatting bar). This will retain the spacing from the console and make the text more readable. Here's an example:

                  Code:
                  stuart@office:~$ sudo fdisk -l
                  [sudo] password for stuart: 
                  
                  
                  Disk /dev/sda: 500.1 GB, 500107862016 bytes
                  255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
                  Units = sectors of 1 * 512 = 512 bytes
                  Sector size (logical/physical): 512 bytes / 512 bytes
                  I/O size (minimum/optimal): 512 bytes / 512 bytes
                  Disk identifier: 0x000b3378
                  
                  
                     Device Boot      Start         End      Blocks   Id  System
                  /dev/sda1            2048    33556479    16777216   83  Linux
                  /dev/sda2   *    33556480    50333695     8388608   83  Linux
                  /dev/sda3        50333696   976773167   463219736   83  Linux
                  stuart@office:~$ sudo fdisk -l
                  [sudo] password for stuart:


                  Disk /dev/sda: 500.1 GB, 500107862016 bytes
                  255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
                  Units = sectors of 1 * 512 = 512 bytes
                  Sector size (logical/physical): 512 bytes / 512 bytes
                  I/O size (minimum/optimal): 512 bytes / 512 bytes
                  Disk identifier: 0x000b3378


                  Device Boot Start End Blocks Id System
                  /dev/sda1 2048 33556479 16777216 83 Linux
                  /dev/sda2 * 33556480 50333695 8388608 83 Linux
                  /dev/sda3 50333696 976773167 463219736 83 Linux

                  See how much better the first one is?
                  Last edited by oshunluvr; Nov 15, 2014, 10:09 AM.

                  Please Read Me

                  Comment


                    #10
                    Just to be crystal clear on what you want me to do:

                    1) You want me to run grub-reinstall for the HDD, while on the HDD
                    2) Then grub-install for the SSD, while on the HDD, with the root-directory option
                    3) Then run update-grub while on the HDD
                    4) Then boot into the SSD

                    Questions:
                    1) I thought you aren't supposed to run grub on the disk you're booted into?
                    2) If this doesn't work and somehow stops me from being able to boot into either, what do I do to put the backed-up MBRs back in place?

                    Comment


                      #11
                      Missing install device on "sudo grub-install --root-directory=/boot" add " /"
                      Boot Info Script

                      Comment


                        #12
                        No, it looked to me like you booted to the SSD install from the hard drive. You want to do the grub-install --root-directory thing from the SSD and to the SSD to get it to boot. If you boot to the HDD install, then mount the SSD install and then to grub-install like this:

                        sudo mount /dev/sdb1 /mnt >>Assuming sdb1 is the SSD Kubuntu install
                        sudo grub-install --root-directory /mnt/boot /dev/sdb >>Assuming sdb is the SSD

                        I wouldn't do anything to the HDD if it's still bootable - it's your backup! We want to make the SSD bootable too.

                        To restore MBR boot sector without the partition table, the command is:

                        sudo dd if=sddmbr.bin of=/dev/sdb bs=446 count=1

                        To restore MBR boot sector with the partition table, the command is:

                        sudo dd if=sddmbr.bin of=/dev/sdb bs=512 count=1

                        Obviously; using the correct file for the correct target drive. Be very careful with dd - one typo can wipe your drive. I wouldn't do this unless you're at last resort , and we're not there yet.

                        Please Read Me

                        Comment


                          #13
                          Originally posted by verndog View Post
                          Missing install device on "sudo grub-install --root-directory=/boot" add " /"
                          Good catch = should have had /dev/sdb at the end. Fixed the earlier post!

                          Please Read Me

                          Comment


                            #14
                            Please don't be offended for me to ask again (I'm about to)... I'm just trying to be super cautious and it makes me feel better to verify everything.

                            1) Boot into the SSD (you accidentally said hard drive on an earlier post) which is on /dev/sdb as you have correctly assumed.
                            2) run sudo grub-install --root-directory=/boot /dev/sdb
                            3) run update-grub (do I need to put sudo again even after logging in with sudo on the last command?)
                            4) Reboot into SSD. Everything should be peachy.

                            Correct?

                            Also, is there a way for me to upvote you guys or anything like that? Thanks a bunch for helping out.

                            Comment


                              #15
                              Yes you need sudo for the update and yes boot to the SSD if you can. The above commands should work if you boot to the SSD.

                              You should be cautious!

                              Please Read Me

                              Comment

                              Working...
                              X