Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] convert root partition (incl. boot folder) to ext4
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
Elleni
l33t
l33t


Joined: 23 May 2006
Posts: 859

PostPosted: Thu Nov 26, 2015 7:58 pm    Post subject: [SOLVED] convert root partition (incl. boot folder) to ext4 Reply with quote

I had installed gentoo on one partition including boot with btrfs filesystem. The whole partition including boot was encrypted with luks. I did a backup with mkstage4.sh.

Now I wanted to change root filesystem to ext4, so I booted to systemrescue.iso file which I had put on a separate partition on the same disk and which was reachable as grub2 loopback bootoption.

I then decrypted the partition mounted it to /dev/mapper/root, formated it to ext4 and restored the backup file.

Now I get grub2 rescue prompt after grub2 asks me for the password for decrypting.

Apparently my grub which was able to boot (crypto0)/ from btrfs filesystem cannot read from ext4 as ls (crypto0)/ now on ext4 gives: (crypto0): Filesystem unknown.

Unfortunately I have no physical access as it is a vps.

So I have three partitions on hd0, (hd0,msdos1) swap, (hd0,msdos2) partition with rescuecd iso file. Unfortunately the filesystem on this partition was ext4 too, so its an unknown filesystem for grub 2 and (hd0,msdos3) which is the encrypted partition ->that was decrypted to (crypto0).

Is there still a possibility to rescue the System?

I will probably have to ask the hoster, to put back the standard image of ubuntu, to be able to restore my system from stage4.sh backup.

What is needed, so that after next try of restore I will not run into the same situation? I mean grub2 is obviously able to read btrfs but not ext4. And the loadable modules are not reachable as it cannot read ext4 for the moment.

What do I have to do after chrooting into restored system so ext4 will be a known filesystem for grub2?


Last edited by Elleni on Sat Nov 28, 2015 10:15 am; edited 2 times in total
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 43221
Location: 56N 3W

PostPosted: Thu Nov 26, 2015 8:10 pm    Post subject: Reply with quote

Elleni,

Grub2 needs an insmod ext2 (even for ext4) in the grub.cfg file. It will say insmod btrfs in your backup.
I'm not sure if the ext2 module will be available without a grub reinstall.

You will also need to edit /etc/fstab as that will have the wrong fs for root, which will cause rootfsck to fail and root to be mounted read only.

-- edit --

Oh, your kernel needs to support ext4 too.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Elleni
l33t
l33t


Joined: 23 May 2006
Posts: 859

PostPosted: Thu Nov 26, 2015 8:25 pm    Post subject: Reply with quote

I had modified fstab and compiled kernel with ext4 support. But I did not think of grub.cfg file. I thought that ext2.mod is automatically loaded. Well I guess, there is no way to rescue system by myself, right?

So I will ask for a reset to the standard ubuntu from hoster and start again.

Thanks for your help.

I will mark as solved tomorrow when having restored my gentoo :wink:

Thanks again for fast and competent reply!! Awesome :)
Back to top
View user's profile Send private message
jonathan183
Guru
Guru


Joined: 13 Dec 2011
Posts: 309

PostPosted: Thu Nov 26, 2015 10:35 pm    Post subject: Reply with quote

If you can boot systemrescuecd then you should be able to reinstall/chroot/reconfigure grub etc. Can you not start systemrescuecd from the grub console?

My grub2 menu entry for system rescue looks like this
Code:
menuentry "SYSRESCUECD 64 bit kernel iso image on sda9 " --users "" {
   insmod part_msdos
   insmod ext2
   set root='(hd0,gpt9)'
   search --no-floppy --fs-uuid --set 229f7a75-d77c-4fee-a60b-03d1933a5f46
   set iso=/systemrescuecd-x86-3.8.1.iso
   loopback loop ${iso}
   linux  (loop)/isolinux/rescue64 grml2ram fb1920x1080 keyboard=uk setkmap=uk isoloop=${iso} iommu=soft
   initrd (loop)/isolinux/initram.igz
}
Back to top
View user's profile Send private message
Elleni
l33t
l33t


Joined: 23 May 2006
Posts: 859

PostPosted: Thu Nov 26, 2015 11:27 pm    Post subject: Reply with quote

Hi jonathan183,

Thank you for posting.

Unfortunatelly I have no ext2 module loaded only the btrfs from grub.cfg.

The result is that grub starts with grub_rescue> prompt. And as it can't access any partition because of filesystem unreadable, no insmod is possible from rescue prompt.

I have a similar menuentry as you have, so I was able to boot to sysrescuecd before when system was up and running on btrfs.

As NeddySeagoon said, I should have put insmod ext2 in grub.cfg, then everything would be ok. And as it is a virtual server, I cannot just boot from livecd or similar to chroot into system and correct this. I will have to ask that the initial ubuntu installation is restored.
Back to top
View user's profile Send private message
v_andal
Guru
Guru


Joined: 26 Aug 2008
Posts: 523
Location: Germany

PostPosted: Fri Nov 27, 2015 7:47 am    Post subject: Reply with quote

You should be able to call insmod from grub-rescue prompt. See for example here https://www.linux.com/learn/tutorials/776643-how-to-rescue-a-non-booting-grub-2-on-linux/

Or search yourself for "grub rescue commands".
Back to top
View user's profile Send private message
Elleni
l33t
l33t


Joined: 23 May 2006
Posts: 859

PostPosted: Sat Nov 28, 2015 10:11 am    Post subject: Reply with quote

As I had installed systetm with btrfs and rootfs grub was configured to just load this module to be able to read btrfs partition including /boot folder. Having switched to ext4 for rootfs but not having changed grub.cfg rootfs=ext4 and insmod ext2, I ended up with rescue prompt not beeing able to load anything :)

The hoster provided me a livecd as virtual cd-drive and booting from it, I could correct grub.cfg to insmod ext2 and rootfs=ext4, I also reinstalled grub, Issued a grub2-install /dev/sda followed by grub2-mkconfig -o /boot/grub/grub.cfg and rebuilt initrd with genkernel and doublechecked grub2.cfg.

Now sytem is up and running again. 8)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum