Showing posts with label grub. Show all posts
Showing posts with label grub. Show all posts

zfs grub rescue

Boot into rescue linux
Setup the root zfspool and mounts
zfs set mountpoint=/mnt rpool/ROOT/pve-1
rm -rf /mnt/*
zfs mount rpool/ROOT/pve-1
mount -t proc /proc /mnt/proc
mount –rbind /dev /mnt/dev
mount –rbind /sys /mnt/sys
#Enter the chroot
chroot /mnt /bin/bash
source /etc/profile
You are now in the chroot
#fix apt and reinstall the required utils
dpkg –configure -a
apt-get update && apt-get dist-upgrade -y
apt-get install –reinstall grub-pc
apt-get install –reinstall zfs-initramfs
apt-get install –reinstall pve-kernel-4.4 linux-image-amd64
#install and configure
grub-install /dev/disk/by-id/
grub-install /dev/disk/by-id/
update-grub2
for x in $(cat /proc/cmdline); do case $x in root=ZFS=*) BOOT=zfs; ;; esac; done
grub-probe /
update-initramfs -u -k all
zfs set mountpoint=/ rpool/ROOT/pve-1
#exit the chroot
exit
Re-assign the mountpoint of the zfs and reboot
umount /mnt
umount rpool/ROOT/pve-1
zfs set mountpoint=/ rpool/ROOT/pve-1
Set the server to boot via hard drive and then Reboot (shutdown -r now)
If the system does not start, reboot into rescue linux and run the following to set the root path.
zfs set mountpoint=/ rpool/ROOT/pve-1


I don't know of a way to shrink a zfs partition (without a send/recreate/receive), so you better have room for your ext4 somewhere already.
  1. Create your ext partition
  2. Mount it somewhere temporarily
  3. rsync -avPX /boot/. /<tempboot>/.
  4. unmount /<tempboot>
  5. Move /boot to another location on zfs (eg. /bootbackup)
  6. Recreate /boot mountpoint and mount your new partition there
  7. Add the new boot ext4 partition to /etc/fstab
  8. Re-run update-grub (maybe even update-initramfs for good measure)
  9. Cross fingers and reboot
This is all from memory, so it's probably...right. The /bootbackup allows you to a location to periodically rsync your /boot ext4 into the pool for recovery purposes.

reset user password using GRUB and set grub password in the end Ubuntu 14.04 LTS

on boot menu

select  "e" to edit the menu item
find line starting with "linux..." and in the end append  init=/bin/bash
and press
ctrl+x

mount -o remount,rw /
passwd <username>
reboot -f

To set grub password

login as root

# grub2-mkpasswd-pbkdf2 
OR
grub-mkpasswd-pbkdf2

Password: ****
Reenter password: ****
PBKDF2 hash of your password is grub.pbkdf2.sha512.10000.9CA4611006FE96BC77A

Paste the encrypted long string into the file /etc/grub.d/40_custom

eg. copy the content starting from "grub.pbkdf2.sha512.10000.9CA461100..."

vim /etc/grub.d/40_custom

set superusers="root"
password_pbkdf2 root grub.pbkdf2.sha512.10000.9CA4611006FE96BC77A...

grub2-mkconfig -o /boot/grub2/grub.cfg
or 
grub-mkconfig -o /boot/grub2/grub.cfg

if on the local terminal use help of "tee"

grub-mkpasswd-pbkdf2 | tee myhelper.txt

your password content and other text are copied in myhelper.txt, edit this myhelper.txt file and cat its content to /etc/grub.d/40_custom

cat myhelper.txt >> /etc/grub.d/40_custom
grub-mkconfig -o /boot/grub2/grub.cfg