Installation (Ubuntu): Difference between revisions

From vwiki
Jump to navigation Jump to search
(Initial creation - content from Ubuntu page)
 
 
(24 intermediate revisions by the same user not shown)
Line 1: Line 1:
= Initial Setup =
Whilst this page was written with the installation of a Ubuntu Server 10.04 LTS in mind, it can also be used for Ubuntu 12.
Much of this section is ''borrowed'' from the following pages - they are well worth a read!
* http://www.howtoforge.com/perfect-server-ubuntu8.04-lts
* http://www.howtoforge.com/how-to-install-ubuntu8.04-with-software-raid1
 
This section will create a Ubuntu VM installed on one partition, software RAID'ed across two VMDK's.  To explain why I do this, my ESX's storage originally wasn't resilient, hence the software RAID across VMDK's on separate physical disks, if you've got resilient storage you should probably wouldn't use software RAID. 
 
''However, once I'd bought a nice (SOHO) NAS, I moved one disk and VM config across to NAS, thinking I'd eventually ditch the software RAID.  Luckily I didn't get round to it, so when I managed to destroy my NAS (partly my fault), I could easily recover my VM's from where they left off by creating new ones and re-using the surviving VMDK file. Therefore, unless you're running a truly enterprise class NAS, that's cost you £1k's to buy, and £1k's in yearly support I'd still recommend you software RAID your critical VM's (eg mail server) across two separate devices.  The whole reason you have a home set-up is to ''play'', which inevitably means ''break''!''


== Prepare Virtual Machine ==
== Prepare Virtual Machine ==
# Create a virtual machine with the following options (use Custom)
# Create a virtual machine with the following options (use Custom)
#* Guest OS: Linux > Ubuntu 32bit
#* Guest OS: Linux > Ubuntu 64bit
#* CPU: 1
#* CPU: 1
#* Memory: 756 MB
#* Memory: 512 MB
#* Disk: 36GB
#* Disk: 36GB
# Then add a second 36GB disk on a separate physical datastore (if you intend to use software RAID)
# Then add a second 36GB disk on a separate physical datastore (if you intend to use software RAID)
# Attach Ubuntu install ISO to the CD-ROM
# Attach Ubuntu install ISO to the CD-ROM


Note that the specs above should be altered to suit your purposes.  For example, its now more common to use a 64bit OS even if you don't expect to need that much memory addressing, in fact 512 MB RAM is often more than enough
Note that the specs above should be altered to suit your purposes.  Whilst there is no need to use a 64 bit OS as opposed to 32 bit if you don't need to address lots of memory, it is standard these days.


== OS Installation ==
== OS Installation ==
Follow the default or sensible choices for your locale, however, use the following notes as well...
Installing Ubuntu Server (LTS) is relatively painless, its generally a case of following the default or sensible choices for your locale.  However, below are step-by-step instructions, which you probably won't require, but may help if you're not familiar with the terminology.
* '''Configure the network'''
 
** Enter the server's hostname (not a FQDN, just the hostname)
If you're completely new make sure you read through the instructions 1st, so that you're prepared for the information you'll need to provide.
* '''Partition Disks'''
 
