How to increase space on a Ubuntu boot partition

When trying to install programs on my Ubuntu server but the server is not allowing me to do that because the boot partition ‘/dev/sda1’ is full. 100% used of 464M

/dev/sda1       236M   236M  0M  100% /boot

How can I increase the space on that partition?

By default Ubuntu has a small /boot partition. When you have auto updates enabled this can cause some issues as newer kernels are not automatically purged.

You can add the following to your crontab to run every Sunday night at 11:30PM to clean out old kernels. You can do so by running crontab -e as root and adding the following line at the bottom of that file.


30 23 * * 6 apt-get autoremove

You will also want to reboot every so often so newer kernels are being used and newer kernels are not causing the issues. I would suggest rebooting at your earliest convenience and running


# apt-get autoremove 

to load the newest kernel and delete the older kernels already installed on your server.

However, once rebooted and the autoremove command is done more disk space will be free.

Info

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            990M  4.0K  990M   1% /dev
tmpfs           201M  716K  200M   1% /run
/dev/dm-0        15G  1.9G   12G  14% /
none            4.0K     0  4.0K   0% /sys/fs/cgroup
none            5.0M     0  5.0M   0% /run/lock
none           1001M     0 1001M   0% /run/shm
none            100M     0  100M   0% /run/user
/dev/sda1       236M   72M  152M  32% /boot

