Tag Archives: Linux

Extend a debian/ubuntu partition on a virtual machine.

This is howto extend a virtual machine drive running Debian / Ubuntu
1. First you need to make sure that there are no snapshot of the VM. If there are snapshot, you can extend the drive in either vmWare or Hyper-V.
2. If the server is running Hyper-v, you can’t extend an IDE drive. If it are an IDE device, you need to turn of the computer first.
3. Make sure that the partition is not an extended partition. If it are you can still extend it, but then this guide won’t work for you. Run fdisk -l /dev/sdX
4. Make sure that the drive is not an LVM storage. Then you can’t used this guide.

The above image, showes that there are an extend partition.

After you have checked, that there are no snapshot, the drive is not an IDE and it the last partition on the drive that needed to extend. Then goes to yours hypervisor and extend the drive, with the amount of storage you will like to have the drive extend with.

Then back on the linux server, install the package cloud-guest-utils, with this command

apt install cloud-guest-utils

Then run these commands:

ls /sys/class/scsi_host/ | while read host ; do echo "- - -" > /sys/class/scsi_host/$host/scan ; done
ls /sys/class/scsi_device/ | while read host ; do echo 1 > /sys/class/scsi_device/$host/device/rescan ; done

This will rescan the SCSI bus for new drive and drive extension.

After you have run the rescan you should extend the partition you want to extend

growpart /dev/sda 2

This commands will extend partition 2 on /dev/sda with the amount of free space on the drive, after partition 2.

After the partition have been extended, you need to extend the filesystem. This can be done by resize2fs

resize2fs /dev/sda2


Expand an EXT4, on a SCSI device

If you have vmware ESXi or Microsoft Hyper-v, you can expand a disk, from the hypervisor console, very simple. But afterwards the partition the servers is not expand.
It is always a good idea to create a Snapshot/checkpoint before. Just remember, that the disc can’t be expanded in Hyper-v when there are a checkpoint. So first expand the disk in Hyper-v and then create a snapshot.

To do this you first need to rescan the disk for change

echo "1" > /sys/class/block/sda/device/rescan

Replace sda with the disk name.
Then you can run fdisk -l /dev/sda, to see the disk information, if you got an error on the top like in the screenshot below

Then you need to repair the disk partition table.

parted -l

After you have check the partition table, you need to delete the old partition, and recreate it

This is done by type fdisk /dev/sda

In the fdisk, you type d to delete, choice the partition, in the example is two. (Beaware that this guide can only be used to expand the last partition on the disk, if you have multiple)
Then you type n to create a new one, and just goes for the default once settings.
In the end type N to not remove the signature.

Then you w to save the settings

Then we just have to resize the ext4 information on the disk, this is done by the command resize2fs

Afterwards you can check that the server have been expand by the command df -h

Here we have expand the disk from 195GB to 295GB.

Linux: Change default IP address on host with multiple IP address

If you have a host with multiple IP address on it, and you need to change witch IP address it present it with on the Internet, you can change the Default IP address, by changing the source IP address on the default route

ip route change default via 192.168.0.254 src 192.168.0.10

Of course the Linux host need to listen on the IP address.
You can see the changes by this command

ip route list
default via 192.168.0.254 dev eth0 src 192.168.0.10

Compiling Linux Kernel 3.6.X the debian/ubuntu way for Hyper-V

Here is a guide to compile a kernel 3.6.X kernel for hyper-v the debian way.

sudo apt-get install git-core kernel-package fakeroot build-essential ncurses-dev

#Download the latest kernel
cd /usr/src
sudo wget --continue http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.6.6.tar.bz2
sudo tar jxvf linux-3.6.6.tar.bz2
cd linux-3.6.6

#Copy kernel config to the new source
sudo cp /boot/config-`uname -r` ./.config

#Choice what you want
#Hyper-V is locate at: Device Drivers, Microsoft Hyper-V guest support
sudo make menuconfig

#Compile the kernel
sudo make-kpkg clean
sudo fakeroot make-kpkg --initrd --append-to-version=-hyperv01 kernel_image kernel_headers
cd ..
sudo dpkg -i linux-image-3.6.*
sudo init 6

Ubuntu and (dot).local addresses – Avahi

I have a Ubuntu server where there was a problem with .local address, i could’t look up the zone from the server.
After a little search i found that Avahi (Zeroconf) was the problem.

The default setup of Avahi, is to look for the zone in mDNS, if that failed the resolv failed.

So to fix this, edit /etc/nsswitch.conf

Change this line
hosts:          files mdns4_minimal [NOTFOUND=return] dns mdns4
To:
hosts:          files dns mdns4_minimal mdns4

Vmware ESX 3.5 and Dell openmanage

First you need to install:
http://www.vmware.com/download/download.do?downloadGroup=VI-RCLI-U2

This is a vmware Remote CLI tools. Install it on a windows machine.
After you install remember to log out and the log in, else you will get some error about libxml.dll cannot be found.

Then download Dell Openmanage  to the same machine that you install Vmware Remote CLI:

http://support.dell.com/support/downloads/format.aspx?c=us&cs=04&l=en&s=bsd&deviceid=2331&libid=36&releaseid=R251021&vercnt=3&formatcnt=0&SystemID=PWE_R710&servicetag=&os=LIN4&osl=en&catid=-1&dateid=-1&typeid=-1&formatid=-1&impid=-1&checkFormat=true

Put the Vmware ESX into maintaince mode.

Put tar.gz file  onto the ESX Host, and the untar the file, and then install the Dell Openmanage

tar zxfv OM_6.2.0_ManNode_A00.tar.gz
cd openmanage
sh setup.sh

Make sure that the Dell openmanage is install on the ESX.

Check if the Dell openmanage is started

/opt/dell/srvadmin/dataeng/bin/dataeng status if not then start it: /opt/dell/srvadmin/dataeng/bin/dataeng start (This commands should be run at the ESX host)

Enable SNMP in the firewall:

esxcfg-firewall -e snmpd
esxcfg-firewall –openPort 1311,tcp,in,OpenManageRequest

On the windows machine where you have install Remote CLI goto folder: C:\Programmer\VMware\VMware VI Remote CLI\bin

vicfg-snmp.pl –server <ESX Host> –username root -c appmanager -p 5567 -t 10.105.2.129/appmanager

vicfg-snmp.pl –server <ESX Host> –username root -E

If you need to test the SNMP traps you can run this command

vicfg-snmp.pl –server <ESX Host> –username root -T