lördag 5 oktober 2013

Howto: Install systemd in gentoo linux

This is how i installed Systemd in gentoo linux.

http://www.freedesktop.org/wiki/Software/systemd/
http://wiki.gentoo.org/wiki/Systemd
https://wiki.archlinux.org/index.php/Systemd
https://dornea.nu/blog/2013/08/gentoo-systemd-consolekit-udev-and-some-failed-system-update
https://wiki.archlinux.org/index.php/Improve_Boot_Performance


Most up to date Systemd  REQUIREMENTS:
http://cgit.freedesktop.org/systemd/systemd/tree/README#n36

REQUIREMENTS:
        Linux kernel >= 3.0
          CONFIG_DEVTMPFS
          CONFIG_CGROUPS (it's OK to disable all controllers)
          CONFIG_INOTIFY_USER
          CONFIG_SIGNALFD
          CONFIG_TIMERFD
          CONFIG_EPOLL
          CONFIG_NET
          CONFIG_SYSFS

        Linux kernel >= 3.8 for Smack support

        Udev will fail to work with the legacy layout:
          CONFIG_SYSFS_DEPRECATED=n

        Legacy hotplug slows down the system and confuses udev:
          CONFIG_UEVENT_HELPER_PATH=""

        Userspace firmware loading is deprecated, will go away, and
        sometimes causes problems:
          CONFIG_FW_LOADER_USER_HELPER=n

        Some udev rules and virtualization detection relies on it:
          CONFIG_DMIID

        Mount and bind mount handling might require it:
          CONFIG_FHANDLE

        Support for some SCSI devices serial number retrieval, to
        create additional symlinks in /dev/disk/ and /dev/tape:
          CONFIG_BLK_DEV_BSG

        Optional but strongly recommended:
          CONFIG_IPV6
          CONFIG_AUTOFS4_FS
          CONFIG_TMPFS_POSIX_ACL
          CONFIG_TMPFS_XATTR
          CONFIG_SECCOMP

        For systemd-bootchart a kernel with procfs support and several
        proc output options enabled is required:
          CONFIG_PROC_FS
          CONFIG_SCHEDSTATS
          CONFIG_SCHED_DEBUG

        For UEFI systems:
          CONFIG_EFI_VARS
          CONFIG_EFI_PARTITION

        Note that kernel auditing is broken when used with systemd's
        container code. When using systemd in conjunction with
        containers please make sure to either turn off auditing at
        runtime using the kernel command line option "audit=0", or
        turn it off at kernel compile time using:
          CONFIG_AUDIT=n

Create  /etc/portage/profile/use.force with -consolekit.
$ cat /etc/portage/profile/use.force
-consolekit

Create /etc/portage/profile/use.mask with consolekit and -systemd.
$ cat /etc/portage/profile/use.mask
consolekit
-systemd

Add to package.use.
$ cat /etc/portage/package.use
sys-fs/udisks systemd
sys-auth/polkit systemd
sys-auth/pambase systemd

When you install systemd you must have desktop profile set.

# eselect profile list
Available profile symlink targets:
  [1]   default/linux/amd64/13.0
  [2]   default/linux/amd64/13.0/selinux
  [3]   default/linux/amd64/13.0/desktop *
  [4]   default/linux/amd64/13.0/desktop/gnome
  [5]   default/linux/amd64/13.0/desktop/kde
  [6]   default/linux/amd64/13.0/developer
  [7]   default/linux/amd64/13.0/no-multilib
  [8]   default/linux/amd64/13.0/x32
  [9]   hardened/linux/amd64
  [10]  hardened/linux/amd64/selinux
  [11]  hardened/linux/amd64/no-multilib
  [12]  hardened/linux/amd64/no-multilib/selinux
  [13]  hardened/linux/amd64/x32
  [14]  hardened/linux/uclibc/amd64


"OPS" It is very  important you don't reboot without one or the other installed. The results would be rather unfortunate.

I use xfce4 and that means only remove udev. Consolekit get removed with above settings.
emerge -C udev

Install systemd first then add systemd to make.conf.
emerge -1av systemd

Add systemd to make.conf.
USE="-gnome -kde -minimal -qt4 -consolekit -pulseaudio systemd

Update your system.
emerge --keep-going  --update --newuse --ask --deep --with-bdeps=y @world

Add systemd to grub2.
GRUB_CMDLINE_LINUX="init=/usr/lib/systemd/systemd"

Mine looks like this.
GRUB_CMDLINE_LINUX="quiet  audit=0  ipv6.disable=1 init=/usr/lib/systemd/systemd"

Done with systemd and reboot.

------------------------------------------------------------------------------------------------------

Now fix little things after :)

