Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
migrate gentoo to another comp
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

Joined: 04 Aug 2016
Posts: 29

PostPosted: Wed Sep 27, 2017 7:43 am    Post subject: migrate gentoo to another comp Reply with quote

I have gentoo installed on laptop.

I'd like to install gentoo on virtualbox for tests, but I want to have the same emerged software like I have on my laptop.
Is it possible do it automatically ?


what is the faster way to install gentoo on virtualbox ?
Back to top
View user's profile Send private message

Joined: 08 Mar 2003
Posts: 24323
Location: here

PostPosted: Wed Sep 27, 2017 7:55 am    Post subject: Re: migrate gentoo to another comp Reply with quote

ttre wrote:
what is the faster way to install gentoo on virtualbox ?
Questions are guaranteed in life; Answers aren't.
Back to top
View user's profile Send private message

Joined: 23 Dec 2013
Posts: 350
Location: Brisbane, Australia

PostPosted: Wed Sep 27, 2017 2:52 pm    Post subject: Reply with quote

My "Copy & Paste" installation script for installing Gentoo and Xfce on a VirtualBox VM.
The Gentoo host must have app-emulation/virtualbox-5.1.26, app-emulation/virtualbox-additions-5.1.26, app-emulation/virtualbox-extpack-oracle-5.1.26, app-emulation/virtualbox-modules-5.1.26 installed and working.

# These instructions are for installing Gentoo on Oracle VirtualBox with
# Oracle VirtualBox Extentions installed on the host PC and are based on
# the Gentoo Handbook.
# I allocate 1GB during intallation and change to 512KB after competing the installation.
# I can still work with 255 KB but slow.

# My local setup is a LAN with several Linux and Win$ boxes with fixed IP addresses.
# My local domain name: "itw.lan"
# My Gentoo VM FQDN: "gentoo.itw.lan"
# IP address:
# Nameserver-1: (I have my own name server for the LAN.)
# Nameserver-2: (my Router has a very basic build in Name Server.)
# Route:
# Locale Australia/Brisbane
# Configure your host clock to UTC time.

# Change these at the approbriate places in below text to match yours.

# The text without "#" in front are commands to be entered or copied into
# the terminal followed by hitting the Enter Key.

# Preparation:
# Download Gentoo Install CD from:

# Alternetuvely download and use Rescue CD as installation CD.

# Configure a Gentoo x86_64 virtual maschine to boot with Gentoo CD.iso as CD Drive,
# a virtual 30GB dard drive and Network Adapter as "Bridged Adapter".

# Boot your new virtual maschine from the Gentoo install CD.

## type on Gentoo Installer Screen


# Write down the IP address and name of your ethernet card like "eth0", "enp0s3"
# or whatever is your's.

net-setup eth0  #For manual setup if your Router does not have a DHCP server.

# Create a password for ssh access.

# Start sshd and ping
/etc/init.d/sshd start
ping -c 3

# This completes configuration of the installation system for ssh access from a second PC.

# --------------------------------------------

# Open a terminal on your second linux PC or Linux Host PC and log by ssh into
# your Gentoo VM. The Host PC Hardware Clock (BIOS) must be set to UTC. If you use
# Windows as Host OS, configure Windows that Windows does not reset the Hardware Clock
# during startup.
ssh root@gentoo.itw.lan

# Manally, step by step partition your Hard drive with these keybord commands:
# If you make a mistake, exit fdisk by 'q' and start again.

fdisk /dev/sda





# ----------------------------------------------
# Now proceed by copying below texts to your terminal followed by Enter.
# You can copy line by line, section by section or several saections at a time
# or all sections from here until
# ----------------------------------------
# End of installation
# ----------------------------------------

# Create the File System:
mkfs.ext4 /dev/sda1 -L VB_BOOT
mkfs.ext4 /dev/sda6 -L VB_ROOT
mkfs.ext4 /dev/sda7 -L VB_HOME
mkswap /dev/sda5 -L VB_SWAP
swapon -L VB_SWAP

# Mount the Filesystem:
mount -L VB_ROOT /mnt/gentoo
mkdir /mnt/gentoo/boot
mount -L VB_BOOT /mnt/gentoo/boot
mkdir /mnt/gentoo/home
mount -L VB_HOME /mnt/gentoo/home
cd /mnt/gentoo

