Planet Hoyer

May 25, 2011

Harald Hoyer

Fedora 15 - 8 services you can most likely disable

If you installed Fedora 15 from the live CD you will end up with some system services enabled, which you most likely do not need _ever_.

These services are:

  • fcoe and lldpad, only needed, if you have fibre channel over ethernet devices
  • iscsi and iscsid, only needed, if you have iSCSI devices
  • livesys and livesys-late, only needed for the live CD
  • mdmonitor, only needed, if you have RAID devices

You can disable them with system-config-services or by:

# chkconfig <servicename> off

<rant mode>anaconda really should do this for you... I filed a bug for this</rant mode>

by Harald Hoyer at May 25, 2011 11:55

May 24, 2011

Harald Hoyer

Fedora 15 Boot Optimization (from 45 to 26 seconds)

If you want to run Fedora 15 on a slow spinning disk, then you have to customize it a bit, to get fast boot times.

First we choose a manual disk layout and use primary partitions and format them with ext4. In my case this results in:

sda1 ext4 /boot
sda2 swap
sda3 ext4 /

After the first boot, setup of the user, etc. and 2 reboots (always reboot 2 times, before taking the measurement, because readahead needs to adapt to the changed boot process), I measure 45 seconds from the grub menu to the graphical login screen. To get the grub menu, just hold down <ALT> in the boot phase. 45 seconds is a little bit slow compared to the other distributions. systemd-analyse gives me the output: Startup finished in 5585ms (kernel) + 5509ms (initrd) + 21847ms (userspace) = 32942ms

The next step is to disable the initramfs, because the kernel can boot from an ext4 partition without it. Because I know how to rescue my system, I can set the root device directly to sda3 and tell the kernel which filesystem type to use. My /etc/grub.conf looks like this:

title Fedora (2.6.38.6-26.rc1.fc15.i686.PAE)
root (hd0,0)
kernel /vmlinuz-2.6.38.6-26.rc1.fc15.i686.PAE ro root=/dev/sda3 rootfstype=ext4 rhgb quiet
#    initrd /initramfs-2.6.38.6-26.rc1.fc15.i686.PAE.img

Rebooting gives 40 seconds to the login screen. systemd-analyse prints:  Startup finished in 7897ms (kernel) + 21470ms (userspace) = 29367ms

Because I don't use any LVM, RAID or encrypted devices, I can safely turn off all fedora-* services. Additionally I turn off the plymouth boot splash, because I want speed and not eye candy. To turn off these services, you have to use the /dev/null softlink mechanism, because these services cannot be disabled by "systemctl disable". A bonus with that mechanism is, that no rpm %post script turns them on automatically, without me knowing :-)

# cd /lib/systemd/system
# for i in fedora-* plymouth-*; do sudo ln -s /dev/null /etc/systemd/system/$i;done

Now the boot time is down to 37 seconds. systemd-analyse prints: Startup finished in 7894ms (kernel) + 17992ms (userspace) = 25887ms

From now on, you really have to know what you are doing and how to revert your actions. To compare Fedora 15 with e.g. Ubuntu, I will now turn off all services except sshd. The result will be a Linux system without mail, firewall, printing and selinux security.

$ for i in abrt-ccpp abrt-oops cups mdmonitor netfs nfslock pcscd portreserve rpcbind rpcgssd rpcidmapd sendmail smolt ip6tables iptables sandbox selinux; do sudo chkconfig $i off;done

To disable selinux, edit /etc/selinux/config and/or add "selinux=0" to the kernel command line. My /etc/grub.conf now looks like this:

title Fedora (2.6.38.6-26.rc1.fc15.i686.PAE)
root (hd0,0)
kernel /vmlinuz-2.6.38.6-26.rc1.fc15.i686.PAE ro root=/dev/sda3 rootfstype=ext4 selinux=0
#    initrd /initramfs-2.6.38.6-26.rc1.fc15.i686.PAE.img

A reboot shows, that we are now down to a nice 26 seconds. systemd-analyse prints: Startup finished in 6157ms (kernel) + 12048ms (userspace) = 18206ms

Because I turned off selinux, I can also remove some packages :-)

# sudo yum remove $(rpm -qf --qf '%{name}\n' /etc/init.d/auditd /lib/systemd/system/{abrtd.service,mcelog.service})

