Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
install gentoo on external usb hd
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
queen
Veteran
Veteran


Joined: 19 Jul 2005
Posts: 1626

PostPosted: Mon May 09, 2016 8:34 am    Post subject: install gentoo on external usb hd Reply with quote

I would like to install full gentoo on external usb hd. Is there a new installation guide how to do it? I found only very old guides.

https://wiki.gentoo.org/wiki/Install_Gentoo_on_a_bootable_USB_stick
http://gentoo-en.vfose.ru/wiki/Portable_USB_Gentoo
Back to top
View user's profile Send private message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 7071

PostPosted: Mon May 09, 2016 8:53 am    Post subject: Reply with quote

You don't need any guide, just install it like any gentoo.
Back to top
View user's profile Send private message
C5ace
Apprentice
Apprentice


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

PostPosted: Mon May 09, 2016 11:33 am    Post subject: Re: install gentoo on external usb hd Reply with quote

queen wrote:
I would like to install full gentoo on external usb hd. Is there a new installation guide how to do it? I found only very old guides.

https://wiki.gentoo.org/wiki/Install_Gentoo_on_a_bootable_USB_stick
http://gentoo-en.vfose.ru/wiki/Portable_USB_Gentoo


I made up a "Cut & Paste" script to install Gentoo with Xfce on a USB Disk to run when connected to a HP Laptop. Needs minor modifications to work with your laptop or desktop.

Code:

# These instructions are for installing Gentoo on a USB Disk and are based on
# the Gentoo Handbook.

# My local setup is a LAN with several Linux and Win$ boxes with fixed IP addresses.
# My local domain name: "home.lan"
# My HP_ Drive FQDN: "hp.home.lan"
# IP address: 192.168.0.16
# Nameserver-1: 192.168.0.2 (I have my own name server for the LAN.)
# Nameserver-2: 192.168.0.1 (my Router has a very basic build in Name Server.)
# Route:   192.168.0.1
# Locale Australia/Brisbane

# 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:
# distfiles.gentoo.org/releases/amd64/autobuilds/current-iso/install-amd64-minimal-?????????.iso

## type on Gentoo Installer Screen
fdisk -l
write down your HP Drive's device name (/dev/sd?

ifconfig

# 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.
passwd
abc123
abc123

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

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

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


# Open a terminal on your Host PC or login from another PC by ssh into Gentoo
ssh root@hp.home.lan
abc123

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

fdisk /dev/sdf
o
n
p   
(Enter)
(Enter)
+500M
a

n
e
(Enter)
(Enter)
(Enter)

n
l
(Enter)
+4G
(Enter)
t
(Enter)
82

n
l
(Enter)
+30G

n
l
(Enter)
(Enter)
p
w
# DONE!

partprobe

# ----------------------------------------------
# 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
#-----------------------------------------------

Change /dev/sdf? to your requirements.
# Create the File System:
mkfs.ext4 /dev/sdf1 -L HP_BOOT
mkfs.ext4 /dev/sdf6 -L HP_ROOT # Create the File System:
mkfs.ext4 /dev/sdf8 -L HP_HOME
mkswap /dev/sdf5 -L HP_SWAP
swapon -L HP_SWAP

# Mount the Filesystem:
mount LABEL=HP_ROOT /mnt/gentoo
mkdir /mnt/gentoo/boot
mount LABEL=HP_BOOT /mnt/gentoo/boot
mkdir /mnt/gentoo/home
mount LABEL=HP_HOME /mnt/gentoo/home
cd /mnt/gentoo

# Check the date
date

# Get Gentoo files from the internet
# links http://www.gentoo.org/main/en/mirrors/
# Select and download stage3....tar.bz2
# using Links is slow. Download from your local mirror.

wget http://ftp.swin.edu.au/gentoo/releases/amd64/autobuilds/current-stage3-amd64/stage3-amd64-????????.tar.bz2
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="(HP) $PS1"

# Copy DNS information
# Replace "home.lan" with your domain name
echo "domain home.lan" > /etc/resolv.conf
echo "nameserver 192.168.0.2" >> /etc/resolv.conf
echo "nameserver 192.168.0.1" >> /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 "-j3" to the number of your processor cores plus 1.
echo "MAKEOPTS=\"-j3\"" >> /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\"" >> /etc/portage/make.conf
echo "VIDEO_CARDS=\"intel\"" >> /etc/portage/make.conf
echo "SANE_BACKENDS=\"hp\"" >> /etc/portage/make.conf
echo "USE=\"-kde -gnome -qt -ipv6 -bluetooth gtk samba\"" >> /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 "http://ftp.swin.edu.au/gentoo\" to you mirror
echo "GENTOO_MIRRORS=\"http://ftp.swin.edu.au/gentoo\"" >> /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 "### package.unmask ###" > /etc/portage/package.unmask/unmask
echo "### package.mask ###" > /etc/portage/package.mask/mask
echo "### package.use ###" > /etc/portage/package.use/use