Check here again.
https://wiki.archlinux.org/index.php/Systemd
http://wiki.gentoo.org/wiki/Systemd
------------------------------------------------------------------------------------------------------

http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/
Start Network
systemctl enable NetworkManager
systemctl start NetworkManager

If you have dhcpcd.
systemctl enable dhcpcd.service

If it doesn´t work
systemctl enable dhcpcd@interface_name.service

If you use dhclient.
User raddaqii in gentoo forums post this.
https://forums.gentoo.org/viewtopic-t-972608.html

If you want to have static ip look there.
https://wiki.archlinux.org/index.php/Network_Configuration#Static_IP_address

If you have a wpa_supplicant.
https://wiki.archlinux.org/index.php/WPA_supplicant#Enabling_with_systemd

-----------------------------------------------------------------------------------------------------

If you have trouble with mounting usb ,burning with dvd.not login to tty  a.s.o,
check if your user-session is active. (google have alot from arch linux forum)

https://wiki.archlinux.org/index.php/Systemd/User

$ loginctl --no-pager show-session $XDG_SESSION_ID | grep Active
Active=yes

$ loginctl show-session $XDG_SESSION_ID active

Id=c5
Timestamp=Sat 2013-10-05 13:13:55 CEST
TimestampMonotonic=93942897
VTNr=7
Display=:0
Remote=no
Service=lightdm
Scope=session-c5.scope
Leader=2364
Audit=0
Type=x11
Class=user
Active=yes
State=active
IdleHint=no
IdleSinceHint=0
IdleSinceHintMonotonic=0
Name=croutch

I fix this with the simplest solution. I installed lightDM displaymanager.
https://wiki.archlinux.org/index.php/LightDM

systemctl enable lightdm

If you want to have another display manager.
Enable with.

for kdm
systemctl enable kdm.service
systemctl start kdm.service

for gdm
systemctl enable gdm.service
systemctl start gdm.service

-----------------------------------------------------------------------------------------------------

If you have a large /home partition, it might be better to allow services that do not depend on /home to start while /home is checked by fsck. This can be achieved by adding the following options to the /etc/fstab entry of your /home partition.

noauto,x-systemd.automount

-----------------------------------------------------------------------------------------------------

Readahed section here before.

https://www.mail-archive.com/systemd-devel@lists.freedesktop.org/msg21693.html

----------------------------------------------------------------------------------------------------

Early start for services

One central feature of systemd is D-Bus and socket activation. This causes services to be started when they are first accessed and is generally a good thing. However, if you know that a service (like UPower) will always be started during boot, then the overall boot time might be reduced by starting it as early as possible. This can be achieved (if the service file is set up for it, which in most cases it is) by issuing.

# systemctl enable upower

----------------------------------------------------------------------------------------------------

After install i would recommend if you still have openrc installed  but wants systemd to take care of how programs starts. And maby save some time on boot.
To check in terminal - rc-update show.

I removed to start with.

dbus
networkmanager
alsa
syslog-ng (uninstalled)

----------------------------------------------------------------------------------------------------


Systemd comes with a rumour to boot fast and that is all true.

Look at this thread at arch linux forums. This thread is very good and you got many tips and trix from other users.

Post your systemd startup times
https://bbs.archlinux.org/viewtopic.php?id=147841


Command in terminal : systemd-analyze && systemd-analyze blame

or like me in .bashrc

alias sys='systemd-analyze && systemd-analyze blame'

And here you have my boot times at the moment.
Startup finished in 4.997s (firmware) + 961ms (loader) + 1.128s (kernel) + 535ms (userspace) = 7.622s

Whats interest are those numbers :)  and yes i have an intel 180g ssd.
Startup finished in 1.128s (kernel) + 535ms (userspace) =1.633

----------------------------------------------------------------------------------------------------

And if you have an more advanced setup with encryption,initramfs.You should look at user nlsa8z6zoz7lyih3ap´s thread on gentoo forums.
https://forums.gentoo.org/viewtopic-t-972332.html

----------------------------------------------------------------------------------------------------

croutch

tisdag 17 september 2013

Howto: Change spotify font size in gentoo linux.

Sometimes you find tips and trix on the web that are amazing. This was exactly what i was looking for and fits my 50T plasma TV perfect.

