Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Installing Gentoo from another distro with 4 disk btrfs /?
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
davidm
Guru
Guru


Joined: 26 Apr 2009
Posts: 557
Location: US

PostPosted: Sat Dec 20, 2014 3:02 am    Post subject: Installing Gentoo from another distro with 4 disk btrfs /? Reply with quote

[SOLVED] (No room to add tag to subject)

I'm considering migrating my main install from another Linux distro to Gentoo. The problem is it is a four disk raid1 btrfs filesystem (all on /) and I don't really have an external disk to do a full backup and then restore from. So I want to just go ahead and install over my existing install using the same existing btrfs /.

I'm thinking I should be able to just create a special directory on my existing / partition. Transfer anything I want to keep there. Then reboot with the Gentoo minimal or Gentoo Rescue CD, chroot, wipe out all other subdirectories besides the special directory I created with my files I want to save...and then finally proceed as normal with the instructions in the handbook.

Does anyone see any gotchas with this plan? The data isn't critical so if it gets lost, no one dies. Best effort is fine. :) I'm just worried about some crazy problem with the minimal or Rescue CD recognizing my existing btrfs filesystem or the Gentoo install process somehow wiping out the files in the special directory, etc. IOW something I may not be considering in my ignorance.


Last edited by davidm on Fri Dec 26, 2014 6:49 pm; edited 1 time in total
Back to top
View user's profile Send private message
BlueFusion
Guru
Guru


Joined: 08 Mar 2006
Posts: 371

PostPosted: Sat Dec 20, 2014 3:00 pm    Post subject: Reply with quote

This is going to be super simple!

On your btrfs root (say /mnt/bpool, which is true in my case).....
Code:
btrfs subvolume create @gentoo /mnt/bpool


Now go ahead and mount it....

Code:
mkdir /mnt/gentoo
mount -o subvol=@gentoo /dev/sda /mnt/gentoo


Start installing there :)

When going to boot into Gentoo, your kernel command line should reflect the mount option of subvol=@gentoo and you're all set.

Once all installed, you can move files around at you leisure and delete old sub volumes if you wish.

No need for a LiveCD. Btrfs is awesome!
_________________
i7-940 2.93Ghz | ASUS P6T Deluxe (v.1) | 24GB Triple Channel RAM | nVidia GTX660
4x 4TB Seagate NAS HDD (Btrfs raid5) | 2x 120GB Samsung 850 EVO SSD (Btrfs raid1)
Back to top
View user's profile Send private message
davidm
Guru
Guru


Joined: 26 Apr 2009
Posts: 557
Location: US

PostPosted: Sat Dec 20, 2014 10:34 pm    Post subject: Reply with quote

@BlueFusion

Thank you! I had not considered that. It looks like it might even be possible to keep the existing distro on there in order to transition into it too. I'm using Grub (or "grub2") so I'm thinking I could just put in an entry to boot into the Gentoo subvolume. That would probably be a good idea as it's my production system and from experience I know it takes a couple days to a week to get Gentoo "just right".
Back to top
View user's profile Send private message
BlueFusion
Guru
Guru


Joined: 08 Mar 2006
Posts: 371

PostPosted: Sun Dec 21, 2014 1:14 am    Post subject: Reply with quote

Yes there's no reason to wipe your old distro off if you don't want to. Additionally, its ideal to use sub volumes instead of having any data in the btrfs root volume. In my experience, it makes everything much easier to keep things organized and take snapshots.

Good luck!
_________________
i7-940 2.93Ghz | ASUS P6T Deluxe (v.1) | 24GB Triple Channel RAM | nVidia GTX660
4x 4TB Seagate NAS HDD (Btrfs raid5) | 2x 120GB Samsung 850 EVO SSD (Btrfs raid1)
Back to top
View user's profile Send private message
davidm
Guru
Guru


Joined: 26 Apr 2009
Posts: 557
Location: US

PostPosted: Sun Dec 21, 2014 9:16 am    Post subject: Reply with quote

I believe I'm mostly there. :)

The questionable part right now is that I am going to try to do this on a multi-device btrfs system without initrd. For now I just want to add on a menu entry on my existing grub install on Arch to boot into the Gentoo sub volume. (over time I will transfer my files over to gentoo and transition to it)

I have one subvolume (called 'gentoo') and the default root install which contains Arch currently.

I have four disks /dev/sd[a-d] as part of a multi-device raid1 btrfs volume

My /etc/fstab (on the Gentoo install/subvolume) :

(The output below is really one line but seems to get wrapped on the forum)

Code:

/dev/sda        /       btrfs   device=/dev/sda,device=/dev/sdb,device=/dev/sdc,device=/dev/sdd,rw,autodefrag,compress=lzo,noatime,thread_pool=12,subvol=gentoo       0       0


I see mixed messages about this being possible without initrd or such. If it isn't I will begrudgingly use it. But from what I gather what I need to do now is find a way to get grub (within my other Arch install on the default subvolume) to add an entry for the "subvol=gentoo' with the Gentoo install on it.

The Arch Wiki has this:

https://wiki.archlinux.org/index.php/Btrfs_-_Tips_and_tricks#Booting_into_snapshots

