Showing posts with label Ubuntu. Show all posts
Showing posts with label Ubuntu. Show all posts

Friday, August 30, 2013

How do maintain a constant mac address on bonded NICs?

SkyHi @ Friday, August 30, 2013
In 10.04 this consistenlty create bond0 with the mac address from eth0. with 12.04, the mac address used appears to be random - sometimes it's the address from eth0, sometimes it's the address from eth1.


After trying MakOwner's solution to no avail, I think I solved it for my case.

At bootup I noticed in dmesg that eth1 was coming up before eth0, probably due to some unpredictable hardware timing. To make things worse, I saw that the link states for eth0 and eth1 would sometimes go up a few seconds after bond0 went up. Perhaps the bond was polling for the link status of eth0 and eth1, cycling through each until one came up. Whichever was chosen first depended on timing.

My solution was to add a pre-up sleep command to eth1. This effectively delays it long enough to guarantee that eth0 is selected first.

Here is my configuration:

Code:
auto eth0
    iface eth0 inet manual
    bond-master  bond0

auto eth1
    iface eth1 inet manual
    # delay ifup to allow eth0 to come up first in the bond
    pre-up sleep 4
    bond-master  bond0

auto bond0
    iface bond0 inet dhcp
    bond-mode active-backup
    bond-miimon 100
    bond-slaves eth0 eth1


REFERENCES
http://ubuntuforums.org/showthread.php?t=1967987

Saturday, July 20, 2013

HOWTO: add disk to VMware Ubuntu guest without reboot using LVM

SkyHi @ Saturday, July 20, 2013
This howto is mostly built on the great tutorial available athttp://www.comnetslash.com/…hout-reboot/. My spot tries to be more Ubuntu and LVM specific. This manual was tested on Ubuntu 9.04 (jaunty) Server edition guest OS.

Add Virtual Hard Disk

add-disk1A new hard disk can be added easily to a running virtual machine in VMWare Infrastructure Web Access by clicking Add Hardware and following the wizard.
Note: I assume that all of the commands given are run under superuser (root) rights. To become root type
sudo su root

Detect new SCSI Disk

The package scsitools provides the script rescan-scsi-bus.sh, which does exacly what we need. Install it and run it:
apt-get install scsitools
rescan-scsi-bus.sh
This should detect the newly added hard disk and make it available in /dev/ – /dev/sdb in the case you are adding a new drive for the first time. The output of fdisk -l should include the newly detected disk.

Format the new disk

Format the newly detected drive using fdisk
fdisk /dev/sdb
    n (for new partition)
    p (for primary partition)
    1 (partition number)
    (keep the other values default)
    w (write changes)
Change the type of the partition to LVM Linux:
fdisk /dev/sdb
    t (change the partition type)
    8e (for Linux LVM)
    w (write changes)

LVM

Initialize LVM Physical Volume

pvcreate /dev/sdb1

Add Physical Volume to Volume Group

List the Volume groups available at your machine.
vgdisplay
Replace VolGroupName with what you read from the output of the last command.
vgextend VolGroupName /dev/sdb1
You should see the newly aquired free space in the output of
vgdisplay

Resize Logical Volumes

After adding some free space to your Volume Group, you can distribute it to the Logical Volumes. The list of Logical Volumes can be obtained by running
lvdisplay
Run the following commands for each Logical Volume you want to resize (add space to). Again – replace /dev/VolGroupNa­me/Namewith the Logical Volume name you can read from the output of the last command. The +10G means Add 10 GB
lvextend -L +10G /dev/VolGroupName/Name
The last step is to resize the ext3 filesystem (use different tool is you use different filesystem):
resize2fs /dev/VolGroupName/Name

REFERENCES
http://blog.stastnarodina.com/honza-en/spot/howto-add-disk-to-vmware-ubuntu-guest-without-reboot-using-lvm/

Thursday, June 20, 2013

Stop Ubuntu / Debian Linux From Deleting /tmp Files on Boot

SkyHi @ Thursday, June 20, 2013
Q. I know /tmp as it named is a temporary dircory, Debian policy is to clean /tmp at boot. However, I'd like to configure my Ubuntu Server to stop deleting files from /tmp on boot due to custom configuration issue. How do I configure behavior of boot scripts to stop deleting files on boot?