** If setting up software RAID follow the steps below, otherwise just select '''Guided - use entire disk and set up LVM'''
# Select language for installer
**# Select '''"Manual'''
# Select '''Install Ubuntu Server'''
**# Then create a partition...
# '''Choose Language''' screens
**## Select the first disk ('''<code>sda</code>''') and on the next screen, '''Yes''', to '''Create new empty partition table on this device?'''
## Select language for server (and remainder of the installer)
**## Select the FREE SPACE, then '''Create a new Partition''', and use all but the last 2GB of space,  
## Select location
**## And then select type of '''Primary''', and create at '''Beginning'''
# '''Ubuntu Installer Main Menu''' screens
**## Change '''''Use as''''' to '''physical volume for RAID''', and change the '''''Bootable flag''''' to '''Yes''', the select '''Done setting up this partition'''
## Select ''Yes'' for questions to determine appropriate keyboard, or ''No'' to just select a keyboard layout
**# Repeat the above on the remaining FREE SPACE on '''<code>sda</code>''', to create another primary '''physical volume for RAID''', but ''''not'' bootable'''
# '''Configure the network''' screen
**# Select the second disk, <code>sdb</code>, and repeat the steps taken for <code>sda</code> to create two identical partitions
## Enter the hostname for the server (not a FQDN, so <code>hostname</code> rather than <code>hostname.domain.com</code>)
**# On the same screen, select the '''Configure Software RAID''' option (at the top), and then confirm through the next screen
# '''Configure the clock''' screen
**# Create a RAID pack/multidisk...
## Select ''Yes'' to accept the suggested timezone, or ''No'' to alter
**## Select '''Create MD device''', then select '''RAID1''' (ie a mirror), then confirm 2 ''Active devices'', and 0 ''Spare devices''
# '''Partition disks''' screens
**## Select both '''<code>/dev/sda1</code>''' and '''<code>/dev/sdb1</code>''' partitions, and then select '''Finish'''
#* If you want to install the server onto software [[Acronyms#R|RAID]]'ed disks see [[#Install on Software RAID|Install on Software RAID]]
**# Repeat the above to create a RAID volume using '''<code>/dev/sda2</code>''' and '''<code>/dev/sdb2</code>''' partitions
## Select ''Guided - use entire disk and set up LVM''
**# Now select the RAID device #0 partition (select the #1 just under RAID1 device line), and change the '''''Use as''''' and select '''Ext3...'''
## Select the disk to partition and install the OS onto
**# Change the '''''Mount point''''' to '''/''', then select '''Done configuring this partition'''
## Select ''Yes'' to ''Write the changes to disks and configure LVM''
**# Now select the RAID device #1 partition (select the #1 just under RAID1 device line), and change the '''''Use as''''' and select '''Swap area'''
## Accept the full amount to partition
**# Then select '''Done configuring this partition''' then finally '''Finish partitioning and write changes to disk''', and confirm to '''Write the changes to disks'''
## Select ''Yes'' to ''Write the changes to disks''
**# Accept the "The kernel was unable to re-read...system will need to restart" complaints for each RAID multidisk, after which the install will continue (note there's a little more to do post install to ensure you can boot using the second disk should the first fail).
# '''Set up users and passwords''' screens
* '''Software Selection'''
## Enter your name
** DNS Server - Only required in order to configure split DNS, which is required for an exchange server install
## Enter your username (that you will use to login with)
** OpenSSH Server - Required (allows you to Putty/SSH to the server)
## Enter your password
##* If you use a weak password (eg less that 8 characters) you'll be asked to confirm this is OK once you've verified it
## Re-enter (verify) your password
## Select ''No'' to not ''Encrypt your home drive''
##* If you are really worried about your dat being compromised you should consider encrypting the whole drive during its partitioning
# '''Configure the package manager''' screen
## Enter proxy server details if required for server to access the internet for updates
# '''Select and install software''' screen
## Select ''No automatic updates'' if you want to control how updates are applied yourself, otherwise select ''Install security updates automatically''
# '''Software selection''' screens
## Select '''OpenSSH Server''' (press [Space] when item is highlighted), this allows you to Putty/SSH to the server
## Select any other required software, eg
##* DNS Server - Only required if you want your server to be a DNS server; or in order to configure split DNS, which is required for an exchange server install
##* LAMP Server - Only required for Apache webserver (with MySQL and PHP)
# '''Configuring grub-pc''' screen
## Select ''Yes'' to ''Install the GRUB boot loader to the master boot record''
# '''Finish the installation''' screen
## Select ''Continue''
 
=== Install on Software RAID ===
On the '''Partition Disks''' screens use the following to setup software RAID during OS installation.
 
* If setting up software RAID follow the steps below, otherwise just select '''Guided - use entire disk and set up LVM'''
# Select '''"Manual'''
# Then create a partition...
## Select the first disk ('''<code>sda</code>''') and on the next screen, '''Yes''', to '''Create new empty partition table on this device?'''
## Select the FREE SPACE, then '''Create a new Partition''', and use all but the last 2GB of space,  
## And then select type of '''Primary''', and create at '''Beginning'''
## Change '''''Use as''''' to '''physical volume for RAID''', and change the '''''Bootable flag''''' to '''Yes''', the select '''Done setting up this partition'''
# Repeat the above on the remaining FREE SPACE on '''<code>sda</code>''', to create another primary '''physical volume for RAID''', but ''''not'' bootable'''
# Select the second disk, <code>sdb</code>, and repeat the steps taken for <code>sda</code> to create two identical partitions
# On the same screen, select the '''Configure Software RAID''' option (at the top), and then confirm through the next screen
# Create a RAID pack/multidisk...
## Select '''Create MD device''', then select '''RAID1''' (ie a mirror), then confirm 2 ''Active devices'', and 0 ''Spare devices''
## Select both '''<code>/dev/sda1</code>''' and '''<code>/dev/sdb1</code>''' partitions, and then select '''Finish'''
# Repeat the above to create a RAID volume using '''<code>/dev/sda2</code>''' and '''<code>/dev/sdb2</code>''' partitions
# Now select the RAID device #0 partition (select the #1 just under RAID1 device line), and change the '''''Use as''''' and select '''Ext3...'''
# Change the '''''Mount point''''' to '''/''', then select '''Done configuring this partition'''
# Now select the RAID device #1 partition (select the #1 just under RAID1 device line), and change the '''''Use as''''' and select '''Swap area'''
# Then select '''Done configuring this partition''' then finally '''Finish partitioning and write changes to disk''', and confirm to '''Write the changes to disks'''
# Accept the "The kernel was unable to re-read...system will need to restart" complaints for each RAID multidisk, after which the install will continue (note there's a little more to do post install to ensure you can boot using the second disk should the first fail).
 
Much of this page was originally borrowed heavily from the following pages - they are well worth a read!
* http://www.howtoforge.com/perfect-server-ubuntu8.04-lts
* http://www.howtoforge.com/how-to-install-ubuntu8.04-with-software-raid1


== Post OS Install Config ==
== Post OS Install Config ==
* '''Enable Root'''
=== Enable Root ===
*# Use the command <code> sudo passwd root </code>
# Use the command <code> sudo passwd root </code>
*# Enter user password, and then a strong password for the root account
# Enter your user password
* '''Finish Software RAID config''' - only if configured during install
# Enter a strong password for the root account
*# Start-up grub (by entering <code> grub </code> and enter the following commands (seems to work better via SSH than direct console)...
*#* <code> device (hd1) /dev/sdb </code>
*#* <code> root (hd1,0) </code>
*#* <code> setup (hd1) </code>
*#* <code> quit </code>
*# Then edit the <code> /boot/grub/menu.lst </code> config file.  Go to the end of the file where the boot options are, and create a copy of the first option and edit the following lines
*#* <code> title </code> Add "Primary disk fail" or something similar to end
*#* <code> root </code> Change <code> hd0 </code> to <code> hd1 </code>
*# To check the RAID setup of your drives use
*#* <code> mdadm --misc -D /dev/md0 </code>
*#* <code> mdadm --misc -D /dev/md1 </code>


== Change IP Address ==
For Ubuntu 18...
# Use the command <code> sudo passwd</code>
# Enter your user password
# Enter a strong password for the root account


* Edit the <code> /etc/network/interfaces </code> file in the following fashion
=== Finish Software RAID config ===
''' Only if configured during install '''
# Start-up grub (by entering <code> grub </code> and enter the following commands (seems to work better via SSH than direct console)...
#* <code> device (hd1) /dev/sdb </code>
#* <code> root (hd1,0) </code>
#* <code> setup (hd1) </code>
#* <code> quit </code>
# Then edit the <code> /boot/grub/menu.lst </code> config file.  Go to the end of the file where the boot options are, and create a copy of the first option and edit the following lines
#* <code> title </code> Add "Primary disk fail" or something similar to end
#* <code> root </code> Change <code> hd0 </code> to <code> hd1 </code>
# To check the RAID setup of your drives use
#* <code> mdadm --misc -D /dev/md0 </code>
#* <code> mdadm --misc -D /dev/md1 </code>
 