echo "app-portage/install-mask ~amd64" >> /etc/portage/package.keywords/keywords

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 samba 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://rsync1.au.gentoo.org/gentoo-portage" >> /etc/portage/repos.conf/gentoo.conf
echo "auto-sync = yes" >> /etc/portage/repos.conf/gentoo.conf

# Re-sync Portagetree
emerge --sync

# Read IMPORTANT News
eselect news read

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
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
export PS1="(HP) $PS1"
date

emerge --oneshot portage
source /etc/profile
export PS1="(HP) $PS1"

# 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/or modify Kernel Configuration
emerge genkernel
echo "MAKEOPTS=\"-j3\"" >> /etc/genkernel.conf
echo "DISKLABEL=\"yes\"" >> /etc/genkernel.conf
#echo "BOOTLOADER=\"grub\"" >> /etc/genkernel.conf
echo "KNAME=\"genkernel-HP\"" >> /etc/genkernel.conf
genkernel --menuconfig all

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

# Emerge grub and edit its configuration file
emerge grub-static

# Write down the kernel and initramfs full file names and versions
# nano -w /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.4.6" to your kernel version
echo "title HP_INTEL Gentoo Linux 4.4.6-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-HP_INTEL-x86_64-4.4.6-gentoo net.ifnames=0 root=/dev/ram0 real_root=LABEL=HP_ROOT rootdelay=5" >> /boot/grub/grub.conf
echo "initrd /boot/initramfs-genkernel-HP_INTEL-x86_64-4.4.6-gentoo" >> /boot/grub/grub.conf
echo "" >> /boot/grub/grub.conf

# Create /etc/fstab
echo "# <fs>               <mountpoint>    <type>  <opts>          <dump/pass>" > /etc/fstab
echo "LABEL=HP_BOOT       /boot           ext4    noauto,noatime  1 2" >> /etc/fstab
echo "LABEL=HP_ROOT       /               ext4    noatime         0 1" >> /etc/fstab
echo "LABEL=HP_HOME       /home           ext4    noatime         0 2" >> /etc/fstab
echo "LABEL=HP_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 192.168.0.105 to your fixed IP address previously written down
echo 'config_eth0="192.168.0.105 netmask 255.255.255.0 brd 192.168.0.255"' > net
echo 'routes_eth0="default via 192.168.0.1"' >> 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 "127.0.0.1     hp.itw.lan hp  localhost" > /etc/hosts

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

# Configure networking
cd /etc/conf.d
echo 'hostname="hp"' > hostname
hostname hp
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
export PS1="(HP) $PS1"

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

# 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
passwd
password
password

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


Change directory to /
cd /

# Install X
emerge xorg-server
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
export PS1="(HP) $PS1"
# /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
# DISPLAYMANAGER="slim"
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
# ------------------------------------


reboot

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


Edit: added "rootdelay=5"


Last edited by C5ace on Mon May 09, 2016 1:21 pm; edited 1 time in total
Back to top
View user's profile Send private message
DONAHUE
Watchman
Watchman


Joined: 09 Dec 2006
Posts: 7553
Location: Goose Creek SC

PostPosted: Mon May 09, 2016 1:07 pm    Post subject: Reply with quote

you may need to include rootdelay= {some number of seconds} in the kernel boot options to compensate for usb hdd "settle time"
_________________
Defund the FCC.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


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

PostPosted: Mon May 09, 2016 1:14 pm    Post subject: Reply with quote

or rootwait if you want to wait forever.
_________________
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
queen
Veteran
Veteran


Joined: 19 Jul 2005
Posts: 1626

PostPosted: Mon May 09, 2016 9:30 pm    Post subject: Reply with quote

Thanks for all the tips. Indeed it's like a regular gentoo install. The only thing I am not sure about, is the grub setting. real_root=LABEL=HP_ROOT or real_root=/dev/sdb1 (if the external hd is /dev/sdb)?

Also is it important to emerge grub-static instead of grub?
Back to top
View user's profile Send private message
DONAHUE
Watchman
Watchman


Joined: 09 Dec 2006
Posts: 7553
Location: Goose Creek SC

PostPosted: Mon May 09, 2016 9:44 pm    Post subject: Reply with quote

