Creating a software RAID on Ubuntu/Debian

Creating a software raid of disks is quite easy in Ubuntu, I will assume the disks are attached (physically or virtually) to the guest operating system.

Currently Ubuntu supports the following raid levels:

  • RAID level 0
  • RAID level 1
  • RAID level 2
  • RAID level 3
  • RAID level 4
  • RAID level 5
  • RAID level 6
  • RAID level 10
  • RAID level 50
  • RAID level 0+1

In this example I am using sdb1 and sdc1 disks and settings the raid to a mirror (1) with a total mirrored size of 4TB (3906885440K)

  • Install mdadm (if not already installed)

  • Run mdadm to create the mirror

  • Run mkfs.ext3 to create a ext3 filesystem on the mirror volume

  • Mount the mirror by creating a mount point and running mount to mount the md0 volume

  • Check to see if you can see the mirror

  • Check the status of the build

  • Add to fstab to auto mount on startup

Should you have any questions, comments or suggestions, please don’t hesitate to comment below. If you like what you have read, please share it on your favourite social media medium.

VMware Creating RDMs from Locally Attached SATA Disks

I recently had to connect two 4TB sata disks to a server to provide some raw storage to the network. Going on past experiences I didn’t want to virtualise the disks but rather present them to the virtual machine guest as a raw device mapping (RDM).

You will need a separate datastore that is separate to the ones you are attaching. It will have to be VMFS5 to get around the 2TB limit with VMFS3.

Note: This is not supported by VMware to the best of my knowledge.

Procedure

  1. Start a SSH session to the VMware ESX host (or if on the physical server, drop to console)
  2. Run fdisk to see the disk layout.

  1. You will need to find the vml identifier, you need to match that to the drive.

In my example, the two I am interested in are:

vml.01000000002020202020202020202020205a33303346325742535434303030

vml.01000000002020202020202020202020205a33303351523246535434303030

  1. Now browse to the VMFS5 datastore you will be creating the RDM’s

  1. Best practise would be to create a folder for the RDM’s to sit in

  1. Create the RDM’s by running the vmkfstools command (use the vml. location that you found in previous steps)

  1. Verify you have the files created

  1. Attach to virtual machine

Should you have any questions, comments or suggestions, please don’t hesitate to comment below. If you like what you have read, please share it on your favourite social media medium.

Limit SSH connections geographically

There is a real security risk to leaving your shell connection ports exposed to the internet especially if you don’t ever intend on connecting from Zimbabwe as well as other random countries.

This can limit brute force attack exposure and also save valuable resources and bandwidth by rejecting a packets before a tcp handshake.

Install GeoIP

You will need to implement a database that can be queried locally that stores IP ranges to countries.

Query GeoIP database

The script

Past the following in:

Enable script

Lock down SSH

Setup a deny all for the ssh daemon

Add the following into the deny file

Enable the script in the allow ssh file

Add the following into the allow file

Testing

Test the script by inputting the script name and then an IP afterwards

Should output something like the following:

Update GeoIP

There is only one constant with the world and that is change, IP addresses are no exception.

Create a new file called update_geo.sh in /scripts

Add the following into the file

Change the script to execute

Edit the crontab

Paste the following at the bottom of the crontab

Adding Colour to Linux Bash Shell

If the standard black and grey makes you feel uninspired, you can change this by adding two lines to your .bashrc file in the users profile.

1. Edit the .bashrc file

2. Add the following lines

Should you have any questions, comments or suggestions, please don’t hesitate to comment below. If you like what you have read, please share it on your favourite social media medium.

Install MediaWiki on Apache with mySQL

From MediaWiki site: MediaWiki is a free software open source wiki package written in PHP, originally for use on Wikipedia.

I decided to give MediaWiki a try as a scripts repository so I thought I’d write a quick guide of how to install it on a Linux/Apache/mySQL server.

Assumptions

  • A fully qualified domain name with a host record pointing to a internet facing server
  • A fully working Linux server (my example is a Debian server)
  • Apache installed on the Linux server and listening on port 80
  • A preconfigured vhost
  • PHP installed
  • mySQL server installed

Installation

1. Download the compressed installation file

2. Extract the compressed archive

3. Copy files from mediawiki-1.23.5 folder to the root folder

4. Create mySQL Database

5.  Create mySQL Database user

6. Grant database permissions to database

7. Flush mySQL privileges

8. Log into the site eg:

http://wiki.example.com

Click on “Complete the installation”

9. Select the language

10. Click continue

11. Input all database information

12. Change settings to suit your database requirements

13. Input name of MediaWiki and desired credentials

14. Configure options for your MediaWiki

15. Install MediaWiki

16. Installation complete

17. Download and copy the LocalSettings.php file to the root of the MediaWiki installation

18. Browse to your MediaWiki installation and log in

Example: http://wiki.example.com

Should you have any questions, comments or suggestions, please don’t hesitate to comment below. If you like what you have read, please share it on your favourite social media medium.