Category Archives: Debian

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

Error while Installing the Client Agent on Ubuntu and Debian Linux – unexpected operator

Errors like this:

/opt/CA/ABuagent/uagentsetup: 74: [: -e: unexpected operator
/opt/CA/ABcmagt/caagent: 60: cd: can’t cd to /nls
/opt/CA/ABcmagt/caagent: 60: cd: can’t cd to /nls
/opt/CA/ABcmagt/caagent: 60: cd: can’t cd to /nls
/opt/CA/ABcmagt/aglang_setup: 60: [: -e: unexpected operator
/opt/CA/ABcmagt/caagentsetup: 54: [: -e: unexpected operator

While installing CA Arcserve R16.5, can be resolve by changing /bin/sh linking from dash to bash.

You can check the linking of /bin/sh, with this commands:

ls –l /bin/sh

If you get:

lrwxrwxrwx 1 root root 4 Feb  7 19:41 /bin/sh -> dash

You have this problem.
Change the linking is easy, just reconfigure dash

dpkg-reconfigure dash

Select No, to Install dash as /bin/sh

Once this is changed you should be able to install the agent or start the agent fine.

 

 

 

 

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