I also like the idea of automounting (systemd's automount feature was an idea of mine :-) ). So I turn /boot in a "mount on demand" mountpoint. Also having /tmp as a tmpfs is one way to reduce disk activity (useful for e.g. a slow flash disk).

My resulting /etc/fstab looks like this:

/dev/sda3  /                       ext4    defaults        1 1
/dev/sda1 /boot                   ext4    noauto,comment=systemd.automount     1 2
/dev/sda2 swap                    swap    defaults        0 0
tmpfs      /tmp                    tmpfs   defaults        0 0

A reboot gives still 26 seconds, systemd-analyse: Startup finished in 6121ms (kernel) + 12772ms (userspace) = 18894ms

To see the difference readahead makes for the system, I turn it off temporarily and reboot

# cd /lib/systemd/system
# for i in *readahead*; do systemctl disable $i;done
rm '/etc/systemd/system/default.target.wants/systemd-readahead-collect.service'
rm '/etc/systemd/system/default.target.wants/systemd-readahead-replay.service'

Without readahead it takes 32 seconds to be able to login. systemd-analyse says: Startup finished in 6125ms (kernel) + 10992ms (userspace) = 17118ms

As we can see it's real 26 versus 32 seconds. The output of systemd-analyse would be misleading, if we only relied on that!!

So, because I like 26 seconds more, I turn on readahead again :-) To check, if readahead has an updated list, do a "ls -l /.readahead" to see the timestamp and check the return status of readahead ("systemctl status systemd-readahead-collect.service"). There might be a selinux related bug, because with selinux turned on, the collector always returned with error status 1 in my testing.

# cd /lib/systemd/system 
# for i in *readahead*; do systemctl enable $i;done

For the reference here is the list of services, that are started:

# LANG=C chkconfig --list|fgrep 5:on

Note: This output shows SysV services only and does not include native
systemd services. SysV configuration data might be overridden by native
systemd configuration.

