Skip to content

Standard Gentoo full update procedure (packages / kernel / gcc etc)

NB : SSH in and then screen - so can detattch / handle connection drops !!

screen detach with crtl+a [ctrl+]d re-attach with screen -r NB : if more than one screen session list with screen -ls then use screen -r {screen id} https://linuxize.com/post/how-to-use-linux-screen/ if you lost connection and screen shows as already attached force detach too with : screen -d -r

check we are up to date with existing local copy of repo

[ flags : update pretend verbose Deep NewUse ]

if not this was not completed last time - and we shoud skip over emerge --sync below, do everything,then start again from

emerge --sync emerge -upvDN world

read news before

sync eselect news list

bring the local repo up to date

emerge --sync

read news after sync eselect news list

review what is to be done

[ flags : update pretend verbose Deep NewUse ]

emerge -upvDN world

NB - IF ABOVE FAILS AS PERL UPDATE IS TOO MESSY !! TRY BELOW

( also further notes about perl update below - messy or not )

emerge -upvDN --with-bdeps=y --backtrack=100 --autounmask-keep-masks=y @world

fetch all packages first flags : update fetch verbose Deep NewUse

NB : this will warn you / fail if you need to manually get a java update from oracle and copy to /usr/portage/distfiles/

emerge -ufvDN world

OR

emerge -ufvDN --with-bdeps=y --backtrack=100 --autounmask-keep-masks=y @world

[ flags : update ask verbose Deep NewUse ]

NB : worth running

tail -f /var/log/portage/elog/summary.log in a second console to see messages coming back from each package - in case requires follow up action

PS : This will take a while - especially if there are new builds of php | mysql | apache

emerge -uavDN world

OR

emerge -uavDN --with-bdeps=y --backtrack=100 --autounmask-keep-masks=y @world

deal with any config changes etc-update

deal with any rebuilds require revdep-rebuild -v -- -av OR NEWER

emerge -av @preserved-rebuild

clear out old deps emerge -av --depclean

>>> PERL

if perl was updated it should force rebuilds of packages however you should run perl cleaner to make sure all is well

perl-cleaner --all

>>> python

If Python was updated update python_target in /etc/portage/make.conf ( and re-emerge if this has changed use flags - best done in advance ? )

eselect python list

eselect python set 2 (or whichever you want eselect python)

cleanup / remove old versions from the list

>>> GCC if gcc was updated it is

compiled - but not yet the active copy - follow below to complete the update - but not enabled yet ... [ NB -> 8.3 ]

list available ( shoudl be just current[1], and new [2] )

e.g. [1] x86_64-pc-linux-gnu-7.3.0 // [2] x86_64-pc-linux-gnu-8.3.0

gcc-config -l

switch to new ( presuming it was [1] above )

gcc-config 2

update your current shell (and any other shells you have open on this machine)

. /etc/profile

re-emerge libtool for the new gcc version

emerge -av1 sys-devel/libtool

check new version is active

gcc --version

uninstall old version

( NB : version number based on example above - however is actually r3 : use emerge -Cp gcc to see installed versions THE "p" IS VERY IMPORTANT ! )

(JW NB Safer option to check installed versions is equery list gcc to save us from any human error in missing the "p")

emerge --ask --depclean =sys-devel/gcc-7.3.0-r3

deal with any rebuilds required

revdep-rebuild -v -- -av

>>> GRUB

If updating both grub and kernel (gentoo-sources) do both before reboot

if grub2 was updated see https://wiki.gentoo.org/wiki/GRUB2

grub-install /dev/sda1

grub-mkconfig -o /boot/grub/grub.cfg

NB : For uefi

grub-install --efi-directory=/boot

grub-mkconfig -o /boot/grub/grub.cfg

reboot - see first note for GRUB reboot

>>> KERNEL

If updating both grub and kernel (gentoo-sources) do both before reboot

if kernel (gentoo-sources) was updated - do below to build / switch to new kernel

go to root dir for kernel source

cd /usr/src

check current version by running

ll

if unsure E.G. output

```/usr/src # ll total 16 drwxr-xr-x 4 root root 4096 May 14 11:19 . drwxr-xr-x 13 root root 4096 Oct 18 2017 .. -rw-r--r-- 1 root root 0 Oct 12 2017 .keep lrwxrwxrwx 1 root root 20 Dec 17 17:42 linux -> linux-4.14.83-gentoo drwxr-xr-x 26 root root 4096 Dec 17 17:57 linux-4.14.83-gentoo drwxr-xr-x 26 root root 4096 May 14 11:19 linux-4.19.37-gentoo


### WE ARE UPGRADING FROM 4.14.83 to 4.19.37 in this case

### copy config from existing configured kernel src dir to new src dir
`cp linux/.config linux-4.19.37-gentoo/`

### switch the linux sym link to new src dir
`rm linux && ln -s linux-4.19.37-gentoo linux`

### change working directory to to new kernel directory
`cd /usr/src/linux`

### update config file with new options being set to their default values
`make olddefconfig`

### build the new kernel, install any modules, install new kernel (copy to /boot)
`make && make modules_install && make install`

### if using genkernel initramfs is required
`genkernel --install --kernel-config=/usr/src/linux/.config initramfs`

### check what was copied to boot
should have config, system map, and kernel for new version
sym link for current should be pointing to new version 
sym link for old should be pointing at previous version 
`ll /boot`

### update grub to use the new kernel
`grub-mkconfig -o /boot/grub/grub.cfg`

### confirm current running version
`uname -a`

### reboot and check new version loaded fine - see first note for KERNEL
`reboot`

### ..... WAIT AND LOG IN AGAIN .....
`uname -a`

### finally remove packages no longer needed
NB : this will take out old kernel sources - if you want to keep them add a row specifying the
version in /var/lib/portage/world
`emerge -av --depclean`

### =================\>\>\>\> PANIC : HELP \<\<\<\<=================
If it goes tits up - here are some useful things ...

boot in live disk and chroot

### boot live disk

### enable swap 
`swapon /dev/sda3`

### create a mount for chrooting (probably already exists on live disk )
`mkdir /mnt/gentoo`

### mount root disk
`mount /dev/sda4 /mnt/gentoo`

### mount system filesystems

mount --types proc /proc /mnt/gentoo/proc mount --rbind /sys /mnt/gentoo/sys mount --make-rslave /mnt/gentoo/sys mount --rbind /dev /mnt/gentoo/dev mount --make-rslave /mnt/gentoo/dev ```

chroot

chroot /mnt/gentoo /bin/bash

update profile (and update prompt)

source /etc/profile export PS1="(chroot) \${PS1}"

mount boot

mount /dev/sda2 /boot

fix stuff as required ( check grub update above !!)

unmount boot

umount /boot

exit

chroot exit

umount system fs

umount /mnt/gentoo/dev umount /mnt/gentoo/sys umount /mnt/gentoo/proc