Category Archives: Kubuntu

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

Kubuntu – Blankpage / hang after logon

Today I have a problem with my Kubuntu, that after i have apply my password for my user, I just got a blank page, only with the standard background of Kubuntu.

I found that I couldn’t start KDE, with the command startkde in the console, I don’t know how, but i was missing the apt-get packet name “kde-workspace-bin”

So I run this command:

sudo apt-get install kde-workspace-bin

Tips:  You can get into the console but holding down the following keys: CTRL ALT F1