# Check the date. Make sure date and time are UTC.

# Get Gentoo files from the internet
# links
# Select and download stage3....tar.bz2
# using Links is slow. Download from your local mirror.

ls -l

tar xvjpf stage3-*.tar.bz2

# Change Root
mount -t proc none /mnt/gentoo/proc
mount --rbind /sys /mnt/gentoo/sys
mount --rbind /dev /mnt/gentoo/dev
chroot /mnt/gentoo /bin/bash
source /etc/profile
export PS1="gentoo.itw.lan $PS1"

# Copy DNS information
# Replace "itw.lan" with your domain name.
echo "domain itw.lan" > /etc/resolv.conf

# Change nameserver IP's to yours.
echo "nameserver" >> /etc/resolv.conf
echo "nameserver" >> /etc/resolv.conf

# Configure compile options in make.conf:
echo "CFLAGS=\"-O2 -march=native -pipe\"" > /etc/portage/make.conf
echo "CXXFLAGS=\"\${CFLAGS}\"" >> /etc/portage/make.conf

# Change "-j2" to the number of your processor cores plus 1.
echo "MAKEOPTS=\"-j2\"" >> /etc/portage/make.conf

echo "FEATURES=\"-preserve-libs\"" >> /etc/portage/make.conf
echo "CHOST=\"x86_64-pc-linux-gnu\"" >> /etc/portage/make.conf
echo "ACCEPT_KEYWORDS=\"amd64\"" >> /etc/portage/make.conf
echo "ACCEPT_LICENSE=\"*\"" >> /etc/portage/make.conf
echo "LINGUAS=\"en\"" >> /etc/portage/make.conf
echo "INPUT_DEVISES=\"evdev virtualbox\"" >> /etc/portage/make.conf
echo "VIDEO_CARDS=\"vboxvideo\"" >> /etc/portage/make.conf
echo "USE=\"-bindist -kde -gnome -qt gtk\"" >> /etc/portage/make.conf
echo "PORTDIR=\"/usr/portage\"" >> /etc/portage/make.conf
echo "DISTDIR=\"\${PORTDIR}/distfiles\"" >> /etc/portage/make.conf
echo "PKGDIR=\"\${PORTDIR}/packages\"" >> /etc/portage/make.conf
echo "XFCE_PLUGINS=\"brightness clock trash\"" >> /etc/portage/make.conf

# change "\" to you Gentoo mirror
echo "GENTOO_MIRRORS=\"\"" >> /etc/portage/make.conf

# Create package.* files
mkdir /etc/portage/package.keywords
mkdir /etc/portage/package.unmask
mkdir /etc/portage/package.mask
mkdir /etc/portage/package.use
mkdir /etc/portage/repos.conf

echo "### package.keywords ###" > /etc/portage/package.keywords/keywords
echo "app-portage/install-mask ~amd64" >> /etc/portage/package.keywords/keywords
echo "app-portage/diffmask ~amd64" >> /etc/portage/package.keywords/keywords
echo "x11-drivers/xf86-video-virtualbox ~amd64" > /etc/portage/package.keywords/x11
echo "xfce-extra/xfce4-weather-plugin ~amd64" >> /etc/portage/package.keywords/xfce
echo "=xfce-extra/xfce4-alsa-plugin-0.1.1 ~amd64" >> /etc/portage/package.keywords/xfce
echo "x11-drivers/xf86-video-virtualbox ~amd64" >> /etc/portage/package.keywords/xfce

echo "### package.mask ###" > /etc/portage/package.mask/mask
echo "sys-apps/systemd" >> /etc/portage/package.mask/mask
echo "www-client/links" > /etc/portage/package.mask/mc
echo ">app-misc/mc-4.8.15" > /etc/portage/package.mask/mc
echo "xfce4-terminal" > /etc/portage/package.mask/xfce

echo "### package.unmask ###" > /etc/portage/package.unmask/unmask

