Showing posts with label fedora. Show all posts
Showing posts with label fedora. Show all posts

Thursday, June 18, 2015

Red Hat 6 to Red Hat 7 system start up configuration

The Linux start up sequence for many years had been a hybrid of BSD and SVR4 stay up files. These files consisted of the /etc/inittab, /etc/rc.local and the /etc/init.d/* and /etc/rc[0-6].d/* locations. The sequence was sequential and in most cases required each command to complete before moving on to the next. Debian based systems atempted to tackle this issue and sped up the start up process by introducing upstart which enabled milestones and dependencies, but was cumbersome and not as effective as the Solaris 10 start up method. Red Hat 7 took its startup sequence from the Fedora project, with Fedora 18 and 19 making the change to systemd which by Fedora 20 was firmly in place and saw the demize of the old mechanism, but like Red Hat 7 still allows the old style SVR4 scripts to be used.
In the rest of this document I will take you through the necesary changes from v6 to v7 start up, covering;
  • Essential commands to start and stop services
  • Commands to disable or enable a service at boot
  • How to change the default run level
  • How to configure your own boot script

Essential service commands

In this section we will look at how you start, stop and view the status services in Red Hat 7.

Starting a service Red Hat 6

The service command in Red Hat 6 is used to control daemon process and associated files, such as the pid file, subdydtem lock file and others. In the event that a service (daemon) terminates unexpectedly these files remain in place as a foot print to let us know that the system didn't stop cleanly. To get the service back up and running you would need to remove these files from within the /var subdirectories. They are normally in /var/run and /var/lock.
service serviceName start
E.g. service dhcpd start

Starting a service Red Hat 7

systemctl start serviceName
E.g. systemctl start dhcpd.service

Stopping a service Red Hat 6

service serviceName stop
E.g. service network stop

Stopping a service Red Hat 7

systemctl stop serviceName
E.g. systemctl stop network.service
You'll notice that the syntax for the systemctl command lead to better history editing since the name of the service comes after the action unlike the old service commands, alowing us to simply recall the command and remove the service name and put in the next.

Systemctl syntax

systemctl action serviceName
systemctl [start|stop|status] serviceName

Listing services Red Hat 6

chkconfig --list [serviceName]
This will list whether a service is set to run at boot time if the service name is supplied, or list all services run ability at boot.
If you wish to se current state of all processes then you would require the following shell script;
for serviceName in $(chkconfig --list | cut -f1 -d' ')do  service $serviceName statusdone

Listing services Red Hat 7

systemctl -a
This one command tells us whether the service is running or is set to run at boot time.
You can also see if an individual service is enabled with;
systemctl is-enabled serviceName
Another useful command for checking a daemons status is the new journalctl command which shows information that will have been written to the log file. This command shows up if you start a service from the command line, and mentions the use of option -xn.
To list all available services;
systemctl list-unit-files --type=service

Red Hat 6 enable or disable services at boot

The chkconfig command was used up to and including Red Hat 6 systems to define if a service should be included in the run level as part of its start up sequence. This command like the service command can still be used in v7, but you should become familiar with the new commands.
Enabling a service for any runlevel was performed with;
chkconfig serviceName on
And to disable it;
chkconfig serviceName off
To specify the runlevel you would use the --level option
E.g. chkconfig --level 23 network on
These commands simply created the correct S or K script in the relevant rc.d directories.
To add your own boot script to a system you used;
chkconfig --add scriptName
Where scriptName is the name of the boot script in the /etc/rc.d/init.d directory that you created. There is also a corresponding --del to remove it from the boot sequence, but not the init.d directory.

Red Hat 7 enable or disable services at boot

In the v7 systems we continue to use the one command, systemctl.
Enable a service or resource with;
systemctl enable serviceName
E.g. systemctl enable cupsd.service
Disable a service with;
systemctl disable serviceName

Modifying the boot sequence

In this section we will look at how to set the default runlevel, add your own service and change the runlevel on boot.

Red Hat 6 setting default runlevel

The /etc/inittab file is used up to and including v6. One line in the file needed the numerical value changed. The initdefault line required the number in column 2 to be set to your desired run level. E.g.
id1:3:initdefault:
Note that with the lines in the inittab it was always essential to have the correct number of : characters on the line.
The above example sets the default run level to 3.

Red Hat 7 setting default runlevel

The inittab has now been retired and a symlink system is now in use that points to the relevant configuration file containing the runlevel to be started on boot. The files that define the levels are located in the /lib/systemd/system directory and end .system, e.g. graphical.target.
To find out the current and default runlevel use the following command;
systemctl get-default
To change the resources to start on boot you use the set-default option as follows;
systemctl set-default multi-user.target
If you wish to use run levels in v7 you can by specifying;
runlevel?.target
The ? should be changed for the number of the run level you want to set. You can then use;
systemctl set-default runlevel5.target
The above example is the same as graphical.target.

Red Hat 6 temporarily change runlevel at boot

Through grub boot menu you would press a key to halt the countdown. You then press e to edit the kernel boot line you wish to start the system with and add the runlevel number to the end of the kernel line and press the relevant key to boot the system using your current settings.
This of course can be used to alter any kernel values.

Red Hat 7 temporarily change runlevel at boot

The process is the same as v6, but instead of specifying the numerical run level you will need to use the target name at the end of the kernel line. For example to use rescue mode;
systemd.unit=rescue.target

Red Hat 6 boot scripts

These are simple bash shell scripts which make use of the case statement, but require 2 special comments to appear in the file. The 2 comments required are;
#description:
#chkconfig:
Note that they must have the colon (:) symbol immediately street the name.
Following the colon are the directives to define what the script is for and what the default start and stop run levels are.
Example:
#!/bin/bash#description: Describes what your service does, used by apps that can provide more info#chkconfig 235 99 01# the above line sets the service to start at # run levels 2, 3 and 5 as the 99th item, e.g S99xxx# and spots add the 1st, e.g K01case $1 in  'start')    # start the service here and create pid and lock files    ;;  'stop')    # stop the service using pid file, remove lock file    ;;  'status')    # use pid file to check process is running
    # and if lock file exists
    ;;
esac

Red Hat 7 boot scripts

The equivalent of the init.d script is to create a .sevice file in the /lib/systemd directory. Notice that you can still use your old style init.d script by placing it into /usr/lib/systemd/scripts.
[Unit]Description=Describe your service[Service]Type=oneshotExecStart=/usr/lib/systemd/scripts/yourInitScript startExecStop=/usr/lib/systemd/scripts/yourInitScript stopRemainAfterExit=yes[Install]WantedBy=multi-user.target
You change the relevant parts, e.g. what this script needs before it can start, the daemon to run our the script.

Useful references


Thursday, September 29, 2011

HP DV3-4300sa Fedora 14 Monitor Setup

Having finally finding some time to sit with my new HP Laptop I have managed to get the screen to work during boot up, and the Wifi connection to work. (Now just have to see about the intermittent fault on the fixed ethernet port).

Getting the graphics working
0. Install the ati-driver-installer-11-8-x86.x86_64.run driver direct from the support.amd.com web site - http://support.amd.com/us/Pages/AMDSupportHub.aspx
- Category: Notebook Graphics
- Product Line: Radeon HD Series
- Product Model: Radeon HD 6xxxM Series
- Operating System: Linux x86_64

1. Remove from /etc/grub.conf kernel line
- rhgb

2. Add to /etc/grub.conf kernel line
- video=VGA-1:e vga=0x318

3. Added /etc/X11/xinit/xinitrc.d/45custom_xrandr-settings

#!/bin/bash
xrandr --addmode VGA1 1366x768
xrandr --output LVDS1 --mode 1366x768 --fb 1366x768
xrandr --output VGA1 --mode 1366x768 --fb 1366x768

4. chmod +x /etc/X11/xinit/xinitrc.d/45custom_xrandr-settings

5. /etc/X11/xorg.conf

Section "ServerLayout"
Identifier "aticonfig Layout"
Screen 0 "aticonfig-Screen[0]-0" 0 0
Screen 1 "LCDPanel"
EndSection

Section "Module"
EndSection

Section "Monitor"
Identifier "aticonfig-Monitor[0]-0"
Option "VendorName" "ATI Proprietary Driver"
Option "ModelName" "Generic Autodetecting Monitor"
Option "Enable" "true"
Option "DPMS" "true"
ModeLine "1366x768" 69.30 1366 1398 1420 1474 768 770 774 784
EndSection

Section "Monitor"
Identifier "LCDPanel"
Option "Enable" "true"
Option "DPMS" "true"
ModeLine "1366x768" 69.30 1366 1398 1420 1474 768 770 774 784
EndSection

Section "Device"
Identifier "aticonfig-Device[0]-0"
Driver "fglrx"
Option "DesktopSetup" "clone"
Option "Centermode" "off"
Option "monitor-VGA" "aticonfig-Monitor[0]-0"
Option "monitor-LVDS" "LCDPanel"
BusID "PCI:1:0:0"
EndSection

Section "Device"
Identifier "LCDPanel"
Driver "intel"
Option "DesktopSetup" "clone"
Option "monitor-LVDS" "LCDPanel"
Option "monitor-VGA" "aticonfig-Monitor[0]-0"
BusID "PCI:0:2:0"
EndSection

Section "Screen"
Identifier "aticonfig-Screen[0]-0"
Device "aticonfig-Device[0]-0"
Monitor "aticonfig-Monitor[0]-0"
DefaultDepth 24
SubSection "Display"
#Viewport 0 0
Depth 24
#Modes "1366x768" "1024x768"
EndSubSection
EndSection

Section "Screen"
Identifier "LCDPanel"
Device "LCDPanel"
Monitor "LCDPanel"
DefaultDepth 24
SubSection "Display"
#Viewport 0 0
Depth 24
#Modes "1366x768" "1024x768"
EndSubSection
EndSection

Making Wifi Work
1. Edit the file /etc/rc.local and add the following lines to it

modprobe lib80211
insmod /lib/modules/`uname -r`/kernel/drivers/net/wireless/wl.ko
modprobe b43

Thursday, April 28, 2011

Virtual Box and Fedora Core

What a surprise Virtual Box have regressed to preventing USB from working again. They should have left it as adding the user to the vboxusers group (which you still require), but oh no!

Now you have to do the following on FC to make USB devices available to you;

Since we of the Fedora world have to use the install script it means our Virtual Box is installed into /opt/VirtualBox

In this directory there is a script called VBoxCreateUSBNode.sh

Edit this script and look for the following code;

if test "$class" -eq 9; then
exit 0
fi

Comment out these lines so it looks like;

#if test "$class" -eq 9; then
# exit 0
#fi

Then go to /proc/bus and you need to allow rwx to all users;

chmod -R 777 /proc/bus/usb
(This is still a work in progress, and ideally you should make the directory group something like vboxusers and then do chmod -R 775 /proc/bus/usb to make sure that only those you trust have access.

Now start VirtualBox

Start your VM

And you should now be able to select your USB device.

FC14 and Skype

As the new versions of Fedora Core come out so every time I have to find out how Skype can be installed and running, since Skype only seem to think everyone uses Ubuntu, even though there is a massive FC community out there.

So today, having successfully installed Skype on FC14 x86_64 architecture thought I'd best write a note about it so that I can remember when I upgrade my server.

Firstly we need to get the 32bit library files necessary for the only version Skype supply for non-Debian Linux systems. These files can be installed as follows;

yum install libXv.i686 qt.i686 qt-x11*.i686 libsigc++ libsigc++.i686 libXScrnSaver.i686 pulseaudio*.i686 libv4l.i686

In brief the above libraries provide the 32-bit graphical functionality, sound (pulseaudio) and webcam (libv4l).

Then download either the FC10 rpm or the Dynamic build of Skype from Skype directly.
If using the rpm then install as follows;
yum localinstall skype-versionsnumber.rpm --nogpgcheck

Else if using the Dynamic file unpack;
bunzip2 skype-versionnumber.tar.bz2
tar xvf skype-versionnumber.tar

Move the directory somewhere meaningful, e.g. /usr/local/skype

Now you should be able to start Skype and have audio and video, running with no library issues.