# Debian/Grub2 : Moving origin dividing to new drive?

Does any person have a pointer for just how to relocate the origin dividing to a new drive and also set up grub2 too on that particular drive? I appear to have no good luck advising grub - mkconfig what it is I intend to do (as an example chroot' int right into my new origin simply perplexes all the manuscripts).

History I am running Debian Squeeze on a brainless reduced - power NAS. My existing arrangement is / on sda0 and also /boot on sde0 (a CF card) : I required the different /boot due to the fact that sd[a-d] require to do a postponed spin - up. Currently I've located an old 2.5" IDE disk to make use of as / consisting of /boot to permit me to rotate all the large disks down.

What I've attempted Basically I went

mount -o rw /dev/sdf5 /mnt/newroot
cp -ax / /mnt/newroot
cp -ax /boot /mnt/newroot/boot


Then I attempted

chroot /mnt/newroot
update-grub


But that fallen short with grub asking if origin was placed. After that I did a fifty percent - hearted effort at establishing /mnt/newroot/grub/grub.cfg to locate the kernel photo on sdf5, adhered to by a grub-install --root-directory=/mnt/newroot /dev/sdf. Yet this simply landed me a grub rescue motivate when I attempted starting from sdf.

My backup strategy is to simply re-install, so an incentive inquiry (no checkmarks for this set): What do I need to do to get my lvm2 and also mdadm config throughout? Is all of it saved in the filesystems (and also will it be instantly uncovered), or do I require to take of it myself?

Remedy (many thanks to Maciej Piechotka) : As Maciej mentions, I require to to a correct chroot for all the grub devices to function. For reference, this is just how I did it:

[email protected]:/mnt/newroot$sudo cp -ax / /mnt/newroot [email protected]:/mnt/newroot$ sudo cp -ax /boot /mnt/newroot


All the documents are currently replicated (see here for a conversation of duplicate approaches). Deal with the new etc/fstab to indicate new origin:

[email protected]:/mnt/newroot$diff -u etc/fstab.old etc/fstab -UUID=399b6a6d-c067-4caf-bb3e-85317d66cf46 / ext3 errors=remount-ro 0 1 -UUID=b394b614-a977-4860-bbd5-7862d2b7e02a /boot ext3 defaults 0 2 +UUID=b9d62595-e95c-45b1-8a46-2c0b37fcf153 / ext3 noatime,errors=remount-ro 0 1  Finally, place dev, sys and also proc to the new origin and also chroot: [email protected]:/mnt/newroot$ sudo mount -o bind /dev /mnt/newroot/dev
[email protected]:/mnt/newroot$sudo mount -t proc none /mnt/newroot/proc [email protected]:/mnt/newroot$ sudo mount -t sysfs none /mnt/newroot/sys
[email protected]:/mnt/newroot$sudo parted /dev/sdb set 5 boot on [email protected]:/mnt/newroot$ sudo chroot .


We are currently chrooted to the future origin specifically as it will certainly look. According to Maciej, it needs to be alright to simply call grub-install, yet I did an update-grub first to get a consider the created /boot/grub/grub.cfg prior to mounting the bootloader. I am not exactly sure it will be instantly upgraded?

[email protected]:/# update-grub
[email protected]:/# grub-install /dev/sdb

0
2019-05-13 04:39:31
Source Share

Mount standard filesystems and also copy/modify documents while chrooting like:

• / dev (mount -o bind /dev/ /path/to/chroot/dev)
• / proc (mount -t proc none /path/to/chroot/proc)
• / sys (mount -t sysfs none /path/to/chroot/sys)

IIRC that benefited me while mounting Grub 2 in arc and also countless times on Gentoo. After that after chroot to /path/to/chroot command was merely:

grub-install /dev/<boot_disk>


As of lvm2 (and also I belive madm yet I have not utilized it) the arrangement is saved on disk. There is arrangement what needs to read to uncover tools. Thinking your tools remain in typical areas (/dev/sd* or /dev/hd*) there need to be no worry.

PS. I would certainly not rely on straightforward cp of real-time system as there are numerous areas where it can fail:

• Forgot to transform /etc/fstab and also various other valuable documents
• Files transformed throughout accessibility
• Coping waste (/tmp etc)
0
2019-05-17 19:20:37
Source

you can install grub from real-time distro without chrooting:

grub-install /dev/hda --root-directory=/mnt/guest/

0
2019-05-17 18:39:55
Source