== Change IP Address (Pre v18) ==
=== v8 Hardy Heron / v10 Lucid Lynx ===
* Edit the <code> /etc/network/interfaces </code> file in the following fashion to set static address details
<pre>
<pre>
# The primary network interface
# The primary network interface
Line 77: Line 122:
         gateway 192.168.1.1
         gateway 192.168.1.1
</pre>
</pre>
* Then check the local hosts file <code> /etc/hosts </code>, so that the IP v4 part looks like...
* Then check the local hosts file <code>/etc/hosts</code>, so that the IP v4 part looks like this (so the host can resolve itself)...
<pre>
<pre>
127.0.0.1      localhost
127.0.0.1      localhost
192.168.1.150  hostname.domain.com  hostname
192.168.1.150  hostname.domain.com  hostname
</pre>
</pre>
* Check that DNS resolution is setup correctly (add DNS nameservers as required, as found in <code>/etc/resolv.conf</code> in order of pref...
* Check that DNS resolution is setup correctly in <code>/etc/resolv.conf</code>.  Add additional DNS nameservers as required, as found in in order of preference.  You can also add the domain of the server (<code>domain</code>), and add domain suffix searches (<code>search</code>), both are optional.  For example...
nameserver 192.168.1.20
  nameserver 127.0.0.1
  nameserver 127.0.0.1
domain domain.com
search domain.com
search domain.com
* Then restart networking
** <code> /etc/init.d/networking restart </code>
* Confirm network config is as expected with
** <code>ifconfig</code>
=== v12 Precise Pangolin ===
* Edit the <code> /etc/network/interfaces </code> file in the following fashion to set static address details
<pre>
# The primary network interface
auto eth0
iface eth0 inet static
        address 192.168.1.150
        netmask 255.255.255.0
        gateway 192.168.1.1
dns-nameservers 192.168.1.20 8.8.8.8
dns-domain localdomain.com
dns-search localdomain.com anotherdomain.com
       
</pre>
* Then check the local hosts file <code>/etc/hosts</code>, so that the IP v4 part looks like this (so the host can resolve itself)...
<pre>
127.0.0.1      localhost
192.168.1.150  hostname.domain.com  hostname
</pre>


* Then restart networking
* Then restart networking
** <code> sudo /etc/init.d/networking restart </code>
** <code> service networking restart </code>
 
* Confirm network interface config is as expected with
** <code>ifconfig</code>
* Confirm DNS config is as expected with
** <code>less /etc/resolv.conf</code>
 
=== Persistent Route ===
To add a persistent route to an interface, add using the following syntax (example sends traffic to 172.32.1.0/24 via eth1 to 192.168.1.100
 
up route add -net 172.32.1.0/24 gw 192.168.1.100 dev eth1
 
=== Additional IPs / Multihome ===
To add additional IP addresses to an interface, create sub-interfaces as below.


== Update the OS ==
<pre>
* Run the following command to update the apt package database
auto eth0:1
** <code> apt-get update </code>
auto eth0:2
* To install any updates
 
** <code> apt-get upgrade </code>
# Sub 1
iface eth0:1 inet static
    address 192.168.1.160
    netmask 255.255.255.0
 
# Sub 2
iface eth0:2 inet static
    address 192.168.1.161
    netmask 255.255.255.0
</pre>


'''RTNETLINK answers: File exists''' - Note that you can't use the same default gateway twice, doing so will cause this error


= Install VM Tools =
== Change IP Address (v18 onwards) ==
The pre-built modules that come with the VMTools installer aren't compatible, therefore the script needs to be able to compile them, however the required library files aren't available by default, so the procedure is a little laboured.
Ubuntu now uses [https://netplan.io Netplan], do not use the <code>/etc/network/interfaces</code> config file, use either <code>/etc/netplan/01-netcfg.yaml</code> or <code>/etc/netplan/50-cloud-init.yaml</code>. Formatting is very important with YAML files, indents especially.


== Ubuntu 8.04.4 LTS ==
# Find the interface name (eg <code>ens2</code>)
# Install the build library files...
#* <code> ip link </code>
#* <code> apt-get install build-essential </code>
# Edit the <code>/etc/netplan/01-netcfg.yaml</code> config file as show below
#* <code> apt-get install linux-headers-2.6.24-26-server </code>
# Apply the changes
#** Use <code> uname -r </code> to get the right headers version number
#* <code> netplan apply</code>
# Select "Install VM Tools" from the VI Client
# Mount the VM Tools CD-ROM
#* <code> mount /media/cdrom0/ </code>
# Copy to home directory
#* <code> cp /media/cdrom/VMwareTools-4.0.0-219382.tar.gz /home/user/ </code>
# Uncompress and then move into the <code> vmware-tools-distrib </code> directory
#* <code> tar xf VMwareTools-4.0.0-219382.tar.gz </code>
#* <code> cd vmware-tools-distrib </code>
# Run the install script
#* <code> ./vmware-install.pl  </code>
# Restart
#* <code> shutdown -r now </code>


== Ubuntu 10.04.1 LTS ==
<pre>
VM Tools can be installed via two methods, neither of which is ideal...
network:
* Using the normal VM Tools ''CD'' - requires additional library install and sometimes mounting the CDROM doesn't work too well.
  version: 2
* Using APT package manager - doesn't work quite as well as it could (upgrading VM Tools isn't supported), and support for this method is rumoured to be dropped in future releases
  renderer: networkd
  ethernets:
    ens2:
      dhcp4: no
      addresses:
        - 192.168.1.50/24
      gateway4: 192.168.1.1
      nameservers:
          addresses: [192.168.1.1,8.8.8.8]
</pre>


'''VM Tools ''CD'''''
=== Persistent Route ===
# Install the build library files (not required for ESX v4.0 update 2 and later)...
To add a persistent route to an interface, add using the following syntax (example sends traffic to 172.32.1.0/24 via eth1 to 192.168.2.100) to add the <code>routes</code> config to the interface the traffic should go through.
#* <code> apt-get install build-essential </code>
# Select "Install VM Tools" from the VI Client
# Mount the VM Tools CD-ROM
#* <code> mount /dev/cdrom /media/cdrom/ </code>
#** If <code>/media/cdrom/</code> doesn't exist, create with <code>mkdir /media/cdrom</code>
# Copy to tmp directory (version number below will vary)
#* <code> cp /media/cdrom/VMwareTools-4.0.0-236512.tar.gz /tmp/ </code>
# Unmount the CD-ROM, and move into tmp directory
#* <code> umount /media/cdrom/ </code>
#* <code> cd /tmp/ </code>
# Uncompress and then move into the <code> vmware-tools-distrib </code> directory
#* <code> tar xzvf VMware*.gz </code>
#* <code> cd vmware-tools-distrib </code>/
# Run the install script, and accept defaults
#* <code> ./vmware-install.pl  </code>
# Restart
#* <code> shutdown -r now </code>


'''APT Package Manager'''
<pre>
# Install VM Tools using apt package manager
    ens2:
# Open VMware Packaging Public GPG Key at http://packages.vmware.com/tools/VMWARE-PACKAGING-GPG-KEY.pub
      addresses:
# On the server open a new file called <code>VMWARE-PACKAGING-GPG-KEY.pub</code> with the <code>/tmp</code> directory
        - 192.168.2.50/24
# Copy and paste the contents of the webpage into the file and save
      dhcp4: no
# Import the key using the following command
      routes:
#* <code>apt-key add /tmp/VMWARE-PACKAGING-GPG-KEY.pub</code>
        - to: 172.32.1.0/24
#* You should get <code>OK</code> returned
          via: 192.168.2.100
# If you need to add a proxy see http://communities.vmware.com/servlet/JiveServlet/download/1554533-39836/Vmware%20Tools%20Guide%20Linux%20osp_install_guide.pdf
</pre>
# Open a new vi in VI called <code>/etc/apt/sources.list.d/vmware-tools.list</code>
 
# Add the following line
== Update the OS ==
#* <code> deb http://packages.vmware.com/tools/esx/<esx-version>/ubuntu lucid main restricted </code> where <esx-version> is the appropriate esx version found at http://packages.vmware.com/tools/esx/index.html
# Run the following command to update the apt package database
# Update the repository cacahe
#* <code> apt-get update </code>
#* <code> apt-get update </code>
# Install VM Tools
# To install any updates
#* <code> apt-get install vmware-tools </code>
#* <code> apt-get upgrade </code>
#* If updates are being held back (eg linux image), then use <code> aptitude safe-upgrade</code>
# If running in VMware VM, [[VM Tools_Install_(Ubuntu)|install VM Tools]]
 
=== Remove Old Version ===
Old kernel images will tend to linger in <code>/boot</code> and source code will remain in <code>/user/src</code>.  These can be safely removed so long as you're completely certain which you are using (normally the latest)
# Get the versions currently installed
#* <code>dpkg --get-selections | grep linux-image</code>
# Remove unwanted versions (don't remove the current or base/unversioned image)
#* EG <code>apt-get purge linux-image-3.2.0-32-virtual </code>
#* If you've got lots to remove its easier to do lots in one go
#** EG <code> apt-get purge linux-image-3.2.0-51-virtual linux-image-3.2.0-52-virtual </code>
 
To remove old source, just delete manually,
* EG <code> rm -fr /usr/src/linux-headers-3.2.0-51 </code>


= NTP =
== NTP ==
''Not required if your server doesn't really need bang on accurate time''  
''Not required if your server doesn't really need bang on accurate time''  


Line 173: Line 265:
#* <code> server 3.europe.pool.ntp.org </code>
#* <code> server 3.europe.pool.ntp.org </code>
# Restart the NTP service
# Restart the NTP service
#* <code> service ntp restart </code>
#* <code> systemctl restart ntp </code>
# Verify using the following commands
# Verify using the following commands
#* <code> ntpq -np </code>
#* <code> ntpq -np </code>

Latest revision as of 07:42, 8 October 2020

Whilst this page was written with the installation of a Ubuntu Server 10.04 LTS in mind, it can also be used for Ubuntu 12.

Prepare Virtual Machine

  1. Create a virtual machine with the following options (use Custom)
    • Guest OS: Linux > Ubuntu 64bit
    • CPU: 1
    • Memory: 512 MB
    • Disk: 36GB
  2. Then add a second 36GB disk on a separate physical datastore (if you intend to use software RAID)
  3. Attach Ubuntu install ISO to the CD-ROM

Note that the specs above should be altered to suit your purposes. Whilst there is no need to use a 64 bit OS as opposed to 32 bit if you don't need to address lots of memory, it is standard these days.

OS Installation

Installing Ubuntu Server (LTS) is relatively painless, its generally a case of following the default or sensible choices for your locale. However, below are step-by-step instructions, which you probably won't require, but may help if you're not familiar with the terminology.

If you're completely new make sure you read through the instructions 1st, so that you're prepared for the information you'll need to provide.

  1. Select language for installer
  2. Select Install Ubuntu Server
  3. Choose Language screens
    1. Select language for server (and remainder of the installer)
    2. Select location
  4. Ubuntu Installer Main Menu screens
    1. Select Yes for questions to determine appropriate keyboard, or No to just select a keyboard layout
  5. Configure the network screen
    1. Enter the hostname for the server (not a FQDN, so hostname rather than hostname.domain.com)
  6. Configure the clock screen
    1. Select Yes to accept the suggested timezone, or No to alter
  7. Partition disks screens
    1. Select Guided - use entire disk and set up LVM
    2. Select the disk to partition and install the OS onto
    3. Select Yes to Write the changes to disks and configure LVM
    4. Accept the full amount to partition
    5. Select Yes to Write the changes to disks
  8. Set up users and passwords screens
    1. Enter your name
    2. Enter your username (that you will use to login with)
    3. Enter your password
      • If you use a weak password (eg less that 8 characters) you'll be asked to confirm this is OK once you've verified it
    4. Re-enter (verify) your password
    5. Select No to not Encrypt your home drive
      • If you are really worried about your dat being compromised you should consider encrypting the whole drive during its partitioning
  9. Configure the package manager screen
    1. Enter proxy server details if required for server to access the internet for updates
  10. Select and install software screen
    1. Select No automatic updates if you want to control how updates are applied yourself, otherwise select Install security updates automatically
  11. Software selection screens
    1. Select OpenSSH Server (press [Space] when item is highlighted), this allows you to Putty/SSH to the server
    2. Select any other required software, eg
      • DNS Server - Only required if you want your server to be a DNS server; or in order to configure split DNS, which is required for an exchange server install
      • LAMP Server - Only required for Apache webserver (with MySQL and PHP)
  12. Configuring grub-pc screen
    1. Select Yes to Install the GRUB boot loader to the master boot record
  13. Finish the installation screen
    1. Select Continue

Install on Software RAID

On the Partition Disks screens use the following to setup software RAID during OS installation.

  • If setting up software RAID follow the steps below, otherwise just select Guided - use entire disk and set up LVM
  1. Select "Manual
  2. Then create a partition...
    1. Select the first disk (sda) and on the next screen, Yes, to Create new empty partition table on this device?
    2. Select the FREE SPACE, then Create a new Partition, and use all but the last 2GB of space,
    3. And then select type of Primary, and create at Beginning
    4. Change Use as to physical volume for RAID, and change the Bootable flag to Yes, the select Done setting up this partition
  3. Repeat the above on the remaining FREE SPACE on sda, to create another primary physical volume for RAID, but 'not bootable
  4. Select the second disk, sdb, and repeat the steps taken for sda to create two identical partitions
  5. On the same screen, select the Configure Software RAID option (at the top), and then confirm through the next screen
  6. Create a RAID pack/multidisk...
    1. Select Create MD device, then select RAID1 (ie a mirror), then confirm 2 Active devices, and 0 Spare devices
    2. Select both /dev/sda1 and /dev/sdb1 partitions, and then select Finish
  7. Repeat the above to create a RAID volume using /dev/sda2 and /dev/sdb2 partitions
  8. Now select the RAID device #0 partition (select the #1 just under RAID1 device line), and change the Use as and select Ext3...
  9. Change the Mount point to /, then select Done configuring this partition
  10. Now select the RAID device #1 partition (select the #1 just under RAID1 device line), and change the Use as and select Swap area
  11. Then select Done configuring this partition then finally Finish partitioning and write changes to disk, and confirm to Write the changes to disks
  12. Accept the "The kernel was unable to re-read...system will need to restart" complaints for each RAID multidisk, after which the install will continue (note there's a little more to do post install to ensure you can boot using the second disk should the first fail).

Much of this page was originally borrowed heavily from the following pages - they are well worth a read!

Post OS Install Config

Enable Root

  1. Use the command sudo passwd root
  2. Enter your user password
  3. Enter a strong password for the root account

For Ubuntu 18...

  1. Use the command sudo passwd
  2. Enter your user password
  3. Enter a strong password for the root account

Finish Software RAID config

Only if configured during install

  1. Start-up grub (by entering grub and enter the following commands (seems to work better via SSH than direct console)...
    • device (hd1) /dev/sdb
    • root (hd1,0)
    • setup (hd1)
    • quit
  2. Then edit the /boot/grub/menu.lst config file. Go to the end of the file where the boot options are, and create a copy of the first option and edit the following lines
    • title Add "Primary disk fail" or something similar to end
    • root Change hd0 to hd1
  3. To check the RAID setup of your drives use
    • mdadm --misc -D /dev/md0
    • mdadm --misc -D /dev/md1

Change IP Address (Pre v18)

v8 Hardy Heron / v10 Lucid Lynx

  • Edit the /etc/network/interfaces file in the following fashion to set static address details
# The primary network interface
auto eth0
iface eth0 inet static
        address 192.168.1.150
        netmask 255.255.255.0
        network 192.168.1.0
        broadcast 192.168.1.255
        gateway 192.168.1.1
  • Then check the local hosts file /etc/hosts, so that the IP v4 part looks like this (so the host can resolve itself)...
127.0.0.1       localhost
192.168.1.150   hostname.domain.com   hostname
  • Check that DNS resolution is setup correctly in /etc/resolv.conf. Add additional DNS nameservers as required, as found in in order of preference. You can also add the domain of the server (domain), and add domain suffix searches (search), both are optional. For example...
nameserver 192.168.1.20
nameserver 127.0.0.1
domain domain.com
search domain.com
search domain.com
  • Then restart networking
    • /etc/init.d/networking restart
  • Confirm network config is as expected with
    • ifconfig

v12 Precise Pangolin

  • Edit the /etc/network/interfaces file in the following fashion to set static address details
# The primary network interface
auto eth0
iface eth0 inet static
        address 192.168.1.150
        netmask 255.255.255.0
        gateway 192.168.1.1

dns-nameservers 192.168.1.20 8.8.8.8
dns-domain localdomain.com
dns-search localdomain.com anotherdomain.com
        
  • Then check the local hosts file /etc/hosts, so that the IP v4 part looks like this (so the host can resolve itself)...
127.0.0.1       localhost
192.168.1.150   hostname.domain.com   hostname
  • Then restart networking
    • service networking restart
  • Confirm network interface config is as expected with
    • ifconfig
  • Confirm DNS config is as expected with
    • less /etc/resolv.conf

Persistent Route

To add a persistent route to an interface, add using the following syntax (example sends traffic to 172.32.1.0/24 via eth1 to 192.168.1.100

up route add -net 172.32.1.0/24 gw 192.168.1.100 dev eth1

Additional IPs / Multihome

To add additional IP addresses to an interface, create sub-interfaces as below.

auto eth0:1
auto eth0:2 

# Sub 1
iface eth0:1 inet static
    address 192.168.1.160
    netmask 255.255.255.0

# Sub 2
iface eth0:2 inet static
    address 192.168.1.161
    netmask 255.255.255.0

RTNETLINK answers: File exists - Note that you can't use the same default gateway twice, doing so will cause this error

Change IP Address (v18 onwards)

Ubuntu now uses Netplan, do not use the /etc/network/interfaces config file, use either /etc/netplan/01-netcfg.yaml or /etc/netplan/50-cloud-init.yaml. Formatting is very important with YAML files, indents especially.

  1. Find the interface name (eg ens2)
    • ip link
  2. Edit the /etc/netplan/01-netcfg.yaml config file as show below
  3. Apply the changes
    • netplan apply
network:
  version: 2
  renderer: networkd
  ethernets:
    ens2:
      dhcp4: no
      addresses:
        - 192.168.1.50/24
      gateway4: 192.168.1.1
      nameservers:
          addresses: [192.168.1.1,8.8.8.8]

Persistent Route

To add a persistent route to an interface, add using the following syntax (example sends traffic to 172.32.1.0/24 via eth1 to 192.168.2.100) to add the routes config to the interface the traffic should go through.

    ens2:
      addresses:
        - 192.168.2.50/24
      dhcp4: no
      routes:
        - to: 172.32.1.0/24
          via: 192.168.2.100

Update the OS

  1. Run the following command to update the apt package database
    • apt-get update
  2. To install any updates
    • apt-get upgrade
    • If updates are being held back (eg linux image), then use aptitude safe-upgrade
  3. If running in VMware VM, install VM Tools

Remove Old Version

Old kernel images will tend to linger in /boot and source code will remain in /user/src. These can be safely removed so long as you're completely certain which you are using (normally the latest)

  1. Get the versions currently installed
    • dpkg --get-selections | grep linux-image
  2. Remove unwanted versions (don't remove the current or base/unversioned image)
    • EG apt-get purge linux-image-3.2.0-32-virtual
    • If you've got lots to remove its easier to do lots in one go
      • EG apt-get purge linux-image-3.2.0-51-virtual linux-image-3.2.0-52-virtual

To remove old source, just delete manually,

  • EG rm -fr /usr/src/linux-headers-3.2.0-51

NTP

Not required if your server doesn't really need bang on accurate time

Out of the box your server will sync every time its restarted and drift a bit in-between. There is an additional resource demand in running the NTP daemon so unless you need to, there's no need to install the full blown NTP daemon.

I tend to have one or two servers updating from remote (public) servers, and then all others updating from those.

  1. Install the service
    • apt-get install ntp
  2. Update the NTP config file, /etc/ntp.conf (Example below is for a server updating from public European servers - see http://www.pool.ntp.org/)
    • server 0.europe.pool.ntp.org
    • server 1.europe.pool.ntp.org
    • server 2.europe.pool.ntp.org
    • server 3.europe.pool.ntp.org
  3. Restart the NTP service
    • systemctl restart ntp
  4. Verify using the following commands
    • ntpq -np
    • date