Skip to main content

Posts

Showing posts from 2014

You can mount ext2 as ext4 filesytem (just read...)

So - this is tough to even explain.  Imagine all of your build scripts and SOP simply read # mkfs /dev/VolumeGroup/Volume and then you add the following entry to /etc/fstab /dev/VolumeGroup/Volume /directory ext4 defaults 1 2 then when you run # mount -a Everything is cool.  Except .. it's not. That mkfs command created an ext2 filesystem - the crappy part is when mount command is run, even though fstab is expecting ext4, it doesn't care and mounts it anyhow.  So, now we have a filesystem with no Journal and added ext4 features. Worse yet - there is no "supported" upgrade path to ext4.  However, you can add a Journal to make it ext3. # tune2fs -j /dev/VolumeGroup/Volume

fedora 20 finish script (mp3 playback, Google Chrome, ClamAV Anti-Virus)

Once again - revisiting my "finish script" for my workstation... #!/bin/bash PWD=`pwd` DATE=`date +%Y%m%d` ARCH=`uname -p` yum -y install redhat-lsb-core RELEASE=`lsb_release -r | awk '{ print $2 }'` # Setup wheel group for NOPASSWD: sed --in-place 's/^#\s*\(%wheel\s\+ALL=(ALL)\s\+NOPASSWD:\s\+ALL\)/\1/' /etc/sudoers # Configure for fastest repos yum -y install yum-plugin-fastestmirror # REPO MGMT # RPMfusion -  Release independent yum -y localinstall --nogpgcheck http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm # RPMfusion -  Release dependent yum -y localinstall --nogpgcheck http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-${RELEASE}.noarch.rpm http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-${RELEASE}.noarch.rpm # Adobe yum -y install http://linuxdownload.adobe.com/adob

Copy Sparse files over network

I have a few physical nodes which I ran KVM guests on.  Occasionally I need to rebuild the host, so I want to copy the VM from one physical node to another.  I use RAW (sparse) disk images and standard scp would copy the image in it's entirety.  Until... I found rsync -S ;-) rsync -Surpolvv * usgtst92:/var/lib/libvirt/images/ *** SOURCE *** usgtst91 images]# for IMG in `find . -name "*.img"`; do qemu-img info $IMG; done image: ./DVGLLVUSGTST82/DVGLLVUSGTST82.img file format: raw virtual size: 44G (47244640256 bytes) disk size: 12G image: ./DVGLLVUSGTST81/DVGLLVUSGTST81.img file format: raw virtual size: 44G (47244640256 bytes) disk size: 4.0G image: ./DVGLLVUSGTST83/DVGLLVUSGTST83.img file format: raw virtual size: 44G (47244640256 bytes) disk size: 3.8G *** DESTINATION *** usgtst92 images]# for IMG in `find . -name "*.img"`; do qemu-img info $IMG; done image: ./DVGLLVUSGTST83/DVGLLVUSGTST83.img file format: raw virtual size: 44G (4724464

Add CentOS 7 and EPEL 7 to Spacewalk

At some point, most of this will be unnecessary.. I have grown fond of using the spacewalk-common-channels - however, the CentOS7 stuff is not included in Spacewalk 2.2 (as of 2014-10-26). Create a file to append to your spacewalk-common-channels.ini cat << EOF > ~/centos7-spacewalk-common-channels.ini [centos7] archs = %(_x86_archs)s name = CentOS 7 (%(arch)s) gpgkey_url = http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-7 gpgkey_id = F4A80EB5 gpgkey_fingerprint = 6341 AB27 53D7 8A78 A7C2 7BB1 24C6 A8A7 F4A8 0EB5 yumrepo_url = http://mirrorlist.centos.org/?release=7&arch=%(arch)s&repo=os dist_map_release = 7 [centos7-addons] label = %(base_channel)s-addons archs = %(_x86_archs)s name = CentOS 7 Addons (%(arch)s) base_channels = centos7-%(arch)s yumrepo_url = http://mirrorlist.centos.org/?release=7&arch=%(arch)s&repo=addons [centos7-centosplus] label = %(base_channel)s-centosplus archs = %(_x86_archs)s name = CentOS 7 Plus

