Ask Your Question

How do you install grub2 on a replacement hard drive?

asked 2013-09-05 15:58:24 -0600

ZedGama3 gravatar image

updated 2014-05-16 02:56:04 -0600

I just recently moved all my partitions over to a new hard drive, but cannot get it to boot without the original hard drive installed.

Relevant Information:

  • The new drive is /dev/sda
  • I've tried grub2-install /dev/sda
  • I've tried grub2-mkconfig -o /boot/grub2/grub.cfg
  • When restarting the computer I receive an error message stating that no bootable media is available.

[root@localhost zedgama3]# parted /dev/sda print Model: ATA ST31000520AS (scsi) Disk /dev/sda: 1000GB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags:

Number Start End Size Type File system Flags 1 1049kB 6291kB 5243kB primary 2 6291kB 531MB 524MB primary ext4 3 531MB 1000GB 1000GB primary lvm

[root@localhost zedgama3]# parted /dev/sdb print Model: ATA ST3160212A (scsi) Disk /dev/sdb: 160GB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags:

Number Start End Size Type File system Flags 1 1049kB 525MB 524MB primary ext4 boot 2 525MB 160GB 160GB primary lvm

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted

answered 2013-12-11 15:00:43 -0600

updated 2015-12-05 17:25:52 -0600

After booting to a Live media Fedora and copying my partitions to new hard disk - whose root was mounted under /run/media/liveuser/newdiskroot and all other directories were properly mounted under it - I did these from the live media:

for d in /sys /dev /run /proc ; do mount -v --bind "$d" /run/media/liveuser/newdiskroot"$d" ; done
chroot /run/media/liveuser/newdiskroot
dracut -v --force --regenerate-all
grub2-install /dev/sda
grub2-mkconfig -o /boot/grub2/grub.cfg

And yes, change the /etc/fstab accordingly.

This successfully produced in normally bootable system.

edit flag offensive delete link more


Why do not mount /dev/sda1 to /mnt? How about /boot, /home?

Charles Wang gravatar imageCharles Wang ( 2013-12-12 07:10:02 -0600 )edit

Works perfectly. Use blkid to identifiy UUIDs of block devices to adjust your /etc/fstab on new root with new UUIDs. Set boot flag on new boot partition and unflag old boot partition, if boot partition moved. Don't forget to set/choose the new drive as boot drive in you BIOS boot menu when booting.

tiesel gravatar imagetiesel ( 2014-02-16 08:24:36 -0600 )edit

answered 2013-09-05 22:54:19 -0600

ZedGama3 gravatar image

I was in a hurry to get this done before school and didn't realize that the partition changes I had made didn't take effect. After setting the boot flag it now boots, but only to a recovery console. It seems to be looking for the UUID of the old /boot partition, even though I have updated the UUID in /etc/fstab. What am I missing? Where else do I need to change the UUID for /boot?

edit flag offensive delete link more



You probably need to regenerate the initramfs images with dracut --regenerate-all. In F19 onward, the initramfs needs a copy of /etc/fstab.

Gareth Jones gravatar imageGareth Jones ( 2013-09-06 11:09:59 -0600 )edit

You are absolutely right. It took me a while to figure that out. I didn't use the --regenerate-all flag, but I'll do that now. BTW you need to specify --force in order for it to overwrite the existing files. i.e. sudo dracut --regenerate-all --force

ZedGama3 gravatar imageZedGama3 ( 2013-09-06 14:46:27 -0600 )edit

answered 2016-12-04 15:10:08 -0600

Alfon gravatar image

Also if you have selinux enabled you could need to create /.autorelabel file using the touch command. If you don't do it you may not be able to log in to the system.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2013-09-05 15:58:24 -0600

Seen: 8,990 times

Last updated: Dec 05 '15