cpuspeed           0:off    1:on    2:on    3:on    4:on    5:on    6:off
sshd               0:off    1:off    2:on    3:on    4:on    5:on    6:off
# systemctl
boot.automount            loaded active waiting       boot.automount
dev-hugepages.automount   loaded active waiting       Huge Pages File System Automount Point
dev-mqueue.automount      loaded active waiting       POSIX Message Queue File System Automount Point
proc-sys...misc.automount loaded active waiting       Arbitrary Executable File Formats File System Automount Point
sys-kern...ebug.automount loaded active waiting       Debug File System Automount Point
sys-kern...rity.automount loaded active waiting       Security File System Automount Point
sys-devi...ock-sdb.device loaded active plugged       Flash_HS-CF
sys-devi...ock-sdc.device loaded active plugged       Flash_HS-COMBO
sys-devi...d-card1.device loaded active plugged       SB Live! EMU10k1
sys-devi...net-em1.device loaded active plugged       82540EM Gigabit Ethernet Controller
sys-devi...da-sda1.device loaded active plugged       ST380011A
sys-devi...da-sda2.device loaded active plugged       ST380011A
sys-devi...da-sda3.device loaded active plugged       ST380011A
sys-devi...ock-sda.device loaded active plugged       ST380011A
sys-devi...ock-sr0.device loaded active plugged       PIONEER_DVD-RW_DVR-105
sys-devi...d-card0.device loaded active plugged       82801EB/ER (ICH5/ICH5R) AC'97 Audio Controller
sys-devi...y-ttyS1.device loaded active plugged       /sys/devices/platform/serial8250/tty/ttyS1
sys-devi...y-ttyS2.device loaded active plugged       /sys/devices/platform/serial8250/tty/ttyS2
sys-devi...y-ttyS3.device loaded active plugged       /sys/devices/platform/serial8250/tty/ttyS3
sys-devi...y-ttyS0.device loaded active plugged       /sys/devices/pnp0/00:08/tty/ttyS0
sys-devi...ock-md0.device loaded active plugged       /sys/devices/virtual/block/md0
sys-devi...ty-tty0.device loaded active plugged       /sys/devices/virtual/tty/tty0
sys-devi...ty-tty1.device loaded active plugged       /sys/devices/virtual/tty/tty1
sys-devi...y-tty10.device loaded active plugged       /sys/devices/virtual/tty/tty10
sys-devi...y-tty11.device loaded active plugged       /sys/devices/virtual/tty/tty11
sys-devi...y-tty12.device loaded active plugged       /sys/devices/virtual/tty/tty12
sys-devi...ty-tty2.device loaded active plugged       /sys/devices/virtual/tty/tty2
sys-devi...ty-tty3.device loaded active plugged       /sys/devices/virtual/tty/tty3
sys-devi...ty-tty4.device loaded active plugged       /sys/devices/virtual/tty/tty4
sys-devi...ty-tty5.device loaded active plugged       /sys/devices/virtual/tty/tty5
sys-devi...ty-tty6.device loaded active plugged       /sys/devices/virtual/tty/tty6
sys-devi...ty-tty7.device loaded active plugged       /sys/devices/virtual/tty/tty7
sys-devi...ty-tty8.device loaded active plugged       /sys/devices/virtual/tty/tty8
sys-devi...ty-tty9.device loaded active plugged       /sys/devices/virtual/tty/tty9
-.mount                   loaded active mounted       /
home-harald-.gvfs.mount   loaded active mounted       /home/harald/.gvfs
media.mount               loaded active mounted       Media Directory
sys-fs-f...nections.mount loaded active mounted       /sys/fs/fuse/connections
tmp.mount                 loaded active mounted       /tmp
systemd-...d-console.path loaded active waiting       Dispatch Password Requests to Console Directory Watch
systemd-...word-wall.path loaded active waiting       Forward Password Requests to Wall Directory Watch
accounts-daemon.service   loaded active running       Accounts Service
acpid.service             loaded active running       ACPI Event Daemon
atd.service               loaded active running       Job spooling tools
avahi-daemon.service      loaded active running       Avahi mDNS/DNS-SD Stack
console-...daemon.service loaded active running       Console Manager
console-...-start.service loaded active exited        Console System Startup Logging
cpuspeed.service          loaded active exited        LSB: processor frequency scaling support
crond.service             loaded active running       Command Scheduler
dbus.service              loaded active running       D-Bus System Message Bus
getty@tty2.service        loaded active running       Getty on tty2
getty@tty3.service        loaded active running       Getty on tty3
getty@tty4.service        loaded active running       Getty on tty4
getty@tty5.service        loaded active running       Getty on tty5
getty@tty6.service        loaded active running       Getty on tty6
hwclock-load.service      loaded active exited        Apply System Clock UTC Offset
irqbalance.service        loaded active running       irqbalance daemon
NetworkManager.service    loaded active running       Network Manager
prefdm.service            loaded active running       Display Manager
rc-local.service          loaded active exited        /etc/rc.local Compatibility
remount-rootfs.service    loaded active exited        Remount Root FS
rsyslog.service           loaded active running       System Logging Service
rtkit-daemon.service      loaded active running       RealtimeKit Scheduling Policy Service
smartd.service            loaded active running       Self Monitoring and Reporting Technology (SMART) Daemon
sshd.service              loaded active running       LSB: Start up the OpenSSH server daemon
system-s...yboard.service loaded active running       System Setup Keyboard
systemd-logger.service    loaded active running       Stdio Syslog Bridge
systemd-...ollect.service loaded active exited        Collect Read-Ahead Data
systemd-...replay.service loaded active exited        Replay Read-Ahead Data
systemd-...pi-vfs.service loaded active exited        Remount API VFS
systemd-sysctl.service    loaded active exited        Apply Kernel Variables
systemd-...-setup.service loaded failed failed        Recreate Volatile Files and Directories
systemd-...ssions.service loaded active exited        Permit User Sessions
systemd-...-setup.service loaded active exited        Setup Virtual Console
udev-trigger.service      loaded active exited        udev Coldplug all Devices
udev.service              loaded active running       udev Kernel Device Manager
avahi-daemon.socket       loaded active listening     Avahi mDNS/DNS-SD Stack Activation Socket
dbus.socket               loaded active running       D-Bus System Message Bus Socket
syslog.socket             loaded active running       Syslog Socket
systemd-initctl.socket    loaded active listening     /dev/initctl Compatibility Named Pipe
systemd-logger.socket     loaded active running       Stdio Syslog Bridge Socket
systemd-shutdownd.socket  loaded active listening     Delayed Shutdown Socket
udev.socket               loaded active listening     udev Kernel Device Manager Socket
dev-sda2.swap             loaded active active        /dev/sda2
basic.target              loaded active active        Basic System
cryptsetup.target         loaded active active        Encrypted Volumes
getty.target              loaded active active        Login Prompts
graphical.target          loaded active active        Graphical Interface
local-fs.target           loaded active active        Local File Systems
multi-user.target         loaded active active        Multi-User
network.target            loaded active active        Network
sockets.target            loaded active active        Sockets
sound.target              loaded active active        Sound Card
swap.target               loaded active active        Swap
sysinit.target            loaded active active        System Initialization
syslog.target             loaded active active        Syslog
time-sync.target          loaded active active        System Time Synchronized
systemd-...ead-done.timer loaded active elapsed       Stop Read-Ahead Data Collection 10s After Completed Startup
systemd-...es-clean.timer loaded active waiting       Daily Cleanup of Temporary Directories

 

For the reference here is the dmesg output.

by Harald Hoyer at May 24, 2011 11:50

May 02, 2011

Harald Hoyer

dracut Talk at LinuxTag

I'll be giving a talk about dracut at LinuxTag in Berlin on Friday, 13.05.2011, Berlin I, 16:30-17:00 Uhr

by Harald Hoyer at May 02, 2011 08:45