$ du -shcx /boot/*
1.2M /boot/abi-3.16.0-30-generic
1.2M /boot/abi-3.16.0-77-generic
169K /boot/config-3.16.0-30-generic
169K /boot/config-3.16.0-77-generic
6.7M /boot/grub
21M /boot/initrd.img-3.16.0-30-generic
21M /boot/initrd.img-3.16.0-77-generic
du: cannot read directory ‘/boot/lost+found’: Permission denied
12K /boot/lost+found
174K /boot/memtest86+.bin
175K /boot/memtest86+.elf
176K /boot/memtest86+_multiboot.bin
3.4M /boot/System.map-3.16.0-30-generic
3.4M /boot/System.map-3.16.0-77-generic
6.1M /boot/vmlinuz-3.16.0-30-generic
6.2M /boot/vmlinuz-3.16.0-77-generic
70M total

	

Downgrade PHP 7 to PHP 5.6 on Ubuntu 16.04 Xenial

How to install PHP 5.6 on Ubuntu 16.04 Xenial and replace php 7. Let’s assume you have a fresh Ubuntu 16.04 server.

Install add-apt-repository:


# sudo apt-get install python-software-properties

Add repository for PHP 5.6:


# sudo add-apt-repository -y ppa:ondrej/php

Update package lists:


sudo apt-get update


Install php5-fpm:


# sudo apt-get install php5.6-fpm

Check the result:


# php -v
PHP 7.0.4-7ubuntu2.1 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies


Run the following:

# sudo mv /usr/bin/php /usr/bin/php7
# sudo mv /usr/bin/php5.6 /usr/bin/php

Check again


# php -v
PHP 5.6.23-2+deb.sury.org~xenial+1 (cli) 
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies

Restart Apache

# service apache2 restart

Install Apache, Mysql and PHP on Ubuntu 14.04

How to install Apache, MySQL and PHP on Ubuntu 14.04

Update

# sudo apt-get update

Apache

# sudo apt-get install apache2

Install MySQL

# sudo apt-get install mysql-server php5-mysql
# sudo mysql_install_db
# mysql_secure_installation

Install PHP

# sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt

Restart Server

# sudo /etc/init.d/apache2 restart

Check Apache

Open a web browser and navigate to http://IPADDRESS. You should see a message saying It works!

Check PHP

# php -r 'echo "\n\nYour PHP installation is working fine.\n\n\n";'

Plesk autoinstaller GPG error on Ubuntu 14.04 Trusty

Getting error for Plesk auto installer on Ubuntu 12 Trusty:


Reading package lists...
W: GPG error: http://autoinstall.plesk.com trusty InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 227C38D6AF741DEB
W: GPG error: http://autoinstall.plesk.com trusty InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 227C38D6AF741DEB
W: GPG error: http://autoinstall.plesk.com trusty InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 227C38D6AF741DEB
W: GPG error: http://autoinstall.plesk.com trusty InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 227C38D6AF741DEB
W: GPG error: http://autoinstall.plesk.com trusty InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 227C38D6AF741DEB
Gathering information about installed license key...
Checking whether the package dependencies are resolved.
E: Unable to correct problems, you have held broken packages.
---X--- `apt-get` output ---------------------
Reading package lists...
Building dependency tree...
Reading state information...
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
plesk-base : Depends: sw-engine (>= 2.13.9) but it is not going to be installed
plesk-core : Depends: libmyodbc but it is not installable
Depends: pigz but it is not installable
plesk-php56-dba : Depends: libdb5.1 but it is not installable
plesk-php56-imap : Depends: libc-client2007e but it is not installable
plesk-php56-mcrypt : Depends: libmcrypt4 but it is not installable
plesk-service-node-utilities : Depends: libxml-dumper-perl but it is not installable
Depends: sysv-rc-conf but it is not installable
pp12.0.18-bootstrapper : Depends: sw-engine (>= 2.0) but it is not going to be installed
psa-courier-imap : Depends: libdb5.1 but it is not installable
Depends: libssl0.9.8 but it is not installable
psa-php5-configurator : Depends: php5-imap but it is not installable
psa-updates : Depends: sw-engine (>= 2.13.12) but it is not going to be installed

Check following:

1. /etc/apt/sources.list

2. uncomment the deb repos listed as universal/multiverse

3. re-run apt-get update

4. re-run plesk installer

I have also noticed that it tends to give an error about the hostname as well, which I resolved by temporarily setting the hostname to pretty much anything, such as newserver.

Other Information: http://forum.odin.com/threads/plesk-autoinstaller-gpg-error.332686/

Change Date for Ubuntu Server

Check your current timezone by just running


# date
Thu Mar 21 18:02:49 MST 2012

Or checking the timezone file at


# more /etc/timezone
US/Arizona

So to change it just run


$ sudo dpkg-reconfigure tzdata

And follow on screen instructions. Easy.

Also be sure to restart cron as it won’t pick up the timezone change and will still be running on UTC.

# /etc/init.d/cron stop
# /etc/init.d/cron start

A chkconfig alternative to Ubuntu

sysv-rc-conf is an alternate option for Ubuntu.


# sudo apt-get install sysv-rc-conf


# sysv-rc-conf --list xxxx

Also, to disable a process at boot, you could simply disable it by:

# sudo update-rc.d apache2 disable

and then if you would like to enable it again:


# sudo update-rc.d apache2 enable

Add resolvers to ubuntu server


sudo nano /etc/network/interfaces


# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static 
address ipAddress 
netmask 255.255.255.0 
gateway gatewayIP 
dns-nameservers 69.64.66.11 69.64.66.10

Once you have entered the values correctly, press Ctrl+Enter to save it with the current filename, then press Ctrl+X to exit the editor.

Provided you entered your values correctly, verify the new settings by retyping the cat command:


cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static 
address 123.45.67.89
netmask 255.255.255.0 
gateway 123.45.67.1 
dns-nameservers 8.8.8.8 8.8.4.4

Apply setting to Interface

After you have determined the values entered are correct, restart networking with the following command:


sudo service networking restart
stop: Unknown instance: 
networking stop/waiting
administrator@ubuntu:~#

Verify it works
To verify the resolvers are working, simply ping a known domain.


ping google.com
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_req=1 ttl=45 time=42.1 ms
64 bytes from 8.8.8.8: icmp_req=2 ttl=45 time=42.2 ms
64 bytes from 8.8.8.8: icmp_req=3 ttl=45 time=42.0 ms