A. Users should not store files in /tmp, use /home or other partition, if you would like to keep the files. The behavior of boot scripts is controlled via a special configuration file called /etc/default/rcS. Open this file and modify TMPTIME variable.
On boot the files in /tmp will be deleted if their modification time is more than TMPTIME days ago. A value of 0 means that files are removed regardless of age. If you don't want the system to clean /tmp then set TMPTIME to a negative value(-1) or to the word infinite.

Configuration /etc/default/rcS

Open /etc/default/rcS file, enter:
$ sudo vi /etc/default/rcS
Set TMPTIME to 60 so that files in /tmp will deleted if their modification time is more than 60 days ago.
TMPTIME=60
Close and save the file. This configuration is used by /etc/init.d/bootclean script on boot to clean /tmp and other directories under all Debian based Linux distros.

A note about RHEL / CentOS / Fedora / Redhat Linux

Redhat and friends use /etc/cron.daily/tmpwatch cron job to clean files which haven’t been accessed for a period of time from /tmp. The default is 720 hours. If the file has not been accessed for 720 hours, the file is removed from /tmp. You can modify this script as per your requirements:
# cp /etc/cron.daily/tmpwatch /etc/cron.daily/tmpwatch.bak
# vi /etc/cron.daily/tmpwatch

REFERENCES
http://www.cyberciti.biz/faq/debian-ubuntu-removes-files-at-boot-time/

Friday, March 22, 2013

Change Default Editor for visudo in Ubuntu

SkyHi @ Friday, March 22, 2013

Ubuntu and Debian use the alternatives system to maintain the symbolic links for programs. When you first run visudo, it will prompt a list of editors for you to choose from. Unfortunately, it doesn’t tell you how to change that setting again. The mostly happend situation is: you set it to “nano” at first, and can’t change it to “vi” at a later time.
Here is the command to bring up that list again:
sudo update-alternatives --config editor
Some people suggest using command EDITOR=vi visudo, or export EDITOR=vi; visudo, but it’s really annoying if you have to remember and type so many letters everytime you run this command.



REFERENCES

Tuesday, October 16, 2012

grant sudo privileges to an existing user

SkyHi @ Tuesday, October 16, 2012

sudo usermod -a -G sudo hduser

Change Default Editor for visudo in Ubuntu

SkyHi @ Tuesday, October 16, 2012

Ubuntu and Debian use the alternatives system to maintain the symbolic links for programs. When you first run visudo, it will prompt a list of editors for you to choose from. Unfortunately, it doesn’t tell you how to change that setting again. The mostly happend situation is: you set it to “nano” at first, and can’t change it to “vi” at a later time.
Here is the command to bring up that list again:
sudo update-alternatives --config editor
Some people suggest using command EDITOR=vi visudo, or export EDITOR=vi; visudo, but it’s really annoying if you have to remember and type so many letters everytime you run this command


REFERENCES

Tuesday, August 21, 2012

How to disable DNSMASQ in ubuntu 12.04(Precise)

SkyHi @ Tuesday, August 21, 2012
Dnsmasq is a lightweight server designed to provide DNS (and optionally DHCP and TFTP) services to a small-scale network. It can serve the names of local machines which are not in the global DNS. The DHCP server integrates with the DNS server and allows machines with DHCP-allocated addresses to appear in the DNS with names configured either in each host or in a central configuration file. Dnsmasq supports static and dynamic DHCP leases and BOOTP for network booting of diskless machines.

The developers of dnsmasq targeted home networks using NAT and connected to the internet via a modem, cable-modem or ADSL connection. But the system would function well in any small network where low resource-use and ease of configuration are important.
In ubuntu 12.04 dnsmasq is now running by default due to being hard coded into network manager.
Using dnsmasq as local resolver by default on desktop installations
That’s the second big change of this release. On a desktop install, your DNS server is going to be “127.0.0.1? which points to a NetworkManager-managed dnsmasq server.
This was done to better support split DNS for VPN users and to better handle DNS failures and fallbacks. This dnsmasq server isn’t a caching server for security reason to avoid risks related to local cache poisoning and users eavesdropping on other’s DNS queries on a multi-user system.
The big advantage is that if you connect to a VPN, instead of having all your DNS traffic be routed through the VPN like in the past, you’ll instead only send DNS queries related to the subnet and domains announced by that VPN. This is especially interesting for high latency VPN links where everything would be slowed down in the past.
As for dealing with DNS failures, dnsmasq often sends the DNS queries to more than one DNS servers (if you received multiple when establishing your connection) and will detect bogus/dead ones and simply ignore them until they start returning sensible information again. This is to compare against the libc’s way of doing DNS resolving where the state of the DNS servers can’t be saved (as it’s just a library) and so every single application has to go through the same, trying the first DNS, waiting for it to timeout, using the next one.
If you don’t want a local resolver you can turn it off DNSMASQ using the following procedure
You need to edit /etc/NetworkManager/NetworkManager.conf file
gksudo gedit /etc/NetworkManager/NetworkManager.conf
and comment out the following line from
dns=dnsmasq
to
#dns=dnsmasq
Save and exit the file
Now you need to network-manager using the following command
sudo restart network-manager
Source from here


REFERENCES
http://www.ubuntugeek.com/how-to-disable-dnsmasq-in-ubuntu-12-04precise.html
http://www.stgraber.org/2012/02/24/dns-in-ubuntu-12-04/

Monday, August 20, 2012

ubuntu install amd catalyst

SkyHi @ Monday, August 20, 2012

ATI Radeon™ HD 3450 GPU on Ubuntu 12.04


Manually installing Catalyst 12.6, special case for Intel/ATI hybrid graphics

WARNING: Using a method other than described in the manual instructions section above by creating a .deb file can lead to extreme difficulties. Be sure to take note of the instructions for uninstalling the driver at the end of this section, since the driver must be uninstalled using the amdconfig utility.
This method is NOT RECOMMENDED in general, but has been found by some users to make the chore of getting Intel/ATI hybrid graphics to work less difficult.
This method PROBABLY WILL NOT WORK for HD 5xxx or earlier cards. It has been shown by some users to work only with 6xxx and 7xxx series cards.
1. Save backup copy of xorg.conf in case this doesn't work.
sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.BAK

2. Remove/purge current fglrx and fglrx-amdcccle (If you have used a method outside of aptitude, apt, Software Center or Synaptic, follow the other party's instructions for removal.)
sudo apt-get remove --purge fglrx fglrx-amdcccle

For some users, the fglrx-updates and fglrx-amdcccle-updates packages do not work. If you attempted to install them, also do
sudo apt-get remove --purge fglrx-updates fglrx-amdcccle-updates

3. Reboot
4. Download the driver found at the AMD/ATI website
5. Navigate to the directory to which the file was downloaded
cd /path/to/file

6. Make the .run file executable, using the 12.6 driver as an example (modify as needed for future versions. Note that the name of the .run file is for ILLUSTRATION only and you must be sure that you type the name of the actual file correctly.)
sudo chmod +x amd-driver-installer-12-6-x86.x86_64.run

7. Execute the .run file
sudo ./amd-driver-installer-12-6-x86.x86_64.run

Be sure to click "Install Driver" as shown: 
catalyst1.png
8. Create a new xorg.conf
sudo amdconfig --initial

9. Reboot.
10. To confirm the drivers are working open a terminal and type:
fglrxinfo

You should get an output similar to the following:
fglrxinfo 
display: :0  screen: 0
OpenGL vendor string: Advanced Micro Devices, Inc.
OpenGL renderer string: AMD Radeon HD 6300M Series
OpenGL version string: 4.2.11733 Compatibility Profile Context

11. The Catalyst Control Center should now offer a choice between the integrated Intel graphics and the dedicated AMD/ATI graphics. To switch, select the graphics you want to run. Because the change is not dynamic, a reboot is required.
SwitchGraphics.png
12. To uninstall after installing using this method, you MUST use the amdconfig utility:
sudo amdconfig --uninstall


REFERENCES
https://help.ubuntu.com/community/BinaryDriverHowto/ATI

Friday, August 17, 2012

Ubuntu remove flash

SkyHi @ Friday, August 17, 2012

Flash aid fetches the last known flashplayer version give it a go again.
You have made a mistake somewhere along the line. If you have tried to install
it multiple times there might be remnants of flash everywhere. flash aid will
remove them all and install again for you.
Or if you choose remove all flash and install from Ubuntu software center or Synaptic.
Stop all firefox running and copy and paste these one at a time.

Code:
sudo apt-get remove -y --purge flashplugin-nonfree gnash gnash-common mozilla-plugin-gnash swfdec-mozilla libflashsupport nspluginwrapper
Code:
sudo rm -f /usr/lib/mozilla/plugins/*flash*
Code:
sudo rm -f ~/.mozilla/plugins/*flash*
Code:
sudo rm -f /usr/lib/firefox/plugins/*flash*
Code:
sudo rm -f /usr/lib/firefox-addons/plugins/*flash*
Code:
sudo rm -rfd /usr/lib/nspluginwrapper
#Now reinstall through Ubuntu software center or synaptics. Or even as most do to get most all restricted packages in one swoop.
Code:
sudo apt-get install ubuntu-restricted-extras
__________________


REFERENCES
http://ubuntuforums.org/showthread.php?t=1747043

Thursday, August 16, 2012

Ubuntu enable puppet agent

SkyHi @ Thursday, August 16, 2012

STEP 1: INSTALL THE AGENT
1
me@client:~$ sudo aptitude install puppet
An Ubuntu server will tell you all of the packages that must be installed and will give you the option to continue. If you choose to continue, Ubuntu will install all of the packages then warn you that it could not start the puppet agent
1
2
3
4
* Starting puppet agent
 
puppet not configured to start, please edit /etc/default/puppet to enable
   ...done.
which means you need to edit the file the message refers to. So, sudo nano /etc/default/puppet, change
1
2
# Start puppet on boot?
START=no
to
1
2
# Start puppet on boot?
START=yes
and save the file. Once saved, sudo service puppet start.



STEP 2: AUTHENTICATE THE CLIENT
Puppet uses certificates for authentication, so the master is basically a CA who signs certificates from the clients. Unless you tell the client otherwise, it’ll assume that the puppetmaster’s name is puppet, so you either have to handle that with DNS or by editing the client’s puppet.conf. I took the first route, which seemed easier to me.
On the client, we tell it to send it’s certificate to be signed by the puppetmaster by telling it to test:
1
2
3
4
5
6
me@client:~$ sudo puppet agent --test
warning: peer certificate won't be verified in this SSL session
warning: peer certificate won't be verified in this SSL session
warning: peer certificate won't be verified in this SSL session
Exiting; no certificate found and waitforcert is disabled

OR
me@client:~$ puppetd –server puppet.example.com –waitforcert 60 –test
Once that’s done, we have the puppetmaster approve the client’s certificate:
1
2
3
me@puppet:/etc/puppet$ sudo puppetca --list
  new-server.local (6F:47:D1:6B:F3:B0:4B:94:00:92:5E:F7:E5:38:7C:C9)
me@puppet:/etc/puppet$




1
2
3
4
me@puppet:/etc/puppet$ sudo puppetca --sign new-server.local
notice: Signed certificate request for new-server.local
notice: Removing file Puppet::SSL::CertificateRequest new-server.local at '/var/lib/puppet/ssl/ca/requests/new-server.local.pem'
me@puppet:/etc/puppet$
After the client certificate is signed, it’s no longer in the server’s pending list.
1
2
me@puppet:/etc/puppet$ sudo puppetca --list
me@puppet:/etc/puppet$M
At this stage, the client is essentially configured. Within the next 30 minutes, it will contact the puppet master to see if any new or changed catalog items exist for it–if they do, the client will make the changes. If you’re impatient like me, you can force the client to check in by forcing another test:
1
2
3
4
5
6
7
8
me@new-server:~$ sudo puppet agent --test
warning: peer certificate won't be verified in this SSL session
info: Caching certificate for new-server.local
info: Caching certificate_revocation_list for ca
info: Caching catalog for new-server.local
info: Applying configuration version '1330636935'
notice: /Stage[main]//Package[ntp]/ensure: ensure changed 'purged' to 'present'
--- /etc/ntp.conf       2011-09-02 18:42:40.000000000 +0000
Keep in mind that it’s possible that some of the client’s catalog cannot be completed while your user is logged in, depending on what the changes are. For instance, if the catalog for that client changes your user’s UID or GID, you’ll receive an error until your user is no longer logged in.
To be sure that your client is checking in on it’s own, just take a look at it’ssyslog:
1
me@client:~$ sudo more /var/log/syslog | grep puppet-agent
Next time, we’ll take a look at the files that make up a “catalog”.



REFERENCES
http://eison.net/2012/03/puppetmaster-xcvii-getting-your-new-server-registered/ 
http://www.unixmen.com/install-puppet-master-and-client-in-ubuntu/