echo "### package.use ###" > /etc/portage/package.use/use
echo "dev-util/cmake -qt4" >> /etc/portage/package.use/use
echo "app-text/poppler -qt4" >> /etc/portage/package.use/use
echo "gnome-base/gvfs -http" >> /etc/portage/package.use/use
echo "sys-process/cronie -anacron" >> /etc/portage/package.use/use
echo ""
echo "x11-base/xorg-server udev" >> /etc/portage/package.use/use
# echo "net-print/hplip scanner doc hpcups hpijs" >> /etc/portage/package.use/use
echo "xfce-base/thunar gvfs xfce_plugins_trash" >> /etc/portage/package.use/use

# Create repos.conf
echo "[DEFAULT]" > /etc/portage/repos.conf/gentoo.conf
echo "" >> /etc/portage/repos.conf/gentoo.conf
echo "main-repo = gentoo" >> /etc/portage/repos.conf/gentoo.conf
echo "" >> /etc/portage/repos.conf/gentoo.conf
echo "[gentoo]" >> /etc/portage/repos.conf/gentoo.conf
echo "location = /usr/portage" >> /etc/portage/repos.conf/gentoo.conf
echo "sync-type = rsync" >> /etc/portage/repos.conf/gentoo.conf
echo "sync-uri = rsync://" >> /etc/portage/repos.conf/gentoo.conf
echo "auto-sync = yes" >> /etc/portage/repos.conf/gentoo.conf

# Sync Portagetree
emerge --sync

eselect news read

emerge --oneshot portage
source /etc/profile
export PS1="gentoo.itw.lan $PS1"

emerge app-portage/cpuinfo2cpuflags
cpuinfo2cpuflags-x86 >> /etc/portage/make.conf

# Select Timezone. (change to yours)
ls /usr/share/zoneinfo
echo "Australia/Brisbane" > /etc/timezone
emerge --config sys-libs/timezone-data

# Specify your locale. (change to yours)
echo "en_AU ISO-8859-1" >> /etc/locale.gen
echo "en_AU.UTF-8 UTF-8" >> /etc/locale.gen
echo "LANG=\"en_AU.UTF-8\"" > /etc/env.d/02locale
echo "LC_COLLATE=\"C\"" >> /etc/env.d/02locale
env-update && source /etc/profile

# Select Profile. We list and use Desktop (3)
eselect profile list

# for Xfce Desktop
eselect profile set 3

# Install Kernel Sources
emerge gentoo-sources
ls -l /usr/src/linux

# Use General Kernel and modify genkernel configuration.
emerge genkernel
echo "MAKEOPTS=\"-j2\"" >> /etc/genkernel.conf
echo "DISKLABEL=\"yes\"" >> /etc/genkernel.conf
#echo "CLEAN=\"no\"" >> /etc/genkernel.conf
#echo "MRPROPER=\"no\"" >> /etc/genkernel.conf
genkernel all

# Verify Kernel installation
ls /boot/kernel* /boot/initramfs*

# Emerge grub-static.
emerge grub-static

# Create /boot/grub/grub.conf
echo "default 0" > /boot/grub/grub.conf
echo "timeout 10" >> /boot/grub/grub.conf
echo "" >> /boot/grub/grub.conf

# Change "4.12.12" to your kernel version
echo "title Gentoo Linux 4.12.12-gentoo" >> /boot/grub/grub.conf
echo "root (hd0,0)" >> /boot/grub/grub.conf

# Change the kernel and initramfs filenames to your full name and versions
echo "kernel /boot/kernel-genkernel-x86_64-4.12.12-gentoo net.ifnames=0 root=/dev/ram0 real_root=LABEL=VB_ROOT" >> /boot/grub/grub.conf
echo "initrd /boot/initramfs-genkernel-x86_64-4.12.12-gentoo" >> /boot/grub/grub.conf
echo "" >> /boot/grub/grub.conf

# Create /etc/fstab
# nano -w /etc/fstab
echo "# <fs>          <mountpoint>    <type>  <opts>          <dump/pass>" > /etc/fstab
echo "LABEL=VB_BOOT   /boot           ext4    noatime         1 2" >> /etc/fstab
echo "LABEL=VB_ROOT   /               ext4    noatime         0 1" >> /etc/fstab
echo "LABEL=VB_HOME   /home           ext4    noatime         0 2" >> /etc/fstab
echo "LABEL=VB_SWAP   none            swap    sw              0 0" >> /etc/fstab
echo "/dev/cdrom      /mnt/cdrom      auto    noauto,ro       0 0" >> /etc/fstab
echo "# /dev/fd0        /mnt/floppy     auto    noauto          0 0" >> /etc/fstab

