Archive for the ‘Hardware’ Category

Expand LVM in CentOS 6 Running on vCenter

Posted 82 days ago by Alex in Hardware, Software, Technology

This is an update to the post I created back in June of 2011 on how to expand an LVM in CentOS 5.6 running on vCenter. CentOS 6 has made some changes to the way the LVMs are setup so I thought I would update this document accordingly.

  1. Using your vSphere client, increase the size of the disk attached to the VM.
  2. Boot into the CentOS 6 installation disk and select ‘Rescue Mode’ from the list of options.
  3. When prompted to search for LVM partitions on the disk, select ‘Skip’.
  4. Type the following commands at the prompt. The following assume you have a standard CentOS LVM configuration.
    fdisk /dev/sda
    p  # Print partition table
    n  # New partition
    p  # Primary partition
    3  # ID = 3
    # When prompted, add 1 to the end block value for the sda2 partition and use it as the start of the sda3 partition.
    # Use the default for the size which should be the rest of the free space on the disk.
    t  # Change partition type
    3  # Change partition 3
    8e # Type = Linux LVM
    p  # Print partition table
    w  # Write partition table
    
    # Create a new LVM physical volume from the new partition
    lvm pvcreate /dev/sda3
    lvm pvdisplay
    
    # Mount the volume group
    lvm vgscan
    lvm vgchange -ay
    # You will see the name of the volume group that is activated.  Usually something like 'vg_hostname'.
    
    # Extend the volume group with the new physical volume.  Be sure to substitute the name of your volume group in the command below.
    lvm vgextend /dev/vg_hostname /dev/sda3
    
    # Extend the logical volume to include 100% of the free space on the volume group.
    lvm lvextend /dev/vg_hostname/lv_root /dev/sda3
    
    # Mount the volume group
    lvm vgscan
    lvm vgchange -ay
    
    # Run a filesystem check on the newly expanded disk
    e2fsck -f /dev/vg_hostname/lv_root
    
    # Resize the filesystem to use the entire disk
    resize2fs /dev/vg_hostname/lv_root
  5. After rebooting, you can confirm the final size of your disk using:
    df -h

As always, have a backup of your data.

Reconfiguring Network Interfaces in CentOS/RHEL Systems Cloned with vCenter

Posted 189 days ago by Alex in Hardware, Randomness, Technology

While cloning CentOS VMs in our environment, I ran into a problem where eth0 wouldn’t start up. When trying to start the networking service, the following error popped up:

Bringing up interface eth0: Device eth0 does not seem to be preset, delaying initialization.      [FAILED]

The reason this error occurs is because networking adapters in cloned VMs are assigned unique MAC addresses, so they don’t conflict with the parent VM. During OS installation, the installer detects the network adapter and udev configures the mapping between the device eth0 and the MAC address. When the MAC address changes udev thinks the device is missing.

To fix this, we need to update udev’s mapping rules to point the eth0 definition to the device with the correct MAC address. Open the file /etc/udev/rules.d/70-persistent-net.rules. You should see something similar to what is below:

# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

# PCI device 0x8086:0x100f (e1000) (custom name provided by external tool)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:9c:00:16", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x8086:0x100f (e1000) (custom name provided by external tool)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:9c:00:18", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

As you can see there are two PCI ethernet adapters present. The original one from the parent VM (MAC: 9c:00:16) and the new one from the current VM (MAC: 9c:00:18). To fix the issue you need to change the eth0 device definition to have the correct MAC address (9c:00:18) and remove the eth1 device. Your resulting file will look like so:

# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

# PCI device 0x8086:0x100f (e1000) (custom name provided by external tool)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:9c:00:18", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

You’ll also want to update the /etc/sysconfig/network-scripts/ifcfg-eth0 file to reflect the correct MAC address. Then, after a quick system restart your eth0 adapter will be back up.

Enable Remote Disk Browsing on a Mac

Posted 265 days ago by Alex in Hardware, Software, Technology

I recently bought a blu-ray drive for my PC to be able to watch movies and burn blu-ray disks easily. Sadly, Apple doesn’t offer a Mac with a blu-ray drive nor have I found a blu-ray internal drive for Macbook Pros.

One thing that is available for Macs is called ‘DVD or CD Sharing’, also called ‘Remote Disk’. You can find the default instructions on how to set it up over at Apple’s support article. The instructions include how to install the DVD or CD Sharing client on a Windows PC for sharing to a Mac.

What isn’t included in those instructions is the fact that by default, only Macbook Airs and Mac Minis support Remote Disk out of the box. I guess this is because they are the only two Mac models that don’t have optical drives.

Once DVD or CD Sharing has been enabled on a remote system (and the firewalls between the two systems correctly configured), the following two lines will activate the ‘Remote Disk’ option in the Finder window. Run them in a terminal window, then restart your computer.

defaults write com.apple.NetworkBrowser EnableODiskBrowsing -bool true
defaults write com.apple.NetworkBrowser ODSSupported -bool true

After boot, you should see the following options in your Finder.
Screenshot of Finder with Remote Disk devices
Note: My PC has two disk drives shared in the above picture.

Volume group “VolGroup00″ not found woes.

Posted 327 days ago by Alex in Hardware, Software

