Expand Hard Disk VMWare Linux (Debian)

I had Nagios running on a VM and the primary partition had almost no space left. Here the steps I had to do to expand the Partition.

1. Prepare the VM
1. Shutdown VM
2. Remove all Snapshots (Otherwise you can’t expand the HD)
3. Expand the Hard Drive
4. Make a Snapshot again in case something goes wrong

2. Check the State
Show all partitions and note the infos somewhere

fdisk -l

3. Find out the Start and the End Sector of the unallocated Space
Well the only way I found out was was actually to create an additional partition.

1. fdisk /dev/sda
2. n (new partition)
3. p (primary)
4. 3 (free number)
5. Enter (Note the default Start Number)
6. Enter (Note the default End Number)
7 w (To write/save it)

And now it looked like this and from the /dev/sda3 can I see now the last sector which is 5221:

First of all I didn’t understand why are the sectors from /dev/sda2 and /dev/sda5 overlapping. After some research it made sense because without and extended partition there would be a limit of just 4 primary partitions. This means that the /dev/sda2 is actually the container of the logical partition /dev/sda5.

Secondly I didn’t want to have a seperate partition /dev/sda3, instead I wanted to expand the /dev/sda1. But this is going to be a problem because we would need the sectors next to it and this would be overlapping with /dev/sda2 and /dev/sda5.

So with all previous information it is now easy to calcualte all Start and End Sectors of the partitions and the result should look like this

4. Repartition Everything
Now to get the result above we need to repartition everything.

1. First of all we need to switch off swapping so that the partiton /dev/sda2 and /dev/sda5 can be deleted
swapoff -a
2. fdisk /dev/sda
3. Delete all partitions even the /dev/sda1
d (Trough all numbers)
4. Recreate all partitions with the Start and End Sectors we calculated. /dev/sda1 should be a primary and the /dev/sda2 an extended. Then add the /dev/sda5 which is a logical in /dev/sda2.
n
5. With the /dev/sda5 I changed the Partition ID to SWAP
t
82
6. Save it
w

Switch swapping back on swapon /dev/sda5

4. Make sure the Kernels takes modified partition table into account
Now the partition table has been modified but the Kernel doesn’t take it to account yet.

partx /dev/sda

This command should fix this but I also rebooted the machine.

5. Finally expand the Partition
resize2fs /dev/sda1

Now you should have it. You can check the result with df.

No Comments »

admin on January 5th 2018 in IT, Linux

Detecting and Mounting CD-Rom in Debian

apt-get install cdrskin
cdrskin –devices
mkdir /mnt/cdrom
sudo mount /dev/sr0 /mnt/cdrom

No Comments »

admin on August 3rd 2016 in IT, Linux

Install OwnCloud on Debian

I already made once a tutorial how to install OwnCloud on Debian. But since then you can find it in the repository of aptitude and is therefore much easier to install.

  1. apt-get update
  2. apt-get install owncloud
  3. apt-get install mysql-server mysql-client
  4. Create DB and User
    mysql –u root –p
    CREATE DATABASE owncloud;
    CREATE USER owncloud@localhost IDENTIFIED BY ‘password’;
    GRANT ALL PRIVILEGES ON owncloud.* TO owncloud@localhost;
    flush privileges;
    quit
  5. Create Directories
    mkdir /var/owncloud
    chown www-data:www-data /var/owncloud
    chmod 750 /var/owncloud
  6. Run owncloud
    http://yourip/owncloud/
  7. Username: owncloud
    Password: Password you have picked for the DB.
    DB Name: owncloud
    Hostname: localhost
  8. Activate HTTPS
    a2enmod ssl
    a2ensite default-ssl
    service apache2 restart

After that you just need to install the OwnCloud clients on your devices and then you are ready to go.

No Comments »

admin on August 1st 2016 in Cloud, Internet, IT, Linux

How to install NTP on Linux Debian

#apt-get install ntp

Edit the config file to adjust it:
#vi  /etc/ntp.conf

Restart the service to make it run:
#service ntp restart

