Skip to content

Instantly share code, notes, and snippets.

@mz0
Last active July 7, 2018 14:43
Show Gist options
  • Save mz0/1785be446316c17bdded4653be0f123b to your computer and use it in GitHub Desktop.
Save mz0/1785be446316c17bdded4653be0f123b to your computer and use it in GitHub Desktop.
chroot&grub
#from sda5 (/) to sdb1, MBR/BIOS - HP Microserver N40
newroot=/mnt/b1
mount /dev/sdb1 $newroot
mount -o bind / /tmp/realroot
cd /tmp/realroot
rsync -a --exclude /tmp/realroot . $newroot/
#rsync -a -n --exclude /tmp/realroot . $newroot/
#sent 1,049,625 bytes received 122,278 bytes 260,422.89 bytes/sec
#total size is 2,516,596,807 speedup is 2,147.44 (DRY RUN)
mount -t proc /proc "$newroot/proc"
mount --rbind /sys "$newroot/sys"
mount --rbind /run "$newroot/run"
mount --rbind /dev "$newroot/dev"
chroot $newroot
vi etc/fstab # set pass=0 for old /, pass=1 for new /
grub-install /dev/sdb # intall Grub to MBR
update-grub # make /boot/grub/grub.cfg
exit
umount -l $newroot/proc
umount -l $newroot/sys
umount -l $newroot/run
umount -l $newroot/dev
umount $newroot
reboot
# adjust boot device with F10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment