Restore Grub Encrypted Partition, Sabayon [Solved]

If you are new to Linux or new to Sabayon Linux and just not sure where to post, here ya go. Post without fear of being told to RTFM :-)

Moderator: Moderators

Restore Grub Encrypted Partition, Sabayon [Solved]

Postby unkn-error » Sun Jun 10, 2012 15:57

I did followed this: ... _Partition

and this: ... tore_Grub2

With a try to change the /dev/sdaX names according to my partition table.


My first partition (primary) which is sda1 is windows XP
My second partition (primary) sda2 was another linux distro, here I was testing a lot of them.

My third partition (primary) sda3 was the boot /boot for sabayon, always there, never touched : o )

When testing distros was easy to boot them as I was installing them in /dev/sda2, the "/" grub also included in /dev/sda2 and I had to just mark the /dev/sda2 as bootable.
So, in this way, the MBR was never touched, which is a good thing from my own point of view.

If something went wrong, with the experimental distro from /dev/sda2 then, I could easy revert back,
marking the /dev/sda3 as bootable, as there was the sabayon grub installed expecting me ; o ) and I could easly acces windows, sabayon linux or other distros.

The other partitions are logical.
The first logical partition has the "/" for sabayon which is encrypted. This is a second reason for using a /sda3 for /boot.
The second logical is swap encrypted
The third one is ntfs data related.

Now, I have finished my "distro-testing" and swiching, at least for the moment and I merged sda1 with sda2, making my sda1 larger. So now my first ntfs partition sda1 is bigger and can fit a ubuntu with wubi install.

The problem appeard as sda3 is now called sda2 and sabayon dosen't boot anymore.
I have booted the live cd and hit the installer icon, I reinstalled grub from there but it dosen't work, and I think it touched my mbr. Anayway, I restored my original mbr from a backup, but I need to reinstall the grub because I really wish to boot sabayon linux.

>>> I have gived some tries for restoring grub, with chroot from sabayon live cd and from ubuntu but I wasn't able to restore it.
Please tell me the exact chain commands I have to give in this scenario, I am sure that I am doing something wrong but it don't know what. <<<