Rename the Satellite Admin Account

I will build a Satellite (or Spacewalk) occasionally to test some stuff... and I have forgotten (more than once) that the first time you login, you are creating the "Admin User".. which I have erroneously setup as my self. So to fix this, add another user and make them an Organization Administrator. Then... go to https:// <satellite fqdn>/rhn/admin/multiorg/Users.do and click on the check box ;-) Technically you are reassigning the Satellite Administrator role to someone else.

Crontab: the slash (/) explained

This post was taken verbatim from http://binblog.info/2014/10/17/what-does-the-slash-in-crontab-actually-do/ on (2014-10-19) I am simply "archiving" it in case that site disappears someday.  If the owner would like me to remove this content, please let me know. What does the slash in crontab(5) actually do? Filed under: UNIX & Linux — Tags: cron , crontab , linux , unix — martin @ 2:16 pm That’s a bit of a stupid question. Of course you know what the slash in crontab(5) does, everyone knows what it does. I sure know what it does, because I’ve been a UNIX and Linux guy for almost 20 years. Unfortunately, I actually didn’t until recently. The manpage for crontab(5) says the following: It’s clear to absolutely every reader that */5 * * * * in crontab means, run every 5 minutes . And this is the same for every proper divisor of 60, which there actually are a lot of: 2, 3, 4, 5, 6, 10, 12, 15, 20, 30 However, */13 * * * * does not mean th

Shellshock bash patch is only part of the solution

USSAG02.s 13039       jboss  txt       REG              253,1     903336    1180605 /bin/bash (deleted) Applications which were spawned before the update was applied and still have not been restarted, etc.. will continue to run from the /bin/bash that was in memory. I don't know what the literal impact of this - but I assume it's fairly minimal.

Dell OMSA OME software for Linux is not fun...

First off.. I don't understand why each model needs it's own repo.. but fine... Secondly.. why do they have to use some ambiguous HEX representation of the model (i.e 0x1278) Why does the RPM packaging completely suck Mkay.. now that I'm done ranting... I have had some ugly cleanups to do with their stuff NOTE: in this example my system is actually subscribed to a Satellite channel with the Dell software, hence why I am removing the repo file. rpm -qa | egrep 'dell|srvadm' | tr '\n' ' ' > cleanup-dellomsa.out sed -i -e 's/^srvad/yum -y remove srvad/g' cleanup-dellomsa.out sed -i -e 's/^Open/yum -y remove Open/g' cleanup-dellomsa.out sed -i -e 's/^dell/yum -y remove dell/g' cleanup-dellomsa.out sed -i -e 's/^yum-dell/yum -y remove yum-dell/g' cleanup-dellomsa.out cat cleanup-dellomsa.out sh ./cleanup-dellomsa.out rm -f /etc/yum.repos.d/dell-omsa-repository.repo ls -l /etc/yum.repos.d/ yum clean all yum -y i

