Results 1 to 4 of 4

Thread: Recover GRUB in case of luks encrypted LVM partitions

  1. #1
    Join Date
    Feb 2015
    Beans
    1

    Recover GRUB in case of luks encrypted LVM partitions

    So I trying to install Windows 7 on my laptop after that it wrote over my grub.
    If you installed Windows before Ubuntu, it will work, but if you installed Windows after Ubuntu, Windows is going to overwrite the MBR of your hard disk , and GRUB is going to disappear…
    All my works are on this laptop I needed to get it up and running. For anyone who in the same situation the following steps might help you to fixed it.


    Insert Ubuntu live cd and select "Run Ubuntu Without Install" then start "console" by press CTRL+ALT+T or search in Dash Home


    1.GET Disk information
    Code:
    #fdisk -l
    
    
    Disk /dev/sda: 320.1 GB, 320072933376 bytes
    255 heads, 63 sectors/track, 38913 cylinders, total 625142448 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 4096 bytes
    I/O size (minimum/optimal): 4096 bytes / 4096 bytes
    Disk identifier: 0x2ec136ab
    
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/sda1   *        2048     1050623      524288   83  Linux    <--------------- BOOT PARTITION
    /dev/sda2         1050624   625142447   312045912   83  Linux    <--------------- CRYPT PARTITION
    2.Create Dir to mount system
    Code:
    #mkdir /mnt/system
    3.Decrypt Crypt Partition
    Code:
    #cryptsetup luksOpen /dev/sda2 encrypted-volume
    Enter passphrase for /dev/sda2:
    4.SCAN for VG
    Code:
    # vgscan
    Reading all physical volumes. This may take a while…
    Found volume group “ubuntu” using metadata type lvm2
    5.ACTIVATE VG
    Code:
    # vgchange -ay
    2 logical volume(s) in volume group “ubuntu” now active
    6.Scan for LV
    Code:
    #lvscan
      ACTIVE            '/dev/ubuntu/swap' [7.73 GiB] inherit
      ACTIVE            '/dev/ubuntu/root' [289.86 GiB] inherit
      
      
    #ls /dev/mapper/
    control encrypted-volume ubuntu-root  ubuntu-swap

    7.mount LV and the other necessary things as well (/dev/sda1 is my BOOT Partition)
    Code:
    # mount /dev/mapper/ubuntu-root /mnt/system/
    # mount /dev/sda1 /mnt/system/boot/                        
    # mount -o bind /dev/ /mnt/system/dev/
    # mount -o bind /proc/ /mnt/system/proc/


    8.Chroot into this system:
    Code:
    #chroot /mnt/system
    9.Install GRUB into MBR:
    Code:
    # grub-install /dev/sda
    Installation finished. No error reported.
    10.Update grub:
    Code:
    # update-grub
    Generating grub.cfg …
    Found linux image: /boot/vmlinuz-2.6.32-21-generic
    Found initrd image: /boot/initrd.img-2.6.32-21-generic
    Found memtest86+ image: /memtest86+.bin
    Cannot find list of partitions!
    done
    11.Reboot
    Code:
    #reboot

  2. #2
    Join Date
    Feb 2015
    Beans
    1

    Re: Recover GRUB in case of luks encrypted LVM partitions

    Thanks! Nearly got my boot partition back, still having issue with being dumped to initramfs prompt but this method has at least let me recover some data

  3. #3
    Join Date
    Jul 2016
    Beans
    1

    Thumbs up Re: Recover GRUB in case of luks encrypted LVM partitions

    This worked well, thank you for posting it!

  4. #4
    Join Date
    Jul 2007
    Location
    Magic City of the Plains
    Beans
    Hidden!
    Distro
    Xubuntu 18.04 Bionic Beaver

    Re: Recover GRUB in case of luks encrypted LVM partitions

    Old thread closed.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •