Jaime Frutos Morales's blog

17/05/2010

Book Review: Samba 3 by Example

Filed under: Books, Linux, SysAdmin — acidborg @ 20:57

Last week, I finished reading “Samba-3 by Example. Practical exercises in successful Samba deployment” by John H. Terpstra.
Samba 3 by example
What makes this book worth reading is the approach that the author makes to the different configurations of a Samba network depending on the users’ requisites, the available hardware and the expertise of the sysadmin. He starts with a basic Samba installation on a simple network, with a few users and no security and he evolves this study case until it reaches advanced topics like migrations from Windows and NetWare networks to Samba or integrating Samba with Microsoft’s Active Directory).

I strongly recommend this book if you are a Samba sysadmin or you are thinking about deploying Samba on your network, because it contains many tips and ideas to design your Samba network or improve your existing one.

You can download it (PDF format) from here for free.

05/05/2010

The Humble Indie Bundle

Filed under: Linux — acidborg @ 20:17

As I did on this previous post, I’d like to support this cross-platform games initiative called “The Humble Indie Bundle“. It sells 5 cross-platform games (GNU/Linux, Windows, Mac) and you can pay whatever you want for them. You can even choose if you want to donate part of the money (or all of it) to Child’s Play charity or Electronic Frontier Foundation.

I think it’s worth it.

12/04/2010

How to automatically download your favourite TV series on Ubuntu 9.10

Filed under: Linux — acidborg @ 21:00

Description: I’m going to explain how to automatically download your favourite TV shows using showRSS, Transmission and Flexget.

Steps:

  1. Register at showRSS and add your favourite TV series.
  2. Go to the “feeds” section and generate your feed address.
  3. Download the latest transmission-common and transmission-gtk packages from here.
  4. Install them: sudo dpkg -i transmission*.deb
  5. Modify $HOME/.config/transmission/settings.json with the following values:
    "watch-dir": "\/home\/your_user\/Downloads",
    "watch-dir-enabled": true
  6. Go to flexget‘s web and download it.
  7. Install it: sudo easy_install FlexGet*.egg
  8. Edit flexget’s config file: vi $HOME/.flexget/config.yml
    flex's config.yml content
  9. Initialize flexget: flexget --initdb
  10. Edit your crontab to check your feed every hour: crontab -e
    0 * * * * /usr/local/bin/flexget

02/03/2010

How to rebuild a corrupted RPM database in Red Hat Linux

Filed under: Linux, SysAdmin — acidborg @ 18:42

Description: If your system’s RPM database is corrupted, you can try this short recipe to rebuild it before trying to restore it from a backup (NOTE: don’t forget to make a backup of the /var/lib/rpm directory periodically on every Red Hat Linux system!).

Steps:

  1. Remove RPM’s locks (if present): rm -f /var/lib/rpm/__db*
  2. Rebuild RPM’s database: rpm -vv --rebuilddb
  3. Check if it worked: yum update

If this didn’t work, then restore from your backup.

22/02/2010

How to make a live migration of a KVM virtual machine using virsh and SSH

Filed under: Linux, SysAdmin, Virtualization — acidborg @ 14:32

Description: A KVM virtual machine (guest) can be easily migrated from one host to another using virsh and SSH. The goal is to migrate guests without stopping them and with almost no downtime. This is very useful to balance the load among the hosts and to manage maintenance tasks.

Requirements:

  • The guest image must be located on a shared storage and it must be accessible using iSCSI, NFS, GFS2 or Fibre Channel.
  • The shared storage must be mounted on the same path on both hosts.
  • Both guests must run the same version of KVM.
  • Both guests must have the same network configuration and bridging configuration (their IPs must be different, of course).

Steps:

  • Verify that the guest is running on the source host: virsh list
    Id Name State
    -----------------------------
    1 test_guest running
  • Migrate the guest: virsh migrate --live test_guest qemu+ssh://destination_server/system
  • If you haven’t shared a pair of SSH keys between the hosts (highly recommended), enter the password.
  • Wait until the migration is completed (the guest will continue running until the end of the process).
  • Verify that the guest is running on the destination host: virsh list
    Id Name State
    -----------------------------
    1 test_guest running

19/02/2010

How to manage KVM virtual machines using virsh

Filed under: Linux, SysAdmin, Virtualization — acidborg @ 13:17

Description: virsh is a program which uses libvirt to manage KVM virtual machines (guests). I’m going to show a summary of its main functions (cheat sheet style):

Show guests’ information:

  • Show a list of all the defined guests: virsh list --all
  • Show a guest’s info: virsh dominfo guest's_name

Start and stop guests:

  • Start a guest: virsh start guest's_name
  • Shutdown a guest (gently): virsh shutdown guest's_name
  • Shutdown a guest (wild): virsh destroy guest's_name
  • Suspend a guest: virsh suspend guest's_name
  • Resume a suspended guest: virsh resume guest's_name

Create and modify guests:

  • Create a new guest
  • Create a guest from its XML definition: virsh create xml_file.xml
  • Dump a guest’s definition in XML: virsh dumpxml guest's_name
  • Modify a guest’s definition: virsh edit guest's_name
  • Remove a guest’s definition (it doesn’t remove the image file): virsh undefine guest's_name

Backup and restore guests:

  • Save a guest’s state on a file: virsh save guest's_name guest's_state_file
  • Restore a guest from a state file: virsh restore guest's_state_file

I’m going to explain guests live migration on another post to keep this cheat sheet simple.

18/02/2010

How to create virtual machines using KVM (Kernel-based Virtual Machine)

Filed under: Linux, SysAdmin, Virtualization — acidborg @ 14:24

Description: KVM is a virtualization infrastructure included in the Linux kernel since 2.6.20 . Although it supports some kinds of paravirtualization, I’m going to explain how to create virtual machines /also called guests) using its full virtualization support.

Steps:

  1. Check if your processor supports full virtualization (if either vmx or svm appears as a flag, then your processor supports it): egrep '(vmx|svm)' --color=always /proc/cpuinfo
  2. Install the packages needed:
    • Debian/Ubuntu: apt-get install kvm libvirt0 python-libvirt python-virtinst
    • Red Hat/Fedora: yum install kvm libvirt libvirt-python python-virtinst
  3. Configure a bridge (Debian/Ubuntu or Red Hat/Fedora) to use a single network interface for all your virtual machines.
  4. Create the virtual machine (a RHEL 5 virtual machine in this example): virt-install --name=guest_name --arch=x86_64 --vcpus=1 --ram=512 --os-type=linux --os-variant=rhel5 --hvm --connect=qemu:///system --network bridge:br0 --cdrom=/var/lib/libvirt/images/rhel5-x86_64.iso --disk path=/mnt/virtual_machines/guest_name.img,size=20 --accelerate --vnc --noautoconsole --keymap=es
    Explanation of the params:

    • name: name of the guest.
    • arch: architecture of the guest.
    • vcpus: number of CPUs assigned to the guest.
    • ram: MB of RAM assigned to the guest.
    • os-type and os-variant: available options can be checked using man virt-install.
    • hvm: use full virtualization.
    • connect: connect to the hypervisor.
    • network bridge: the bridge to use for the guest.
    • cdrom: the ISO of the operating system to install.
    • disk path=x,size=y: path and size of the image file for the guest.
    • accelerate: make use of the KVM acceleration capabilities if available.
    • vnc: export a virtual console over VNC to the guest.
    • noautoconsole: Don’t automatically try to connect to the guest console.
    • keymap: keyboard layout for the VNC console
  5. Use a VNC client to connect to the guest (port 5900 or 5901 if you already have a VNC server listening on port 5900) and install the operating system.

I’ll write another post soon explaining all the operations which can be done with KVM virtual machines using virsh.

29/01/2010

How to reduce a logical volume in GNU/Linux using LVM

Filed under: Linux, SysAdmin — acidborg @ 14:01

Description: previously, on this post, I explain how to extend a logical volume using LVM. Now, I’m going to explain how to reduce it without data loss (if you aren’t using all the available space, of course). In this example, I’m going to reduce a logical volume called logical_volume1 belonging to the volume group volume_group1 to 85 Gb of disk space. It’s mounted on /mnt/logical_volume1 .

Steps:

  1. Umount the logical volume: umount /mnt/logical_volume1
  2. Make a backup of the logical volume
  3. Check the filesystem integrity: fsck -f -y -v /dev/volume_group1/logical_volume1
  4. Resize the filesystem to something smaller than the final size (around 80GB in this case): resize2fs /dev/volume_group1/logical_volume1 80000M
  5. Check the filesystem integrity again: fsck -f -y -v /dev/volume_group1/logical_volume1
  6. Reduce the logical volume: lvreduce -L 85G /dev/volume_group1/logical_volume1
  7. Resize the filesystem to fit the logical volume: resize2fs /dev/volume_group1/logical_volume1
  8. Check the filesystem to know whether the reduction went fine: fsck -f -y -v /dev/volume_group1/logical_volume1
  9. Mount the logical volume: mount /mnt/logical_volume1

NOTE: if you aren’t careful with the disk space you are using and the final disk space you are going to be using, this operation can cause data loss. I recommend to backup the logical volume before the reduction and to use around 5GB of “safe space” while reducing the filesystem in order to avoid data loss.

27/01/2010

How to backup a logical volume (snapshots) using LVM

Filed under: Linux, SysAdmin — acidborg @ 11:19

Description: a snapshot is a copy of the state of a logical volume at a particular point. It’s created almost immediately, so it’s very useful to backup large logical volumes. In this example, I’m going to create a snapshot of a logical volume called logical_volume1 beloging to the volume group volume_group1.

Steps:

  1. Check the size of the logical volume (LV Size): lvdisplay /dev/volume_group1/logical_volume1
    --- Logical volume ---
    LV Name /dev/volume_group1/logical_volume1
    VG Name volume_group1
    LV UUID AxihqP-Yt8l-5scY-bXNG-Bn5D-K3ms-X7v1Ys
    LV Write Access read/write
    LV Status available
    # open 1
    LV Size 200,00 GB
    Current LE 6400
    Segments 2
    Allocation inherit
    Read ahead sectors auto
    - currently set to 256
    Block device 253:5

    Usually, snapshots are smaller than the original logical volume, but I recommend to use at least the same space.

  2. Create the snapshot: lvcreate -L200G -s -n backup_logical_volume1 /dev/volume_group1/logical_volume1
  3. The -s param tells lvcreate to create a snapshot instead of a normal logical volume.

25/01/2010

How to extend a logical volume in GNU/Linux using LVM

Filed under: Linux, SysAdmin — acidborg @ 13:54

Description: if you have created a logical volume (maybe following my previous post) and you want to increase its size (if you have enough physical space, of course), LVM can do that easily. In this example, I’m going to extend a logical volume called /dev/volume_group1/logical_volume1 mounted on /mnt/logical_volume1 adding 50GB of disk space which are available in the volume group volume_group1.

Steps:

  1. Unmount the logical volume if it’s mounted: umount /mnt/logical_volume1
  2. Extend the logical volume with 50GB: lvextend -L +50G /dev/volume_group1/logical_volume1
  3. Check the volume group: e2fsck -f /dev/volume_group1/logical_volume1
  4. Resize the filesystem on the logical volume (ext3 in this case): resize2fs /dev/volume_group1/logical_volume1
  5. Mount the logical volume again: mount /mnt/logical_volume1

Extending a logical volume it’s a safe operation which doesn’t involve much downtime. This is one of the many advantages of using LVM to manage disk storage.

« Newer PostsOlder Posts »

Create a free website or blog at WordPress.com.