Display OracleASM Headers

 So.... I am up at 3AM troubleshooting an "issue" that mysteriously appeared when our DBAs restart CRS/ASM/WTH earlier during some maintenance.  Apparently ASM was unable to find 3 devices. In this example 0c32 is a known-good and 0c33 is a suspected-bad. dd if=/dev/mpath/ITSHDS06_0c35p1 bs=8 skip=13 count=4 2>/dev/null|strings TT6SMS_DATA01 [root@smsdba01 mapper]# dd if=/dev/mpath/ITSHDS06_0c32p1 bs=8 skip=13 count=6 2>/dev/null|strings TT6SMS_DATA01 TT6SMS_DATAASM31 [root@smsdba01 mapper]# /etc/init.d/oracleasm querydisk /dev/mpath/ITSHDS06_0c32p1 Device "/dev/mpath/ITSHDS06_0c32p1" is marked an ASM disk with the label "TT6SMS_DATAASM31"   [root@ttgllpsmsdba01 mapper]# dd if=/dev/mpath/ITSHDS06_0c33p1 bs=8 skip=13 count=6 2>/dev/null|strings TT6SMS_DATA01 TT6SMS_DATAASM32 [root@ttgllpsmsdba01 mapper]#  /etc/init.d/oracleasm querydisk /dev/mpath/ITSHDS06_0c33p1 Device "/dev/mpath/ITSHDS06_0c33p1" defines a device with no labe

Kickstart with UEFI and PXE (and BIOS too)

I'm still learning some of the nuances of how UEFI has changed the game a bit... but, this should get you going in the right direction. Summary : It appears that if you boot using BIOS and /pxelinux.0 - it expects a pxelinux.cfg/default (or a file based on IP or MAC) and boot using /BOOTX64.efi - it expects /efidefault Also - the syntax appears to vary between default (BIOS) and efidefault (UEFI).  At this point I am unsure if the differences I noticed are necessary though.  Details : So - I'm not going to delve in to a lot of details about the BIOS/PXE kickstart, nor how to install packages.  I also won't cover much about creating an actual kickstart file.  There are plenty of other sites that do a much better job explaining it than I ever could.  Also - my configuration supports the rest of my home network (not just my lab), so you may find some configuration settings are not absolutely necessary for this task - but should not hurt. # Install the necessary pa