Manual Sync:
#ntpd -q –g

To overwrite the HW Clock:
#hwclock –systohc

No Comments »

admin on June 29th 2012 in IT, Linux

Upgrade Problem with nagios from lenny to Squeeze in debian

Because lenny is no longer supported I had to upgrade our nagios monitor server from lenny to squeeze. After the upgrade the check_snmp commands timed out. After some research I found out because of a licensing issues snmpd with the mibs are no longer installed by default.

1. Edit Source List
First I had to change the /etc/apt/source.list and add “contrib non-free”.

It should look similar to this:
deb http://ftp.ch.debian.org/debian/ squeeze main contrib non-free
deb-src http://ftp.ch.debian.org/debian/ squeeze main contrib non-free

2. Install SNMPD with the MIB List
#apt-get install snmpd
#apt-get install snmp-mibs-downloader

3. Download Mibs
#/usr/bin/download-mibs

4. Restart SNMPD
I’m not sure if this step is necessary. I actually even restarted the whole server.
#/etc/init.d/snmpd restart

No Comments »

admin on April 26th 2012 in IT, Linux

Manage Users in Debian

Create Groups
# group add finance
# group add development
# group add others

Create User and Assign to Groups
# useradd –m –g finance –G development,others –s /bin/csh testuser

Information about a User
# id testuser
# groups testuser

Modify and Delete a User
# usermod testuser
# userdel –r testuser

Deactivate User Account
# usermod –L testuser

Switch to a user and move to home directory
# su – testuser

Set a Password for a User
# passwd testuser

Set Password Policies
# chage testuser

User, Groups and Password Database
# /etc/passwd
# /etc/groups
# /etc/shadow

Template Directory for Home Folder
# /etc/skel/

No Comments »

admin on April 29th 2010 in Linux

Turn Off Annoying Bell in Debian

Edit the file with vim:
# vi /etc/inputrc

Remove comment:
set bell-style none

Or I prefer actually to have it visually displayed:
set bell-style visible

After that you need to restart debian.

No Comments »

admin on April 21st 2010 in Linux

Get services to start up in Linux

Add Service with default runlevels:
# update-rc.d apache2 defaults

Add Service with custom runlevels:
# update-rc.d apache2 start 50 2 3 4 5 . stop 50 0 1 2 3 4 5 6 .

Remove Service:
# update-rc.d -f apache2 remove

More Infos you can get here:
http://www.debuntu.org/how-to-manage-services-with-update-rc.d

No Comments »

admin on February 24th 2010 in General

Install VMWare tools in debian

1. Install Kernel Heaeders

  1. Get the Kernel version and remember it with:
    uname-r
  2. apt-get install linux-headers-[Kernel Version]

2. Install VMWare Tools

  1. Choose “install and upgrade VMWTools in VMWare” in your VM menu
  2. mount /dev/hda /media/cdrom
  3. cd /media/cdrom/
  4. cp VMWareTools[whateverversion]tar.gz /tmp/
  5. cd /tmp
  6. tar xvzf VMWareTools[whateverversion]tar.gz
  7. umount /media/cdrom/
  8. cd /tmp/vmware-tools-distrib/
  9. make a symlink:
    ln –s /usr/src/linux-headers-[Kernel Version] /usr/src/linux
  10. apt-get install gcc-4.1
  11. change using gcc version:
    export CC=/usr/bin/gcc-4.1
  12. I had make and killall missing on my installation so can you get it:
    apt-get install psmisc make
  13. ./vmware-install.pl

3. Uninstall VMWare Tools
After a failed installation of VMWare Tools I got following message:
A previous installation of VMWare Software has been detected… You may want to re-install VMWare Tools.

The solution was to run the uninstaller first and run the VMWare setup again:
1. ./vmware-uninstall.pl

No Comments »

admin on February 2nd 2010 in Linux, VMWare

Set Date/Time in Debian

Linux

Important: use two “-” before set!

No Comments »

admin on January 28th 2009 in Linux




Check out new movies online website. Download and buy movies now.
12