All credits to jkx for his guide http://www.larsen-b.com/Article/446.html

Spotify use a skin for the client , so changing QT4 fonts doesn’t change anything, we have to fix the skin directly.

This is how you do it in gentoo linux. Before you start remember to do backups.

You need  python and /dev-python/elementtree


1. Search the file resources.zip in /opt/spotify/spotify-client/Data/ . Extract the file skin.xml.

2. Create dir /opt/spotify/spotify-client/Data/unpack and extract resources.zip to it

3. Create a python file with name spotify.py and and past this in - 
(if you have problem with the script,put a b to the right of the 'w' in this line - 
file = open("new_skin.xml", 'w') 
from this bug http://bugs.python.org/issue9458


import xml.etree.ElementTree as xml

tree = xml.parse("./skin.xml")
root = tree.getroot()

for f in root.findall('font'):
 taille = f.get('size')
 if taille:
  taille = int(taille) + 4
  f.set('size',str(taille))


file = open("new_skin.xml", 'w')

xml.ElementTree(root).write(file)


4. After your run spotify.py you should have a file named new_skin.xml. Rename it to skin.xml and put it in unpack dir.


5. Repack resources.zip with command - zip -r resources *


6. Copy resources.zip back  to /opt/spotify/spotify-client/Data/

7. Reboot computer and start spotify 




lördag 7 september 2013

Howto: Install grub2 with "uefi" in gentoo linux.


I used refind bootloader as my boot-tool in a very long time. But i had very much trouble with it in the end
and switch over to grub2 instead. And i never had any boot problem at all since then.

I create  my partitions with  http://gparted.sourceforge.net/livecd.php and i use GPT partitions.
You must go to advanced mode and change to gpt before you create your partitions.
I have like this:
bios_grub 50M = vfat = Set bios_grub flag after creation of the partitions.
/boot/efi 512M = vfat = Set boot flag after creation of the partitions.
/
/home

# Before chroot
modprobe efivars


# EFI kernel settings

CONFIG_EFI=y
CONFIG_FB_EFI=y
CONFIG_FRAMEBUFFER_CONSOLE=y
CONFIG_EFI_PARTITION=y
CONFIG_EFI_VARS=y
CONFIG_EFI_STUB=y

Optional- I not use these two
CONFIG_RELOCATABLE=y
CONFIG_CMDLINE="root=/dev/sda3"

Install gentoo the way you do and when you chrooted in and are to install grub2.

Set:
grep -v rootfs /proc/mounts > /etc/mtab

Set GRUB_PLATFORMS in /etc/portage/make.conf (optional). If unset, grub will guess which platform you want. It guesses "pc" for x86 / amd64.

# UEFI on amd64
GRUB_PLATFORMS="efi-64"

# UEFI and PC
GRUB_PLATFORMS="efi-64 pc"

echo 'LABEL=efi-boot /boot/efi vfat defaults 0 2' >> /etc/fstab
root #
mount /boot/efi
root #
mkdir -p /boot/efi/{EFI/BOOT,GRUB}

emerge --ask sys-boot/grub

grub2-install --target=x86_64-efi --efi-directory=/boot/efi --boot-directory=/boot/efi

grub2-mkconfig -o /boot/efi/GRUB/grub.cfg

 ----------------------------------------------------------------------------------------------------------------------

 "OBS" Grub2 has change name to grub.

If you already sit with grub2 and want to switch to new grub instead just remove GRUB2DIR in /boot/efi/GRUB2.

mkdir -p /boot/efi/grub

And install 
emerge --ask sys-boot/grub
grub2-install --target=x86_64-efi --efi-directory=/boot/efi --boot-directory=/boot/efi

grub2-mkconfig -o /boot/efi/GRUB/grub.cfg

Done

 ----------------------------------------------------------------------------------------------------------------------------
sources
http://wiki.gentoo.org/wiki/GRUB2#UEFI.2FGPT
http://wiki.gentoo.org/wiki/GRUB2_Quick_Start



croutch

onsdag 26 december 2012

Howto: Install rEFInd bootloader in gentoo linux.



# My hardware
Asus P8Z77-M PRO
Intel Core i5 3570K 3,4Ghz (Ivy Bridge)
Crucial 32GB (4x8192MB) CL9 1600Mhz Ballistix Sport

I follow this guide for refind http://www.rodsbooks.com/refind/installing.html#linux
 (Installing rEFInd Manually Using Linux)

I create gpt partitions with gparted live-cd (http://gparted.sourceforge.net/livecd.php )  and install gentoo with systemrescueCD  (http://www.sysresccd.org/SystemRescueCd_Homepage ) .

# IMPORTANT.
If systemrescuecd not find your uefi bios. You must put efi.shell on a usb with fat32.
wget https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2/EdkShellBinPkg/FullShell/X64/Shell_Full.efi
Rename Shell_Full.efi to shell.efi and put it in your usb.

You could also finish the install with refind and then wget efi.shell to /boot/efi and chroot back in with uefi support.
And then create boot command with efibootmgr.

# IMPORTANT.
Refind find most of the settings automatic if you have bzImage or vmlinuz in kernel name.
(check my config at the end)
You have to call your kernel bzImage-3.6.8-blabla or vmlinuz-3.6.8 with this guide.
(No need for .efi at the end of kernelname)

# IMPORTANT.
Modprobe efivars before chroot.
modprobe efivars

# Tools we need are.
efibootmgr wget unzip

# EFI kernel settings

CONFIG_EFI=y
CONFIG_FB_EFI=y
CONFIG_FRAMEBUFFER_CONSOLE=y
CONFIG_EFI_PARTITION=y
CONFIG_EFI_VARS=y
CONFIG_EFI_STUB=y

Optional- I not use these two
CONFIG_RELOCATABLE=y
CONFIG_CMDLINE="root=/dev/sda3"

# Guide starts here ---------------------------------------------

# I create a fat32 partition and i made it 500mb

# When its time to mount your partitions to /mnt/gentoo.

Create you other dirs for gentoo and /boot/efi and mount them
mkdir -p /boot/efi
mount /dev/sda1 /mnt/gentoo/boot/efi

# When your ready to install refind efi to /boot/efi/EFI/refind
mkdir -p /boot/efi/EFI/refind

# I wget refind to my / with this command. Choose the version you want to use.
wget http://sourceforge.net/projects/refind/files/0.5.0/refind-bin-0.5.0.zip

unzip refind-bin-0.5.0.zip
cd refind-bin-0.5.0
and cd to refind dir inside refind-bin-0.5.0

cp -r icons /boot/efi/EFI/refind/icons
cp refind.conf.sample /boot/efi/EFI/refind/refind.conf
cp refind_x64.efi /boot/efi/EFI/refind/refind_x64.efi

cd /boot/efi/EFI/refind
and edit refind.conf

# The only settings i have is this and remove # at those lines.
timeout 4
UPDATE=in refind 6.5 are
"scan_all_linux_kernels" not disabled, do that if you not want to have double entrys of your kernel.Like this.
#scan_all_linux_kernels

#scanfor internal,external,optical,manual
add manual for one entry.

#showtools shell,exit,reboot,shutdown

# Add this to your config at the bottom (change to your needs).
Put stuff you need in options line - quiet elevator=noop.

menuentry "Gentoo" {
                icon   \EFI\refind\icons\os_gentoo.icns
loader \vmlinuz-3.6.8
  options "ro root=/dev/sda2"
}

menuentry Gentoo { icon EFI/refind/icons/os_gentoo.png loader \vmlinuz-linux.efi initrd \initramfs-linux.img options "ipv6.disable=1 rootfstype=ext4 root=/dev/mapper/vgroup-root cryptdevice=/dev/disk/by-uuid/07c22f21-1269-4fad-b4b2-8cbbf1daeece:lvm:allow-discards" }

# IMPORTANT.
DONT FORGET TO CP YOU KERNEL TO /boot/efi.
NOT TO /boot/efi/EFI

# IMPORTANT.
Everytime you upgrade your kernel you have to copy it manually to /boot/efi and change refind.conf to reflect the new kernel.

# Create /etc/mtab
grep -v rootfs /proc/mounts > /etc/mtab

# Now its time to add refind to efibootmgr with this command.
Taken from https://wiki.archlinux.org/index.php/UEFI_Bootloaders#Using_rEFInd.
Change /sdabcd for your needs and -p 12345 for your partition.
I use /dev/sda1.

efibootmgr -c -g -d /dev/sda -p 1 -w -L "rEFInd" -l '\EFI\refind\refind_x64.efi'

# Check if ok with command.
efibootmgr

Output .

BootCurrent: 0000
Timeout: 0 seconds
BootOrder: 0000,0001,0003,0004
Boot0000* rEFInd

Reboot.

When you login. Your screen should look like this.
http://www.rodsbooks.com/refind/

croutch