Map Raw Disk Devices KVM

 I'm trying to test some KVM guest clustering w/GFS using iSCSI for the Shared Device. I don't know if any of this plan will work.. but.. I did manage to figure out how to map the device directly to the guest.     <disk type='block' device='lun' sgio='unfiltered'>       <driver name='qemu' type='raw' cache='none'/>       <source dev='/dev/disk/by-path/ip-192.168.0.140:3260-iscsi-iqn.2014-08.private.matrix.rhel6a:target1-lun-1'/>       <target dev='vdb' bus='scsi'/>       <address type='drive' controller='4' bus='0' target='0' unit='0'/>     </disk> Or.. using Multipath... (this doesn't seem to work, but I think the issue is with my VM, not this solution...)     <disk type='block' device='lun' sgio='unfiltered'>       <driver name='qemu' type='raw' cache='none

Performance Analysis

Preface:  At any given point, this ENTIRE page will be a work-in-progress... if you happen upon this page, you are likely fighting some fire and researching how to figure out what is causing your grief.  I doubt this page will help (or not until I have done quite a bit of research). dstat - versatile tool for generating system resource statistics strace - trace system calls and signals iotop - simple top-like I/O monitor iostat  - Report Central Processing Unit (CPU) statistics and input/output statistics for devices, partitions and network filesystems (NFS). vmstat - Report virtual memory statistics iotop - simple top-like I/O monitor nfsstat - list NFS statistics ps - report a snapshot of the current processes. collectl /proc /sys splat gnuplot mrtg?

Add encryption key to device after installation

I started to use encryption on my drives during installation (and also with external drives).  As ironic as this sounds:  I'm sick of entering my encryption pass-phrase every time I boot my laptop.  Even though what I am about to do is *less* secure, I still think it makes my machine pretty damn secure yet. I am preventing someone from stealing my laptop and pulling the drive to get my data.  Yes, the machine boots - which means they either have to brute-force a login at the console, or hack a service once the machine is up.  At that point, they almost deserve my "sensitive data"... Anyhow - if you would like to use encryption on your OS drive, but do not want to enter a passphrase, do the following: dd if=/dev/urandom of=/root/.keyfile bs=32 count=1 chmod 0600 /root/.keyfile cryptsetup luksAddKey /dev/sda4 /root/.keyfile sed -i -e 's/none/\/root\/.keyfile/g' /etc/crypttab dracut --force --install /root/.keyfile /boot/initramfs-`uname -r`.img # SPECIAL

Offline content for non-standard packages (Satellite, Repo, etc..)

EDIT:  This explains how you could have offline content of specific packages. You could potentially do the following: * retrieve the repo file for the files you want to retrieve * place the repo file in /etc/yum.repos.d/ and make sure enabled=0 (otherwise your host will try to use that repo for updates) * create an excludepkgs and includepkgs directive in your repo file * run reposync and identify the repo you just created * bonus: you could run createrepo (which would create the repomd.xml file and all) * place the entire repo on some media that you can attach to your server Repo File (I use this to ONLY grab a few asm files - not the entire repo - hence the include/exclude) /etc/yum.repos.d/oracle.repo ~~~ [ol6_latest] name=Oracle Linux 6 Latest (x86_64) baseurl=http://public-yum.oracle.com/repo/OracleLinux/OL6/latest/x86_64/ gpgkey=http://public-yum.oracle.com/RPM-GPG-KEY-oracle-ol6 gpgcheck=1 enabled=0 exclude = *xen* includepkgs = oracleasm*el6.x86_64 oracle-validated-* oraclea

Reasons I can't use RHEL 7 as my primary "desktop" OS (yet)

2014-07-29 -- This is not a bash-fest, I just need to keep a list of these items so I don't go off and update my OS (again) without considering the issues I ran in to. no easy support for: VPNC MP3 playback VMware Workstation Which, essentially stems from poor EPEL support (at this time) and NO rpmfusion. Which really bums me out.. I was really liking the look-and-feel of RHEL 7 workstation.  I'm sure those things will be resolved soon enough. 2014-11-07 - trying again.  Going to load RHEL 7 Workstation on my desktop to see how things going.  Criteria remains the same: hope that the VPN, MP3 and VMware Workstation now work on EL 7. No RPMfusion for EL 7?  Need to find an actual post regarding this and not some seemingly random Tweet.

Script to update Dell Firmware

There are a few other scripts/tools out there to do this.. but they all seem to have some stupid dependencies (this one is no exception). #!/bin/bash # $Id: update_firmware.sh,v 1.9 2014/04/25 18:42:55 root Exp root $ # Author: James.Radtke@company.com # Purpose:  Script to download and apply firmware updates # Status:   Stable, but likely needs some work # TODO:     I would like to require a flag to run the REBOOT REQUIRED updates # Maintained at:   rhnsat01:/root/bin/update_firmware.sh #         # #  VARIABLES # FIRMWARE_LOG=/var/log/dell_firmware.log PRETTYDATE=`date +%Y%m%d-%H%M` REBOOT_RECD=0 # PLEASE NOTE: EACH OF THE PACKAGES LISTED IN THE PKGS VARIABLES ARE THE #   LEAST-COMMON-DENOMINATOR FOR EACH PACKAGE. (i.e. they only differ by version number). NON_REBOOT_PKGS="ESM Lifecycle-Controller Power_Firmware" REBOOT_PKGS="R[1-9][12]0_BIOS BIOS Network_Firmware SAS-RAID_Firmware Fibre-Channel_Firmware" # MYPWD=`pwd` # #########################################

Red Hat Satellite: Cleanup "Actions" history

I had run in to a situation where my Satellite had several hundred-thousand previously run scheduled jobs sitting in the history... I could delete them 25 at a time... and if I did "Select All" it would puke. So - I created the following #!/usr/bin/env python import xmlrpclib import time SATELLITE_URL = "http://rhnsat01.company.com/rpc/api" SATELLITE_LOGIN = "satadmin" SATELLITE_PASSWORD = "notMyPassword" client = xmlrpclib.Server(SATELLITE_URL, verbose=0) delete = 1 key = client.auth.login(SATELLITE_LOGIN, SATELLITE_PASSWORD) ############################### # CHANGE THINGS AFTER THIS LINE # ## Delete all Failed Actions x = "Deleting all Failed Actions" print(x) failed_list = client.schedule.listFailedActions(key) action_ids=[] for action in failed_list:     action_ids.append(action['id']) archive_result=client.schedule.archiveActions(key,action_ids) ## Archive all Completed Actions ## Generate a

Satellite Backup Script 5.5

#!/bin/bash ## Database Backup Script - Embedded Only prettyDATE=`date +%F` BACKUPS=/var/satellite/backups BACKUPDIR=${BACKUPS}/${prettyDATE} DBBACKUPDIR=${BACKUPS}/${prettyDATE}/DB mkdir -p ${BACKUPDIR} mkdir -p ${DBBACKUPDIR} chown oracle:dba ${DBBACKUPDIR} /usr/sbin/rhn-satellite stop echo "-- `date`" tar -cvf ${BACKUPDIR}/var_lib_rhn_kickstarts_upload.tar /var/lib/rhn/kickstarts/upload/ tar -cvf ${BACKUPDIR}/var_lib_cobbler.tar /var/lib/cobbler/ tar -cvf ${BACKUPDIR}/etc_cobbler.tar /etc/cobbler/ tar -cvf ${BACKUPDIR}/etc_rhn.tar /etc/rhn/ su - oracle -c "db-control backup ${DBBACKUPDIR}" echo "-- `date`" /usr/sbin/rhn-satellite start echo "-- `date`" su - oracle -c "db-control verify ${DBBACKUPDIR}" echo "-- `date`" # TRAVERSE THE BACKUP DIR TO DELETE OLD(ER) BACKUP FILES # I DO NOT LIKE USING A VARIABLE FOR THE PATH FOR THIS TYPE OF COMMAND find /var/satellite/backups -type d -mtime +14 -exec rm -rf {} \; /usr/sbin/rhn-

Snapshot cleanup expect script for Satellite

My environment does not see a lot of general maintenance or attention in particular ways.  I will occasionally find something that is either causing us grief, or about to... One of those items is the size of my Satellite Database.  The size is now an issue as I hope to upgrade to Red Hat Satellite 5.6 and migrate to Postgres in the process (yeah!). Some folks have recommended: * remove unused channels (seems logical enough) * remove unused/older snapshots I'm fairly certain that nobody else in my environment knows or realizes that snapshots even exist, let alone why they are advantageous.  Therefore, I intend to truncate the snapshots to only include those created in the last 4 months. #!/usr/bin/expect -f # # Expect and autoexpect were both written by Don Libes, NIST. # set force_conservative 0  ;# set to 1 to force conservative mode even if                           ;# script wasn't run conservatively originally if {$force_conservative} {         set send_slow {1 .

Filesystem resize issue (ext4)

Error [root@dvgllpsmsapp12 apps]# resize2fs /dev/mapper/ORAAPPVG-LV_APPS resize2fs 1.39 (29-May-2006) Filesystem at /dev/mapper/ORAAPPVG-LV_APPS is mounted on /apps; on-line resizing required Performing an on-line resize of /dev/mapper/ORAAPPVG-LV_APPS to 275251200 (4k) blocks. resize2fs: Inappropriate ioctl for device While trying to add group #4400 Resolution [root@dvgllpsmsapp14 ~]# lvresize -L+500g /dev/mapper/ORAAPPVG-LV_APPS Extending logical volume LV_APPS to 1000.00 GB Logical volume LV_APPS successfully resized [root@dvgllpsmsapp14 ~]# yum -y install e4fsprogs Loaded plugins: downloadonly, product-id, rhnplugin, security, subscription-  : manager This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. This system is receiving updates from RHN Classic or RHN Satellite. Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package e4fsprogs.x86_64 0:1.41.12-4.el5

Satellite UNDO_TBS is full

[root@pdgllprhnsat01 rhnsat]# spacewalk-remove-channel -c rhel-i386-server-5 -c dell-om-platform_independent-rhel-i386-server-5 -c rhel-i386-server-productivity-5 -c rhn-tools-rhel-i386-server-5 Deleting package metadata (9499):                   ________________________________________ Removing:         ERROR: unhandled exception occurred: ((30036, "ORA-30036: unable to extend segment by 8 in undo tablespace 'UNDO_TBS'\n", 'delete from rhnChannelPackage where package_id = :package_id')). Traceback (most recent call last):   File "/usr/bin/spacewalk-remove-channel", line 560, in ?     sys.exit(main() or 0)   File "/usr/bin/spacewalk-remove-channel", line 147, in main     skip_channels=options.skip_channels)   File "/usr/bin/spacewalk-remove-channel", line 305, in delete_channels     _delete_rpms(rpms_ids)   File "/usr/bin/spacewalk-remove-channel", line 477, in _delete_rpms     _delete_rpm_group(toDel[:group])   File &q

Beginning Python

#!/usr/bin/env python __author__ = "James Radtke" __copyright__ = "Copyright 2013, Linux Revolution" __credits__ = ["James Radtke"] __license__ = "GPL" __version__ = "0.0.1" __date__ = "20130108" __maintainer__ = "James Radtke" __email__ = "james.radtke@linuxrevolution.com" __status__ = "Development" import commands from os import path, access, R_OK # W_OK for write permission. # First, see if FILE exists FILE='/tmp/test' if path.exists(FILE) and path.isfile(FILE) and access(FILE, R_OK): print "File: " + FILE + " exists" else: print "ERROR: " + FILE + " File is missing or is not readable" # See if process is running PROCNAME = 'bash' OUTPUT = commands.getoutput('ps -A') if PROCNAME in OUTPUT: print "Process " + PROCNAME + " was running" else: print print "ERROR: Process "

Linux Antivirus

Linux doesn't *need* Antivirus... blah.. blah... whatever...  I wear seatbelts not because I *will* be in an accident today... I wear them as I *might* be in an accident.  I don't actually run AV on my Linux systems... My Windows 8.1 host was p0wned when I attempted to download/install a Matrix Screensaver from CNET.  I thought that site was safe.. but there is definitely many reasons why I don't generally run Windows.  Stupid stuff like this... ranks pretty high on that list. Anyhow - since the host in question is a dual-boot system with Windows and either Fedora or RHEL - I figured I should clean-up the Malware on my Windows partition while running it from Linux. This is the procedure for Linux: ### Install ClamAV and mount Windows partition yum -y install clamav clamav-data  clamav-filesystem clamav-lib clamav-lib clamav-scanner-systemd clamav-server-sysvinit clamav-update clamav-unofficial-sigs mkdir -p /windows/C mount /dev/sda4 /windows/C ### Update the

core dump configuration RHEL

I have copied this page (verbatim) from http://linuxtechres.blogspot.com/2011/09/how-to-enable-core-dump-for-application.html ALL credit is due to Jephe Wu (contact at bottom).  I merely want to archive this in case his site disappears. Objective : enable core dump for application and users Environment: RHEL5 Steps: 1. enable it for interactive login users globally By default, it's disabled in Linux, you can change file /etc/profile. from     # No core files by default     ulimit -S -c 0 > /dev/null 2>&1 to     ulimit -c unlimited >/dev/null 2>&1 or for individual user, edit your $HOME/.bash_profile.     2. for those program started by daemon or services , please add the following into /etc/sysconfig/init #added by Jephe for enabling core dump for application users DAEMON_COREFILE_LIMIT='unlimited' This environment variable will be picked up by /etc/init.d/* daemons/services. To enable core dump for individual daemon /etc/init.