So I believe I need something like:

Code:

menuentry "Gentoo Linux" {
  linux /boot/vmlinuz-3.17.7-gentoo root=/dev/sda rootflags==device=/dev/sda,device=/dev/sdb,device=/dev/sdc,device=/dev/sdd,subvol=root rootfstype=btrfs


And then I need to re-run grub and write it. Is this on the right track or perhaps is this even possible without an initrd? Not having the initramfs seems to complicate things and is confusing me a bit...

Apologies if this is a bit disjointed. It's 4:30am local time. ;)
Back to top
View user's profile Send private message
BlueFusion
Guru
Guru


Joined: 08 Mar 2006
Posts: 371

PostPosted: Sun Dec 21, 2014 3:58 pm    Post subject: Reply with quote

I've always used an initramfs so I don't know for sure but I don't see why it wouldn't work with btrfs filesystem support built into the kernel.

The line you have looks similar to mine listing all of the devices and sub volume. Mines even more complicated because I have a dm-crypt layer too.
_________________
i7-940 2.93Ghz | ASUS P6T Deluxe (v.1) | 24GB Triple Channel RAM | nVidia GTX660
4x 4TB Seagate NAS HDD (Btrfs raid5) | 2x 120GB Samsung 850 EVO SSD (Btrfs raid1)
Back to top
View user's profile Send private message
davidm
Guru
Guru


Joined: 26 Apr 2009
Posts: 557
Location: US

PostPosted: Sun Dec 21, 2014 5:56 pm    Post subject: Reply with quote

Success!

I ended up just using an initrd file as I couldn't find anyone having success otherwise.

Here's my '/etc/grub.d/40_custom' file which I used from the Arch install (which exists on the default subvolume) :

Code:

menuentry "Gentoo Linux on gentoo subvolume" {
  linux /gentoo/boot/vmlinuz-3.17.7-gentoo root=/dev/sda rootflags=subvol=gentoo
  initrd /gentoo/boot/initramfs-genkernel-x86_64-3.17.7-gentoo
}


For anyone else having to do it I also used 'genkernel-next' with the --btrfs option to generate the initramfs. Also I called my Gentoo subvolume 'gentoo'. Notice that '/gentoo/' thus prepends the location of the kernel and initramfs file. Without doing that it was never found by grub as the gentoo subvolume is not currently my default (or root/topmost) subvolume in the btrfs volume.

This was actually a lot of fun to figure out. I don't remember manually configuring the kernel with "make menuconfig" being this easy a couple years ago when I last did it. It's probably just a matter of time until I set the Gentoo subvolume as the default and transition away from Arch. It's a lot of fun and I feel I am learning things. :)
Back to top
View user's profile Send private message
BlueFusion
Guru
Guru


Joined: 08 Mar 2006
Posts: 371

PostPosted: Mon Dec 22, 2014 2:46 am    Post subject: Reply with quote

I suggest making a separate /boot sub volume for Grub that way all your kernels and initrds can reside there and the /gentoo/ thing would not be required.
_________________
i7-940 2.93Ghz | ASUS P6T Deluxe (v.1) | 24GB Triple Channel RAM | nVidia GTX660
4x 4TB Seagate NAS HDD (Btrfs raid5) | 2x 120GB Samsung 850 EVO SSD (Btrfs raid1)
Back to top
View user's profile Send private message
davidm
Guru
Guru


Joined: 26 Apr 2009
Posts: 557
Location: US

PostPosted: Tue Dec 23, 2014 1:11 am    Post subject: Reply with quote

BlueFusion wrote:
I suggest making a separate /boot sub volume for Grub that way all your kernels and initrds can reside there and the /gentoo/ thing would not be required.


Thanks for the suggestion. I'm actually in the process of moving all my files from the old root subvolume to the new 'gentoo' subvolume. Then I will probably set the 'gentoo' subvolume as the new default. I believe that will remove the requirement to specify it in that way but I suppose we'll see.
Back to top
View user's profile Send private message
davidm
Guru
Guru


Joined: 26 Apr 2009
Posts: 557
Location: US

PostPosted: Fri Dec 26, 2014 6:48 pm    Post subject: Reply with quote

Also for anyone searching who runs into this situation where they set up gentoo on a seperate subvolume branching from the root (where there was another install from a different distro) I have also verified that grub2 seems to be pretty smart about how it handles the btrfs subvolumes.

But first just to be clear this is what I had:

(default id=5 subvolume which exists by default on all btrfs volumes)
|
-------'gentoo' subvolume (with new Gentoo install)

I then simply followed http://wiki.gentoo.org/wiki/GRUB2 as normal:

1. 'grub2-install /dev/sda' (this is where my BIOS looks to boot the first disk)
2. 'grub2-mkconfig -o /boot/grub/grub.cfg'

The output from the last command didn't seem to be aware of the subvolume and it had me scared that it wouldn't work but in fact it seems to work great. I did not have to change the default subvolume at all. I simply left it as is and it worked automatically detecting the available kernels and the initramfs image. Anyway I'm 100% on Gentoo now. :)
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