Skip to main content

Posts

Adding a new EBS to EC2 and move /var to new EBS

To follow the previous blog article, what if we need to extend /var by moving it to another partition? The following article outlines the key steps. Meanwhile, I found some of the steps are only required if you have SELINUX enabled. The key steps are: 1) Launch a new EBS, choose SSD for speed, or HDD for higher volume. 2) Attach the EBS to the server instance. 3) Login via SSH client. 4) fdisk /dev/xvdf - Note when you provision a new EBS and attach it to EC2, it will say it will rename automatically to /dev/xvdf through /xvdp 5 )mkfs -t ext4 /dev/xvdf1 - format new partition for Linux use 6) mount /dev/xvdf1 /mnt - mount it at /mnt 7) shopt -s dotglob - copy files from /var to /mnt rsync -aulvXpogtr /var/* /mnt 8) umount /mnt - unmount 9) Edit /etc/fstab /dev/xvdf1   /var       ext4    defaults,noatime,nofail 0   2 10) mv /var/ /var.old - change the original to become a backup 11) mkdir /var - re-create the /v...

Resizing & Extending EC2 root partition - live

The EC2 standard EBS is 8G. Planning a simple single EBS instance, the EBS will also contain / and root partition. Following the steps in http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/recognize-expanded-volume-linux.html, we can expand the EBS without stopping the instance. The key steps: 1) Login to AWS Console, locate the EBS and modify the volume size - there is no need to stop the instance (if you are using the current generation of EC2 and EBS - as of Oct, 2017) 2) SSH to the EC2 3) Run lsblk - you will see xvda / xvda1 with different sizes, meaning you need to resize the partition before you can expand the volume 4) Resize the partition - growpart /dev/xvda 1  (note the space between xvda and 1) 5) The resize the filesystem - resize2fs /dev/xvda1 There are other posts saying stopping the instance, and use parted and gdisk. In our case, it is not necessary. There are disadvantages of a using single EBS scenario, but the beauty is that OS/...

ISPConfig update

Trying to update from older version of ISPConfig 3.x to 3.1. After executing the command: ispconfig_update.sh The upgrade went smooth but upon returning to the login screen, it won't proceed further (it redirects back to the login screen after inputting a pair of valid username and password.) First, try quitting and relaunching the browser (or test with another one). If failed, following these steps: Try re-installing from the source: cd /tmp wget http://www.ispconfig.org/downloads/ISPConfig-3-stable.tar.gz tar xfz ISPConfig-3-stable.tar.gz cd ispconfig3_install/install/ php -q install.php Note during the prompt asking if you want to reconfigure the database, choose "yes".

Install SSL for webmin at Ubuntu 14.04LTS

Webmin has its own webserver called miniserv and default to port 10000. To install a valid SSL, following these steps: 1) Create a file called miniserv.pem by combining the server cert and the key in a single file. A simple concat will do. 2) Copy the CA bundle file to the webmin directory (or you can skip it if it has been installed somewhere) 3) Modify the miniserv.conf file: extracas=/etc/webmin/[CA bundle file name] keyfile=/etc/webmin/miniserv.pem 4) Restart webmin Service stop webmin Service start webmin

Email extract script for mbox

Problem: To extract e-mail address of the incoming mail. Analysis: 1. The e-mail address are stored in .mbox format in macOS. The .mbox for Mac is essentially an archive (can be opened and what is useful in this exercise is the file called filename .mbox). It is a .txt file. 2. Email have standard header info which contains the sender information. e.g. an e-mail header would look something like this: (information masked for privacy) From sender@example.com Fri Dec 16 00:11:30 2016 Delivered-To: recipient@domain.com Received: by IP address with SMTP id hm4csp533342wjb;         Fri, 16 Dec 2016 00:11:30 -0800 (PST) X-Received: by 10.157.51.53 with SMTP id f50mr1243482otc.34.1481875890678;         Fri, 16 Dec 2016 00:11:30 -0800 (PST) Return-Path: Received: from gateway21.websitewelcome.com (gateway21.websitewelcome.com. [IP address])         by mx.google.com with ESMTPS id r12...

Ubuntu 16.04 and ISPConfig 3.1 - stopping ClamAV

ClamAV requires quite a bit of resources to run in the background and this usually slows down the mail delivery. In the ISPConfig 3 (Under Perfect Server setup), clamAV is run within Amavis. Therefore, typical removal of clamAV commands will not remove it. When RAM is really low, Linux kills amavis and this will cause mail not being delivered. Therefore, if we run amavis to manage anti-virus and spam, consider a minimum of 2G or 4G RAM VM/Cloud servers. The steps to disable clamav and amavisd are: (1) edit postfix conf - note amavis uses a special port 10024 and 10026. Therefore, if you are not using these ports, consider closing them in your firewall settings. nano /etc/postfix/main.cf # content_filter = amavis:[127.0.0.1]:10024 # receive_override_options = no_address_mappings (2) Under ISPConfig 3.1, comment additional 2 lines nano /etc/postfix/tag_as_foreign.re # /^/ FILTER amavis:[127.0.0.1]:10024 nano /etc/postfix/tag_as_originating.re # /^/ FILTER amavi...

Change hostname Debian Linux

To permanently change the hostname of a Debian Linux machine, perform these steps: 1) nano /etc/hostname 2) nano /etc/hosts 3) /etc/init.d/hostname.sh start If the server has other things that requires update, such as mail server, be sure to edit the config files as well. For example, if there is Postfix, edit the following: /etc/mailname /etc/postfix/main.cf Then execute: /etc/init.d/postfix restart Update: Under Ubuntu Linux 16.04LTS with Aliyun (Alibaba Cloud), use: hostnamectl set-hostname "your FQDN" service hostname restart is not necessary in this case.