My attempts to migrate a physical CentOS installation to a Virtual machine were fraught with perils. First, I had to figure out how to actually transfer the data. There are many tools out there that say they can assist in a P2V conversion, but the simplest method is usually the easiest. I ended up going with a good old dd.

  1. First, you’ll want to create the new VM that you’ll be migrating to; we’ll call this the DestinationVM. Just configure the hardware — don’t install an OS.
  2. Next, boot the VM from the CentOS installation disk and enter rescue mode. At the prompt, type
    linux rescue
  3. Configure the network interfaces and when it asks to search for installations, allow it to initialize the disks in the VM. There isn’t an install present, but we need to setup the disks to perform the copy.
  4. When the VM has booted run
    nc -l -p 6501 | dd of=/dev/sda

    This will start the nc daemon and output the data to the /dev/sda disk. Make sure to change the destination disk if it is different than /dev/sda.

  5. On the physical machine run
    dd if=/dev/sda | nc <ip-of-VM> 6501

    Tip: Start the command in a screen session if you might be disconnected from the server during the transfer. It may take a while.

  6. You won’t see anything until the transfer completes. It took 6 hours for a 250GB drive to copy for me. YMMV
  7. Once the transfer is complete, reboot the VM and you should be good to go!

Sadly, when I rebooted the VM, I encountered the following error:

  Reading all physical volumes. This may take awhile...
  Volume group "VolGroup00" not found
Unable to access resume device (/dev/VolGroup00/LogVol01)
mount: could not find filesystem '/dev/root'
setuproot: moving /dev failed: No such file or directory
setuproot: error mounting /proc: No such file or directory
setuproot: error mounting /sys: No such file or directory
switchroot: mount failed: No such file or directory
Kernel panic - not syncing: Attempted to kill init!

This error likely means that the kernel copied from the old physical system doesn’t have drivers to support the disk hardware in the virtual machine. Because of this, the LVM configuration isn’t loading properly. The easiest way to resolve this is to reinstall the kernel using yum.

  1. Boot the VM into the CentOS install CD and at the prompt, type
    linux rescue
  2. Enable and configure networking and allow the mounting of the local installation. Make sure to mount is as read/write — we’ll be making changes to it.
  3. chroot /mnt/sysconfig
    yum remove kernel
    yum install kernel
    exit
    exit

    Note, it’s OK to remove all versions of the kernel. Just make sure you install one before you reboot.

  4. The system will reboot, once it does, let it load into the OS. If everything went OK, your new system will be up and running!

Expand CentOS 5.6 LVM running on vSphere.

Posted 350 days ago by Alex in Hardware, Software, Technology

I spent a while looking for information about how to resize an LVM within CentOS 5.6. After adding additional space to the Virtual disk through the vSphere1, CentOS doesn’t automatically utilize that space. To be able to make use of the extra space, you’ll have to do the following:
Note: These initial steps are required when expanding the size of the root partition. A non-system partition can be expanded without having to restart.

  1. Boot into a CentOS 5 installation disk. At the prompt, type:
    linux rescue
  2. Type the following commands at the prompt. The following assume you have a standard CentOS LVM configuration.
  3. # Create new partition from free space
    fdisk /dev/sda
    p  # Print partition table
    n  # New partition
    p  # Primary partition
    3  # ID = 3
    t  # Change partition type
    3  # Change partition 3
    8e # Type = Linux LVM
    p  # Print partition table
    w  # Write partition table
    
    # Create a new LVM physical volume from the new partition
    lvm pvcreate /dev/sda3
    lvm pvdisplay
    
    # Extend the volume group with the new physical volume
    lvm vgextend /dev/VolGroup00 /dev/sda3
    
    # Extend the logical volume to include 100% of the free space on the volume group.
    lvm lvextend -l+100%FREE /dev/VolGroup00/LogVol00
    
    # Mount the volume group
    lvm vgscan
    lvm vgchange -ay
    
    # Resize the filesystem on the volume group to match the total size of the drive.
    resize2fs /dev/VolGroup00/LogVol00
    

As always, have a backup of your data.

1 Learn about how to resize the virtual disk in VMWare KB Article 1004047.

Installing FreeNAS to a flash drive on a Mac

Posted 451 days ago by Alex in Hardware, Interesting Links, Software, Technology

I’m building a NAS and decided to use FreeNAS to deploy it (rather than buy a hardware solution). The installation instructions were easy enough though they didn’t include instructions on how to install FreeNAS onto a flash drive while running a Mac. I found a 512MB flash drive that was perfectly suitable for the install.
Note: The instructions below include terminal commands. The command is presented with an example of expected output.

  1. Download the latest release of FreeNAS from the downloads page. The version I downloaded was titled ‘FreeNAS-amd64-embedded-0.7.2.5543.img’. Make sure you get the .img file, not the .iso.
  2. Plug your flash drive into your computer and open a new terminal window.
  3. Using diskutil, find the device node for your flash drive:
    mac:~ alex$ diskutil list
    /dev/disk0
       #:                  TYPE NAME                    SIZE       IDENTIFIER
       0: GUID_partition_scheme                        *500.1 GB   disk0
       1:                   EFI                         209.7 MB   disk0s1
       2:             Apple_HFS Macintosh HD            499.8 GB   disk0s2
    /dev/disk1
       #:                  TYPE NAME                    SIZE       IDENTIFIER
       0:                       CDROM                  *512.5 MB   disk1
  4. The flash drive’s device node in the above output is /dev/disk1. Now, unmount the drive:
    mac:~ alex$ diskutil unmountDisk /dev/disk1
    Unmount of all volumes on disk1 was successful
  5. Next, we’ll extract the image’s contents onto the flash drive. Warning: This will delete all of the data off of the drive.
    mac:~ alex$ sudo dd if=~/Downloads/FreeNAS-amd64-embedded-0.7.2.5543.img of=/dev/disk1
    203632+0 records in
    203632+0 records out
    104259584 bytes transferred in 66.608632 secs (1565256 bytes/sec)
  6. Lastly, eject the drive.
    $ diskutil eject /dev/disk1
    Disk /dev/disk1 ejected

Now you can use the flash drive to boot off of and run your FreeNAS instance from. Good times!