cd /etc/conf.d
# Change to your fixed IP address previously written down
echo 'config_eth0=" netmask brd"' > net
echo 'routes_eth0="default via"' >> net

# Adding net.eth0 to the default runlevel
cd /etc/init.d
ln -s net.lo net.eth0
rc-update add net.eth0 default

# Filling in the networking information
cd /etc
echo "     gentoo.itw.lan gentoo  localhost" > /etc/hosts

# Change to your fixed IP address previously written down
echo "  gentoo.itw.lan gentoo" >> /etc/hosts

# Configure networking
cd /etc/conf.d
echo 'hostname="gentoo"' > hostname
hostname gentoo
hostname -f

# Install a syslogger, a cron daemon, mc and sshd
emerge app-admin/syslog-ng
rc-update add syslog-ng default
emerge sys-process/cronie
rc-update add cronie default
rc-update add sshd default
env-update && source /etc/profile

emerge sys-apps/mlocate
emerge app-portage/gentoolkit
emerge app-admin/eclean-kernel
emerge app-portage/diffmask
emerge app-portage/flaggie
emerge app-portage/install-mask
emerge app-portage/portpeek
emerge app-portage/smart-live-rebuild
emerge app-misc/mc
eselect fontconfig enable 22

# Adding sshd to the default runlevel
rc-update add sshd default

# Option:
echo "PermitRootLogin yes" >> /etc/ssh/sshd_config

# Add your username. Change "user" to your username.
useradd -m -G users,wheel,audio,cdrom,portage,usb -s /bin/bash (username)
passwd (username)

# Setting the root password

# Install grub-static (grub leagacy)
grub --no-floppy
# grub> root (hd0,0)
# grub> setup (hd0)
# grub> quit

Change directory to /.
cd /

# Install X
emerge xorg-server
emerge x11-drivers/xf86-video-virtualbox
emerge app-emulation/virtualbox-guest-additions
rc-update add xdm default
env-update && source /etc/profile
echo XSESSION="Xfce4" > /etc/env.d/90xsession

# Install Xfce
emerge xfce-base/xfce4-meta
emerge x11-terms/xfce4-terminal
emerge app-editor/leafpad
emerge app-portage/porthole
env-update && source /etc/profile
/etc/init.d/dbus start
rc-update add dbus default
rc-update add xdm default

emerge x11-misc/slim

# Editing /etc/conf.d/xdm
# nano -wc /etc/conf.d/xdm
echo "CHECKVT=7" > /etc/conf.d/xdm
echo "DISPLAYMANAGER=\"slim\"" >> /etc/conf.d/xdm
rc-update add xdm default

eselect fontconfig enable 1 2 4 5 6 7 8 9 10 11 12 13 14 24 25 26

# End of Xfce installation
# ------------------------------------

# Poweroff
umount -l /mnt/gentoo/dev{/shm,/pts,}
umount -l /mnt/gentoo{/proc,/boot,/home,/sys,}

# ----------------------------------------
# End of installation
# ----------------------------------------

# Remove the Gentoo CD

# This completes the installation of the Gentoo System.
# Boot your Gentoo VM, log in with your username, open Xfce-terminal, ping
# to verify that it works.
# Then login as root from your Gentoo VM terminal.

# if all is well, you should now see the Slim login screen
# Login as root
# emerge your favorite Xfce and other applications such as:
# porthole
# leafpad
# midori or firefox
# claws mail or thunderbird
# avoid Gnome and KDE applications. They pull in tons of dependencies
# Happy computing!

Total keyboard time is about 15 minutes.
Back to top
View user's profile Send private message

Joined: 02 Jan 2009
Posts: 2253
Location: $TERM

PostPosted: Fri Sep 29, 2017 10:36 am    Post subject: Reply with quote

In case you got CFLAGS incompatibility in the new host, you need to first build all the packages with generic CFLAGS (-mtune=native -O3 etc...).
My blog
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