Tag Archives: gnome 2

CentOS 6.8 – Disable Screen Saver and other delays

Introduction

Please see the article “Build a Linux-based Infrastructure Solution Demonstration Series” (http://blogs.czapski.id.au/2016/10/build-a-linux-based-infrastructure-solution-demonstration-series) for rationale, introduction and links to articles in this series.

In this article we are creating a script to disable the screen saver and other delays in the CentOS 6.8 desktop, and appending it to the initial create configuration script which we are incrementally building for the second and subsequent images.

Pre-Requisites

This article assumes that

  1. The work is done in the Virtual Box Machine Image created in accordance with the instructions in the blog article to be found at http://blogs.czapski.id.au/2016/10/configure-virtual-box-virtual-machine-and-install-centos-6-8-base-image.

The instructions should work in other RedHat 6-like OS’ and OS versions.

Disable screensaver and other delays

The commands in the script below will disable screensaver and other delays in the Gnome 2 desktop.

Remember that all this can be done using the relevant UIs but my objective is to create configuration scripts which I can execute and have the demo image configured without having to tediously manipulate various UIs.

mkdir -p /media/sf_distros/scripts
cat <<-'EODECK' > /media/sf_distros/scripts/002_disable_screen_saver_and_delays.sh
# disable screen saver and other delays
gconftool-2 -s -t bool /apps/gnome-screensaver/idle_activation_enabled false
gconftool-2 -s -t bool /apps/gnome-screensaver/lock_enabled false
gconftool-2 -s -t int /apps/gnome-screensaver/idle_delay 0
gconftool-2 -s -t int /apps/gnome-screensaver/logout_delay 0
gconftool-2 -s -t int /apps/gnome-screensaver/cycle_delay 0

EODECK
chmod ug+x /media/sf_distros/scripts/002_disable_screen_saver_and_delays.sh

Execute the commands

/media/sf_distros/scripts/002_disable_screen_saver_and_delays.sh

Append “disable screensaver and other delays” script execution commands to the initial bulk configuration script. This script is intended to collect all automated configuration commands and scripts so that they can be all executed in one go on a brand new image if one gets to do this the second and subsequent times.

Don’t actually execute this script while you are building the first image.

cat <<-'EODECK' >> /media/sf_distros/scripts/000_initial_bulk_configuration.sh
# disable screen saver and other delays
/media/sf_distros/scripts/002_disable_screen_saver_and_delays.sh

EODECK
chmod ug+x /media/sf_distros/scripts/000_initial_bulk_configuration.sh

CentOS 6.8 – Show Detailed Grub Boot Loader Feedback

Introduction

Please see the article “Build a Linux-based Infrastructure Solution Demonstration Series” (http://blogs.czapski.id.au/2016/10/build-a-linux-based-infrastructure-solution-demonstration-series) for rationale, introduction and links to articles in this series.

In this article I am configuring CentOS 6.8 Grub boot loader so that it shows detailed feedback at boot rather than the “progress bar” that is shows by default.

Pre-Requisites

This article assumes that

  1. The work is done in the Virtual Box Machine Image created in accordance with the instructions in the blog article to be found at http://blogs.czapski.id.au/2016/10/configure-virtual-box-virtual-machine-and-install-centos-6-8-base-image.
  2. The user “demo” has sudo access without a password. If this is not the case use the command “su -” and provide the password instead of saying “sudo -i” in the set of commands below

The instructions should work in other RedHat 6-like OS’ and OS versions.

Show Detailed Boot Feedback

Fix /boot/grub/grub.conf so that the detailed boot feedback is shown at boot instead of a “progress bar”

Remember that all this can be done using the relevant UIs, like a text editor in this case, but my objective is to create configuration scripts which I can execute and have the demo image configured without having to tediously manipulate various UIs.

Append commands to the fix grub script

mkdir -p /media/sf_distros/scripts
cat <<-'EODECK' > /media/sf_distros/scripts/001_fix_grub_boot_loader_configuration.sh

# save a backup of the grub boot loader configuration file and change it so detailed feedback is shown
cp /boot/grub/grub.conf /boot/grub/grub.conf_orig
sed -i 's/rhgb quiet//' /boot/grub/grub.conf

EODECK
chmod ug+x /media/sf_distros/scripts/001_fix_grub_boot_loader_configuration.sh

Execute the commands as root

sudo /media/sf_distros/scripts/001_fix_grub_boot_loader_configuration.sh

Append “fix grub” script execution commands to the initial bulk configuration script. This script is intended to collect all automated configuration commands and scripts so that they can be all executed in one go on a brand new image if one gets to do this the second and subsequent times.

Don’t actually execute this script while you are building the first image.

cat <<-'EODECK' >> /media/sf_distros/scripts/000_initial_bulk_configuration.sh
# set grub boot loader to be verbose
/media/sf_distros/scripts/001_fix_grub_boot_loader_configuration.sh

EODECK
chmod ug+x /media/sf_distros/scripts/000_initial_bulk_configuration.sh

Reboot to verify the change

sudo reboot

If you don’t do this but still want to occasionally see the details use Alt+E key combination when the progress bar is showing at boot – it works as a toggle

CentOS 6.8 – Configure “demo” user for autologin, sudo and VirtualBox Shared Folder access

Introduction

Please see the article “Build a Linux-based Infrastructure Solution Demonstration Series” (http://blogs.czapski.id.au/2016/10/build-a-linux-based-infrastructure-solution-demonstration-series) for rationale, introduction and links to articles in this series.

In this article I am configuring the OS so that the demo user:

  1. Is automatically logged in at boot and whenever they log out
  2. Can sudo without a password
  3. Can freely access the VirtualBox shared folder

Pre-Requisites

This article assumes that the work is done in the Virtual Box Machine Image created in accordance with the instructions in the blog article to be found at http://blogs.czapski.id.au/2016/10/configure-virtual-box-virtual-machine-and-install-centos-6-8-base-image.

The instructions should work in other RedHat 6-like OSes and OS versions.

Enable autologin for demo user

Enable autologin for the demo user so that on boot demo user is automatically logged in

su - # welcome1

cp /etc/gdm/custom.conf /etc/gdm/custom.conf_orig

sed -i 's/\[daemon\]/\[daemon\]\
AutomaticLoginEnable=true\
AutomaticLogin=demo\
/' /etc/gdm/custom.conf


reboot

Reboot to verify that demo user is logged in automatically

Add demo user to sudoers

Add demo to sudo’ers with all rights and no need to enter password

su - # welcome1

rm -f /dev/shm/sudoers
cp -f /etc/sudoers /dev/shm/sudoers

insertAfter=$(( $(grep -n "## Allow root to run any commands anywhere" /dev/shm/sudoers \
| cut -d ":" -f1-1) + 2)); echo ${insertAfter}

ed /dev/shm/sudoers <<-END
${insertAfter}i
demo    ALL=(ALL)       NOPASSWD:ALL
.
w
q
END

grep -B2 -A2 demo /dev/shm/sudoers
cp -f /dev/shm/sudoers /etc/sudoers # needs manual acknowledgement with "yes"

exit

sudo ls -al /root

Allow user to freely use Virtual Box shared folder

Include demo account in vboxsf group so that the user can freely use vbox shared folder. This assumes that the sahred folder was created with the name “distros”. If it was created with a different name change the commands accordingly.

ls -al /media/sf_distros # verify that you don’t have access to the shared folder
sudo usermod -G vboxsf demo

Log out and log back in for this to take effect

ls -al /media/sf_distros # verify that you now have access to the shared folder

Configure Virtual Box Virtual Machine and Install CentOS 6.8 Base Image

Introduction

Please see the article “Build a Linux-based Infrastructure Solution Demonstration Series” for rationale, introduction and links to articles in this series.

In this article I am configuring a Virtual Box Machine Image and installing and configuring the CentOS 6.8 OS and the Virtual Box Guest Additions. At the end of the process there will be a Virtual Box Machine Image with CentOS 6.8 installed, snapshot taken and image ready for further work.

All future articles in this series will assume that the image created this way is the baseline for further work.

Host Assumptions

I assume that the demonstration image is built as a Virtual Box 5.x virtual machine image and that the Virtual Box Host environment is Windows 7. This is not a hard requirement but merely an explanation of the Windows’isms which necessarily creep into this document, particularly when it comes to downloading distribution packages prior to image creation.

I assume that you installed the Oracle VirtualBox software on your chosen host, Windows 7 in my case, and are in position to create Virtual Machine Image using the CentOS 6.8 iso as a starting point.

Download assumptions

I assume that the platform from which the image will be created is Windows 7 and that the Windows directory to which packages will be downloaded is

O:\DemoBuilding\Distros

If you are working your way through this series and use either a different host OS or a different download file location then make appropriate adjustments.

Downloading Software Packages

All packages which I am using are, as far as I am aware, free to download. It is your responsibility to ensure that you have the right to download and use the software which I am discussing in this document.

Instructions for downloading, installing and configuring the software packages are provided when the package is first used.

Create and Configure baseline CentOS 6.8 VM Image

Download CentOS 6 Update 8

CentOS, https://wiki.centos.org, is a RedHat-like Linux distribution, available free of charge for any use as far as I can tell.

Download the CentOS 6.8 distribution from the nearest mirror, http://isoredirect.centos.org/centos/6/isos/x86_64/. For me this is http://centos.mirror.digitalpacific.com.au/6.8/isos/x86_64/.

I choose to download the two DVD iso images, CentOS-6.8-x86_64-bin-DVD1.iso and CentOS-6.8-x86_64-bin-DVD2.iso to my distribution packages directory

O:\DemoBuilding\Distros

http://centos.mirror.digitalpacific.com.au/6.8/isos/x86_64/CentOS-6.8-x86_64-bin-DVD1.iso

http://centos.mirror.digitalpacific.com.au/6.8/isos/x86_64/CentOS-6.8-x86_64-bin-DVD2.iso

Create and configure VM Image using the GUI (command line version next section)

Start the VirtualBox Management UI – for me

"C:\Program Files\Oracle\VirtualBox\VirtualBox.exe"

Verify the location to which virtual machine files will be written and change as appropriate.

Choose Machine –> New

000_vboxmgr_machine_new

Name the image “demo”, configure the following settings:

Type: Linux

Version: Other Linux (64-bit) – I am assuming that you have a 64 bit machine if not adjust accordingly

Memory Size: 4096 MB – that should be sufficient for what I have in mind. Increase as needed.

Check “Create a Virtual Hard Disk Now”

001_vbox_create_virtual_hard_disk

Click Create

Define name and location of the new hard disk – I prefer to keep all my VM files in the same place, which will happen if I correctly configure the location to which the files will go to by default.

Complete the dialogue box as follows:

File location: name – this assumes that the default location for the virtual disk file is used

File Size: 120MB

Check “VDI”

Check “Dynamically Allocated”

002_vboxmgr_dynamically_allocated

Click Create

Right-click the name of the new Virtual Box machine and choose Settings

003_vboxmgr_choose_settings

In “General”–>”Advanced” change “Shared Clipboard” and “Drag and Drop” to “bidirectional”

004_vboxmgr_shared_bidirectional

System–>Motherboard–>Boot Order: Uncheck Floppy

005_vboxmgr_uncheck_floppy

System–>Processor–>Processors: set a 1 less than the number of processors on your machine or some other number less than the total number of processors, possibly with the execution cap of less than 100% if you set this to the number of processors.

006_vboxmgr_number_of_cpus

Display–>Screen: set Video Memory to 128MB and enable 3D acceleration

007_vboxmgr_video_memory

Storage –> Storage –> Controller: IDE –> demo.vdi: Check solid state drive if your vdi file is on a solid state drive (highly recommended for performance of your VM)

Storage –> Storage –> Controller: IDE –> Empty –> Optical Drive: select Choose Virtual Optical Drive File…, then navigate to the location of the CentOS 6.8 DVD 1 iso and select it: O:\DemoBuilding\Distros\CentOS-6.8-x86_64-bin-DVD1.iso

009_vboxmgr_iso

010_vboxmgr_iso_2

Network –> Adapter 1: Confirm that you have NAT network selected and if not select it. We want to be able to update the image or get missing packages over the Internet

011_vboxmgr_nat

Shared Folders –> Shared Folders –> Folder List: click Add new Shared Folder (+) icon, navigate to the location to which you downloaded the CentOS iso distribution disks and choose that folder. Check the Auto-mount checkbox and click OK

012_vboxmgr_shared_folder

User Interface –> Check “Show at top of screen”

013_misc

Click OK to finish configuration

Boot the VM with the CentOS DVD 1 iso in the optical drive by selecting the new “demo” image in the Virtual Box Manager tree and clicking “Start”, or following the right-click menu selections over the “demo” image

014_vboxmgr_start

Create and configure VM using command line (instead of the GUI – above)

If you configured the VM using the GUI following the steps in the previous section then you don’t need to execute the command in this section. If you skipped the previous section because you want to configure the VM using the command line, carry on.

I used some of the material in http://superuser.com/questions/741734/virtualbox-how-can-i-add-mount-a-iso-image-file-from-command-line

With the VM not started, in the DOS Box / CMD window, execute the following commands:

set VBM="C:\Program Files\Oracle\VirtualBox\VBoxManage.exe"

@create and register bare VM
 %VBM% createvm --name "demo" --ostype "RedHat_64" --register

@rem Execute the following to determine where the files are going and make sure to use that directory path in creating thwe disk
 %VBM% showvminfo "demo" | find "Config file:"

@rem set the disk file location and name
 set diskFile=d:\VirtualBoxDisks\demo\demo.vdi

%VBM% storagectl "demo" --name IDE --add ide --controller PIIX4 --portcount 2 --bootable on
 %VBM% createhd --filename %diskFile% --size 120000
 %VBM% storageattach "demo" --storagectl "IDE" --port 0 --device 0 --type hdd --medium %diskFile%

%VBM% modifyvm "demo" --clipboard bidirectional
 %VBM% modifyvm "demo" --boot1 dvd
 %VBM% modifyvm "demo" --boot2 disk
 %VBM% modifyvm "demo" --boot3 none
 %VBM% modifyvm "demo" --boot4 none
 %VBM% modifyvm "demo" --cpus 3
 %VBM% modifyvm "demo" --cpuexecutioncap 100
 %VBM% modifyvm "demo" --memory 4096
 %VBM% modifyvm "demo" --vram 128
 %VBM% modifyvm "demo" --accelerate3d on
 %VBM% modifyvm "demo" --rtcuseutc on
 %VBM% modifyvm "demo" --paravirtprovider default
 %VBM% modifyvm "demo" --mouse ps2
 %VBM% modifyvm "demo" --usb on
 %VBM% modifyvm "demo" --usbehci on
 %VBM% modifyvm "demo" --nic1 nat
 %VBM% modifyvm "demo" --nicspeed1 10000000
 %VBM% modifyvm "demo" --macaddress1 auto
 %VBM% sharedfolder add "demo" --name "distros" --hostpath "O:\DemoBuilding\Distros" --automount
 %VBM% setextradata "demo" "GUI/MiniToolBarAlignment" "Top"

@rem mount the iso image for installation
 %VBM% storageattach "demo" --storagectl IDE --port 1 --device 0 --type dvddrive --medium "O:\DemoBuilding\Distros\CentOS-6.8-x86_64-bin-DVD1.iso"

Boot the VM with the CentOS DVD 1 iso in the optical drive

%VBM% startvm "demo"

Install CentOS 6.8

When you bot the VM after it is created the installation process will start. You will need to have the 1st iso mounted, which it will be if you followed the steps above. If you choose the options I chose below you will need to mount the 2nd iso to mount as well so make sure you have both before you start.

Make sure that the “Install or upgrade an existing system” is selected and press “Enter”

015_centos_choose_install_option

Skip media testing

021_centos_skip_media_test

022_centos_next_from_splashscreen

  • Next

Choose “English (English)” language (if you choose another language you will need to make such changes in the instructions as will be necessary to compensate for the fact that this guide is written in English for an English language OS)

023_centos_choose_language

  • Next

Choose US English keyboard

024_centos_choose_keyboard

  • Next

Choose Basic Storage Device

025_centos_choose_basic_storage_device

  • Next

Click “Yes, discard any data”

026_centos_yes_discard_any_data

Enter “demo.demodomain.org” into the “Host” box and click the “Configure Network” button

027_centos_configure_network_1

Choose “System eth0” and click Edit

028_centos_choose_eth0_and_edit

Check “Connect Automatically” and click “Apply”

029_centos_connect_automatically

Click Close

  • Next

Choose your timezone – Mine is Sydney/Australia

  • Next

Set root password to welcome1 (or whatever you prefer and will remember)

  • Next

Choose “Create custom layout”

030_centos_custom_layout

  • Next

Select “Hard Drives –> sda –> Free” node in the node tree and click “Create”

031_centos_create_hard_drive_1

Select “Standard partition” and click “Create”

Change “File System Type” to “swap”

Set “Size (MB)” to 8192

Ensure “Fixed Size” is selected then click “OK”

032_centos_add_swap

Select “Hard Drives –> sda –> Free” node in the node tree and click “Create”

033_centos_add_partition

Select “Standard partition” and click “Create”

Enter “/” for “Mount Point”

Retain “File System Type” of “ext4”

Check “Fill to maximum allowable size” and Click “Create”

034_centos_add_root_partition

  • Next

Click “Format”

035_centos_format

Click “Write changes to disk”

Accept “Install boot loader on /dev/sda”

036_centos_accpet_bootloader_location

  • Next

Choose “Software Development Workstation”

Select “Customize Now”

  • Next

Applications –>

Uncheck: “TeX Support” and “Technical Writing”

Select “Graphics Support Tools”, click “Optional Packages”, select “ImageMagick”, “Close”

Base System –>

Uncheck: Directory Client, Java Platform, Network File System Client, Performance Tools, Printing Client

Check: Compatibility Libraries

Databases –>

Check: MySQL Database Client, click “Optional Packages”, select MySQL Python, mysql-connector-java, mysql-connector-odbc, click “Close”

Check MySQL Database Server

Desktops –>

Check KDE Desktop (all checkboxes will be checked)

Select “Fonts”, click “Optional Packages”, uncheck all the fonts that you will not need, amd check “bitmap-lucida” and “bitmap-fixed”

Servers –> Check CIFS File Server

Virtualization –> uncheck all options

  • Next

Installation will now proceed, with 1529 packages to be installed

  • Reboot

Click Forward

Click Forward

Username: demo

Password: welcome1

Click Forward

Check date and time and click Forward

Click Finish

Log in as use demo/welcome1

Install Virtual Box Guest Additions

Pull down the “Devices” menu of the running Virtual Box Image and choose “Insert Guest Additions CD image…”

016_centos_install_vbox_guest_1

Click “OK” when the dialogue box opens

017_centos_install_vbox_guest_2

Click “Run”

Provide root password welcome1 and click “Authenticate”

Observe feedback in the terminal window the installer opens

018_centos_install_vbox_guest_3

Press Return/Enter to close the window.

Right-click on the VBOXADDITIONS… icon on the Desktop and choose “Eject”

019_centos_install_vbox_guest_4

Reboot the image: System -> Shutdown -> Reboot

Shut down the image and snapshot

"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" snapshot "demo" take "v1.0.0 Baseline - CentOS 6.8 Installed" --description "v1.0.0 Baseline - CentOS 6.8 Installed"

Configure the VM Image for screen resolution and other things

Assume that the VBoxManage.exe is installed in a default location, that the host is a Windows host and that the name of the VM image is “demo”.

In a command / terminal window of the host machine, while the VM is running, execute the following (or similar command if your host is not Windows) to see what your Virtual Box configuration is.

"c:\Program Files\Oracle\VirtualBox\VBoxManage.exe" showvminfo "demo"

With the VM running execute the following (or similar command if your host is not Windows) to set non-standard video modes and memory pre-allocation.

"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" setextradata "demo" "CustomVideoMode1" "1440x900x32"
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" setextradata "demo" "CustomVideoMode2" "1366x768x32"
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" setextradata "demo" "CustomVideoMode2" "1920x1080x32"
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" setextradata "demo" "CustomVideoMode2" "1720x1000x32"
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" setextradata "demo" "CustomVideoMode2" "1600x836x32"

This too needs the VM to be running

"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" controlvm "demo" setvideomodehint 1440 900 32
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" controlvm "demo" setvideomodehint 1366 768 32
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" controlvm "demo" setvideomodehint 1920 1280 32
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" controlvm "demo" setvideomodehint 1720 1000 32
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" controlvm "demo" setvideomodehint 1600 836 32
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" setextradata "demo" VBoxInternal/RamPreAlloc 1

Shut down the VM

With the VM shut down execute the following (or similar command if your host is not Windows) to set the speed of the NIC

"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" modifyvm "demo" --nicspeed1 10000000

Boot the VM

For working in “comfort”

"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" setextradata "demo" "CustomVideoMode2" "1600x836x32"

The one below needs VM running

"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" startvm "demo"
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" controlvm "demo" setvideomodehint 1600 836 32Shut the image down and use the Virtual Box Manager to take a Snapshot of the image. Name the snapshot "v1.0.0 Installed CentOS 6.8 and Virtual Box Guest Additions"

Shut the image down and use the Virtual Box Manager to take a Snapshot of the image. Name the snapshot “v1.0.0 Installed CentOS 6.8 and Virtual Box Guest Additions”

020_vboxmgr_v1-0-0_snapshot

This is it. The image is ready for further work.

Build a Linux-based Infrastructure Solution Demonstration Series

I have been quite remiss in the last 5 years or so, with my blog. The software I worked with in that time, and still do, is so vendor-, industry- and use case-specific that it was not really possible to develop blog articles that would be generally applicable, or at least of interest to people other these who work with the software with which I have been working.

Over these years I built a number of virtual machine images which I used to demonstrate the software and solutions. While the software and solutions were pretty point-specific, a lot of the things I did to construct, configure and deliver demonstrations are pretty generic and might be of possible interest to people who likewise need to build demonstration images for infrastructure software and fairly complex solutions that don’t have just a single GUI to demonstrate.

In the, hopefully, series of blogs, I will works through specific aspects of demo image creation and configuration, showing how one can script creation of menus, hotspots, toolbar buttons, screen backgrounds and a bunch of other things. The things which I had to do time and again, and which I endeavoured to script so that I could simply copy and paste text into a terminal window and the objects would be created without having to go through manual configuration using GUIs.

I picked a RedHat 6.8-like OS, CentOS, because I want that flavour and that version of the OS and, most specifically, I want Gnome 2 – not Gnome 3.

Series so far:

  1. Build and Configure the Base Image
    1. Configure Virtual Box Virtual Machine and Install CentOS 6.8 Base Image
    2. CentOS 6.8 – Configure “demo” user for autologin, sudo and VirtualBox Shared Folder access
    3. CentOS 6.8 – Show Detailed Grub Boot Loader Feedback
    4. CentOS 6.8 – Disable Screen Saver and other delays
    5. CentOS 6.8 – Disable Firewall and SELinux Security
    6. CentOS 6.8 – Disable Unneeded Services
    7. CentOS 6.8 – Update DHCP address in /etc/hosts at boot
  2. Configure Working Environment
    1. CentOS 6.8 – Script Adding Top Panel Applets – GEyes, ShowDesktop and Gnome Monitor
    2. CentOS 6.8 – Script adding a new gnome-terminal profile
    3. CentOS 6.8 – Create desktop branding scripts and brand desktop
    4. CentOS 6.8 – Script creating a new demo user
    5. Scripts to hide standard desktop icons and make top and bottom panels hideable
  3. Miscellaneous
    1. Resize Linux Virtual Box Virtual Disk

 

So, watch this space over the next while and see if any of what I will be writing about helps you.