Code: Select all
[email protected]:~$ sudo su
[sudo] password for wolfy:
[email protected]:/home/wolfy# cd /mnt/
[email protected]:/mnt# ls
boot  enc
[email protected]:/mnt# rm -f enc/
rm: cannot remove `enc/': Is a directory
[email protected]:/mnt# man rm
[email protected]:/mnt# rm -rf enc/
[email protected]:/mnt# ls
[email protected]:/mnt# fdisk -lu

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x62d363a6

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *          64   142946369    71473153    7  HPFS/NTFS/exFAT
/dev/sda2       142946370   143572904      313267+  83  Linux
/dev/sda3       143572905   976768064   416597580    5  Extended
/dev/sda5       143572968   227544659    41985846   83  Linux
/dev/sda6       227544723   231737624     2096451   82  Linux swap / Solaris
/dev/sda7       231737688   976768064   372515188+   7  HPFS/NTFS/exFAT

Disk /dev/sdb: 8016 MB, 8016363520 bytes
255 heads, 63 sectors/track, 974 cylinders, total 15656960 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x72f0e0f4

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *          63    15647309     7823623+   b  W95 FAT32
[email protected]:/mnt# ls
[email protected]:/mnt# mkdir sabayon
[email protected]:/mnt# ls
boot  sabayon
[email protected]:/mnt# rm -rf sabayon/
[email protected]:/mnt# mkdir -p sabayon
[email protected]:/mnt# ls
boot  sabayon
[email protected]:/mnt# cd /mnt/
[email protected]:/mnt# cryptsetup luksOpen /dev/sda5 encrypted
Enter passphrase for /dev/sda5:
[email protected]:/mnt# mount /dev/mapper/encrypted /mnt/sabayon/
[email protected]:/mnt# ls
boot  sabayon
[email protected]:/mnt# cd sabayon/
[email protected]:/mnt/sabayon# ls
bin   dev  home          lib         media  opt   root  sbin  tmp  var
boot  etc  install-data  lost+found  mnt    proc  run   sys   usr  z
[email protected]:/mnt/sabayon# cd ..
[email protected]:/mnt# mount /dev/sda2 /mnt/boot/
[email protected]:/mnt# ls
boot  sabayon
[email protected]:/mnt# mc

[email protected]:/mnt# mount -t proc none /mnt/sabayon/proc/
[email protected]:/mnt# mount -o bind /dev /mnt/sabayon/dev
[email protected]:/mnt# chroot /mnt/sabayon/ /bin/bash
ubuntu / # env-update
>>> Regenerating /etc/
ubuntu / # ls
bin   dev  home          lib         media  opt   root  sbin  tmp  var
boot  etc  install-data  lost+found  mnt    proc  run   sys   usr  z
ubuntu / # source /etc/profile
ubuntu / # export PS1="(chroot) $PS1"
(chroot) ubuntu / # grep -v rootfs /proc/mounts > /etc/mtab
(chroot) ubuntu / # cp /proc/mounts /etc/mtab
(chroot) ubuntu / # grub2-install /dev/sda2
/sbin/grub-probe: error: no such disk.
Auto-detection of a filesystem of /dev/mapper/encrypted failed.
Try with --recheck.
If the problem persists please report this together with the output of "/sbin/grub-probe --device-map="/boot/grub/" --target=fs -v /boot/grub" to <[email protected]>
(chroot) ubuntu / #
Last edited by unkn-error on Mon Jun 18, 2012 16:24, edited 2 times in total.
Baby Hen
Posts: 16
Joined: Tue Apr 03, 2012 19:03

Re: Restore Grub Encrypted Partition, Sabayon

Postby batvink » Sun Jun 10, 2012 18:07

so you CAN chroot into your SL install, and this is your new partition table?
Code: Select all
Disk identifier: 0x62d363a6

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *          64   142946369    71473153    7  HPFS/NTFS/exFAT
/dev/sda2       142946370   143572904      313267+  83  Linux
/dev/sda3       143572905   976768064   416597580    5  Extended
/dev/sda5       143572968   227544659    41985846   83  Linux
/dev/sda6       227544723   231737624     2096451   82  Linux swap / Solaris
/dev/sda7       231737688   976768064   372515188+   7  HPFS/NTFS/exFAT

Where /dev/sda2 is Sabayon /boot partition, and /dev/sda5 is Sabayon / (root) partition., right?
When chrooted into your SL installation, goto your "/etc/fstab" and change the lines concerning your "/boot" and "/" partitions. My guess is, that in your fstab the partitions are defined by their unique UUID, but as you changed the partition table probably the UUID of the partitions has changed.

If you want to keep defining your part. with UUID, BEFORE chrooting,and AFTER you unlocked your encrypted partitions, just enter as root "blkid" and you see al your partitions and their associated UUID's
Just copy over the according UUID's for your partitions into fstab. otherwise, enter the block devices directly...
eg, /dev/sda2 /boot ext4 defaults 1 2
User avatar
Old Dear Hen
Posts: 495
Joined: Sun Oct 28, 2007 11:44
Location: the netherlands

Re: Restore Grub Encrypted Partition, Sabayon

Postby unkn-error » Wed Jun 13, 2012 13:02

These are the exact steps I did:

I have first installed windows xp into the hardisk, and at the install time, I created a partition which is sda1 (primary) and windows xp is installed there.

This was with a size of 50 Gb.

I've created the secondary primary partition which is sda2 aprox 20 Gb. (for distro testing)

I've created the third primary partition which is sda3 aprox 300 Mb (for boot sabayon)

I've created the next partition as Logical,
and In it,

the first logical partition with aproximate size of 40-50 Gb for sabayon "/".
the secondary logical parition aproximate size of 2 Gb. for Swap.
the third logical parition for data storage (ntfs)

I have been carefull for letting a little space before and after with the proporse that all partition tools should work, as "cfdisk" gives some error if there is no free space in the end of the hdd, and now all partition managers work (cfdisk, acronis, gparted, etc.)

Next I did a Acronis back-up of the windows partition image(sda1), and I installed sabayon with this setup scenario:

In the third parition /dev/sda3 (primary) boot 300 Mb assigned as /boot unencrypted.
At the install time I choosed for the grub to be installed in /dev/sda3, not im mbr.

The first logical parition I assigned the "/" and I choosed encrypted (damn it!)
The secondary logical partition I assinged the "swap" and I chosed encrypted.

Then I've formated the secondary primary partition (sda2) with ext4 and I changed the boot flag from /sda3 to /sda2.
Here where installed a lot of distros, as ubuntu, fedora, suse, etc. etc. And always I choosed at the "testing distro install time" for grub to install in /sda2 which was also the "/" for the testing distro.

If I wished to boot sabayon I changed the flag to /sda3
If I wished to boot the testing distro I changed the flag to /sda2
If something went bad (as in this case) I changed the boot flag /sda1 and windows started, as the mbr was untouched.

Everything good till here.

Now, I finised to test other linux distros and I decided to make my windows partition bigger, and I deleted the sda2 (ext4, linux distro test) and resiezed the sda1 (winxp, ntfs).

When I did this, the /sda3 (which was for booting the encrypted sabayon) becamed /sda2 and did not worked correctly anymore.

Because this happend, I changed the flag to /sda1 and used winxp.

In windows XP I installed ubuntu with WUBI, and now ubuntu resides in /sda1/ubuntu(folder)/some stuff.

Then I have tried to reinstall sabayon by booting the live cd and I did a grub reinstall as follows:

I started the sabayon installer from desktop, choosed grub recovery, and As I have seen, grub went into my mbr, and when I wish to boot the encrypted sabayon I have this screen:

Because I don't like my mbr to be touched with grub stuff, and from there did not worked even as a temporary solution, I restored the MBR from acronis backup.

The next step I did, was a try to reinstall grub from the ubuntu wubi install into /sda2 (which is now -"sabayonboot") with the help from wiki tutorials, but something dosen't works.

If I boot the /sda2 (sabayon boot) now I have only a black screen wich say "gurb loading" and a prompter which blinks but I can't type anything.
Like this:

The Ubuntu Wubi say this in terminal when I paste the command:

Code: Select all
[email protected]:/home/wolfy# for d in $(sed -ne 's/^.*\(sd.*\)/\1/p' /proc/partitions);do echo -e "$d\t ID: $(sudo hexdump -v -s 0x80 -n 2 -e '2/1 "%x" "\n"' /dev/$d)";done;echo -e "\nGRUB 1: 5272/aa75\nGRUB 2: 7c3c/48b4/020"
sda    ID: bc81
sda1    ID: 8cd
sda2    ID: 020
sda3    ID: 00
sda5    ID: 20a7
sda6    ID: 03c
sda7    ID: 8cd

GRUB 1: 5272/aa75
GRUB 2: 7c3c/48b4/020
[email protected]:/home/wolfy#

This is what cfdisk say about my partitions:

Here is what blkid say:
Code: Select all
[email protected]:/# blkid
/dev/loop0: UUID="fc7a4d72-3e9f-4178-bfc4-bb38c1ce1e0d" TYPE="ext4"
/dev/sda1: LABEL="WinSys" UUID="4CB4B8A6B4B89444" TYPE="ntfs"
/dev/sda2: LABEL="bootsabayon" UUID="e41e9722-68f4-427a-a654-6db70636987b" TYPE="ext4"
/dev/sda5: UUID="b4f8de00-2142-4ac1-89b4-f37dc66f9b0d" TYPE="crypto_LUKS"
/dev/sda6: UUID="b6baf991-11af-45d9-905f-e432f032cf5e" TYPE="crypto_LUKS"
/dev/sda7: LABEL="MyData" UUID="5620BA9A20BA8093" TYPE="ntfs"
/dev/sdb1: LABEL="MYLINUXLIVE" UUID="6CC0-3D92" TYPE="vfat"
/dev/mapper/encrypted: UUID="106e2fe8-a522-4664-995c-8d8451445a0b" TYPE="ext4"

[email protected]:/# less /etc/fstab |cat
# /etc/fstab: static file system information.
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    nodev,noexec,nosuid 0       0
/host/ubuntu/disks/root.disk /               ext4    loop,errors=remount-ro 0       1
/host/ubuntu/disks/swap.disk none            swap    loop,sw         0       0

[email protected]:/# less /mnt/sabayon/etc/fstab |cat

# /etc/fstab
# Created by anaconda on Fri Jun  8 04:56:57 2012
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
UUID=106e2fe8-a522-4664-995c-8d8451445a0b /                       ext4    defaults        1 1
UUID=e41e9722-68f4-427a-a654-6db70636987b /boot                   ext4    defaults        1 2
UUID=16d02b76-2f18-4b14-ab3d-75ca10fa1d43 swap                    swap    defaults        0 0
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0

[email protected]:/#

But the system dosen't boot. And I really wish to restore grub to make the system boot... :( :?

P.s. Shoud I try to resize the first primary partiton /dev/sda1 again and create a little partition to "revert back" the name of the paritions?

Thank you for support, but especially for patience.
Baby Hen
Posts: 16
Joined: Tue Apr 03, 2012 19:03

Re: Restore Grub Encrypted Partition, Sabayon [Solved]

Postby unkn-error » Mon Jun 18, 2012 16:43


1) formated /dev/sda2 ( THE /boot PARTITION -->> NOT DELETED!!! but formatted "mkfs /dev/sda2")
2) shrieked /dev/sda1 ( THE WINDOWS PARTITION )
3) created a /dev/sda2 ( With a size of X MB, as you please)
4) Installed some linux distro there but till here my "/" sabayon bood didn't work

So Here it Comes :

5) I've started windows, and in vmware I created a new virtual machine with the following settings:

" Boot from an ACRONIS disc image (acronis.iso) "
A virtual hardisk driver (for container propose) with "allocate all disk space now" with a size of 43 Gb as my sabayon "/" was about 39 or 41 Gb.

A second Hardisk which was my psychical one attached to the virtual machine.

Then I started up the machine,

6) Created another virtual machine with psychical acces to hardisk.
I installed sabayon 8 in /dev/sda5 as "/" and /dev/sda3 with "/boot" as was in my original install scenario.
Booted up the new installed sabayon machine then "halt".

7) Started up the vmware Acronis machine, restored only the "/" into /dev/sda5.
8) I've booted up the machine, and started up my tests as this is why I wished to recover it, for the challenge of making it work again and I was curious if I'll upgrade to the new kernel which resides in sabayon 9 iso the sys will boot up, because on my sys the new iso image it dosen't.

The Result is that it is starting with the new kernel with the same version the iso is having but the wallpaper on "grub" was left as in sabayon 8, and only the bootsplash wallpaper is like in sabayon 9.
Baby Hen
Posts: 16
Joined: Tue Apr 03, 2012 19:03

Return to Beginners|Newbies Area

Who is online

Users browsing this forum: No registered users and 6 guests