Wednesday, April 27, 2016

linux - How to boot GRUB2 so it mounts "root" on a different drive (remote server without kvm switch)

Summary:
I created a copy of the root file system on a raid array (with one disk on it), and im trying to get the system to boot off that newly copied drive.



Background:





  • 2 disks of same size in server (sda, sdb)

  • sdb not being used

  • i am trying to transition the whole thing to a raid1 mirror

  • current active partitions:


    • sda1 - boot

    • sda2 - swap

    • sda3 - root (mounted to "/")





I am not sure if it possible to make a full raid1 system which can boot off either drive, since I do not have kvm access (i can only tell them to help me out of a jam via troubleticket)



Done so far:




  • Created partitions on sdb to match sda

  • Created new raid1 array (with 1 disk)


  • /dev/md3 consists of 1 disk: /dev/sdb3

  • mount /dev/md3 /mnt/md3

  • cp -ax / /mnt/md3

  • So now I have matching copies of data on / and /dev/md3



Can I just edit GRUB2 to make /dev/md3 the root, and everything should be ok right?



I need to be absolutely sure, since I have no kvm access. I looked at /boot/grub/grub.cfg and I see this entry:




menuentry 'Ubuntu, with Linux 2.6.32-28-generic-pae' --class ubuntu --class gnu-linux --class gnu --class os {
recordfail
insmod ext2
set root='(hd0,1)'
search --no-floppy --fs-uuid --set 18de6bbd-e46d-4f89-a2c9-fa2e7fa718b7
linux /vmlinuz-2.6.32-28-generic-pae root=/dev/sda3 ro
initrd /initrd.img-2.6.32-28-generic-pae
}



So, note the "root=/dev/sda3" part. Can I just replace that with "root=/dev/md3", then reboot??

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...