emerge -av grub -- provides grub2
These are the packages that would be merged, in order:
[ebuild N #] sys-boot/grub-2.02_beta3-r1:2/2.02_beta3-r1::gentoo USE="fonts multislot nls sdl themes truetype -debug -device-mapper -doc -efiemu -libzfs -mount -static {-test}" GRUB_PLATFORMS="-coreboot -efi-32 -efi-64 -emu -ieee1275 -loongson -multiboot -pc -qemu -qemu-mips -uboot -xen" 7,623 KiB

emerge -av grub-static -- provides grub legacy improved to handle GPT as well as DOS disks
These are the packages that would be merged, in order:
[ebuild N ] sys-boot/grub-static-0.97-r12::gentoo 0 KiB
_________________
Defund the FCC.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


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

PostPosted: Mon May 09, 2016 10:28 pm    Post subject: Reply with quote

queen,

Use real_root=PARTUUID=...
It takes care of the case where things move around. Also the kernel can deal with PARTUUID.
UUID needs an initrd.
_________________
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
C5ace
Apprentice
Apprentice


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

PostPosted: Mon May 09, 2016 10:46 pm    Post subject: Reply with quote

queen wrote:
Thanks for all the tips. Indeed it's like a regular gentoo install. The only thing I am not sure about, is the grub setting. real_root=LABEL=HP_ROOT or real_root=/dev/sdb1 (if the external hd is /dev/sdb)?

Also is it important to emerge grub-static instead of grub?


Queen:

My USB drive is "/dev/sdf " at the beginning of the installation. After formating the partions you have created will be identified by their labels, such as "HP_ROOT", etc.

The kernel command line "real_root=LABEL=HP_ROOT" is correct. This makes booting independed from whether your USB drive is /dev/sdb or has changed if you boot with another USB drive or stick pluged in or added and harddrive.

I use grub-static because i don't use disk larger the 2GB, EFI or UEFI and grub-static is easy for me to configure the way I want than grub-2.02_"beta"3-r1.

Is your USB drive to be connected to a Desktop or Laptop?
Back to top
View user's profile Send private message
Irre
Guru
Guru


Joined: 09 Nov 2013
Posts: 340
Location: Stockholm

PostPosted: Tue May 10, 2016 6:23 am    Post subject: Reply with quote

I use the very simple LILO (boot loader) for one Linux on USB-stick. :D
Back to top
View user's profile Send private message
queen
Veteran
Veteran


Joined: 19 Jul 2005
Posts: 1626

PostPosted: Tue May 10, 2016 7:39 pm    Post subject: Reply with quote

I use an external 3TB hd. 2 or 3 filesystems ext4, swap and maybe ntfs (haven't decided about the last one yet). This includes backup of my laptop. The HD will be attached to the laptop. I need UEFI enabled in order to boot from external hd.

So, what's better? grub or grub-static?

@NeddySeagoon

The PARTUUID should appear in /etc/fstab without UUID? And during the installation I have to use LABEL=some-name?
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


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

PostPosted: Tue May 10, 2016 8:11 pm    Post subject: Reply with quote

queen,

PARTUUID is for use on the kernel command line. It allows the kernel to find the root filesystem without the userspace mount command being provided by an initrd.
Its only useful if you want to be able to boot without an initrd.

Use UUID or LABEL in fstab. Root is mounted before /etc/fstab can be read, so the mount command is available.

The PARTUUID is a property of the partition. The UUID is a property of a filesystem created on a partition.

grub-static is a prebuilt grub-legacy. It was intended for use on /no-multilib/ profiles, as they cannot build grub-legacy. Its 32 bit only.

There are several options for a boot leader for UEFI and GPT. Avoid grub-static/grub-legacy as it needs the space before the first partition to install properly.
This space is used by the GPT partition table, so grub-static/grub-legacy use a fallback mode. It works but its fragile.
I don't have UEFI hardware, so I don't have any recommendation for a bootloader.
_________________
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
DONAHUE
Watchman
Watchman


Joined: 09 Dec 2006
Posts: 7553
Location: Goose Creek SC

PostPosted: Tue May 10, 2016 11:52 pm    Post subject: Reply with quote

I was doing a new install last week-gpt,uefi on a samsung 950 pro ssd. Googled "gpt fstab partuuid uuid" to refresh my aging memory. Found https://wiki.archlinux.org/index.php/fstab . Progress has been made. /etc/fstab can now use PARTUUID= or PARTLABEL= or UUID= or LABEL= for GPT labeled disks I tried it. It works.

My favorite bootloader for UEFI with a GPT labeled disk is EFI stub kernel. https://wiki.gentoo.org/wiki/EFI_stub_kernel
My favorite boot manager for UEFI with a GPT labeled disk is rEFInd.. https://wiki.gentoo.org/wiki/Refind
_________________
Defund the FCC.
Back to top
View user's profile Send private message
queen
Veteran
Veteran


Joined: 19 Jul 2005
Posts: 1626

PostPosted: Wed May 11, 2016 10:33 am    Post subject: Reply with quote

Thanks for the explanations. Now it's much more clear, which options to use.

@DONAHUE

I also stumbled upon the archlinux link about fstab and PARTUUID. This is what I wasn't sure about.
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