This is sometimes necessary to free up disk space on a volume that cannot have extra disk space easily added.

Similar documents
This guide is broken up into several sections and covers different Linux distributions and non- Linux operating systems.

Article Number: 549 Rating: Unrated Last Updated: Tue, May 30, 2017 at 11:02 AM

Article Number: 513 Rating: 5/5 from 1 votes Last Updated: Tue, Jul 19, 2016 at 10:09 PM

OK: {C: 68% free / 99.51GB total} 'C: free'= g; ; ;0; 'C: free %'=68%;20;10;0;100

It is important to remember that an external worker needs all of the plugins installed on it so it can execute the checks that are handed to it.

Article Number: 722 Rating: Unrated Last Updated: Thu, Jul 20, 2017 at 12:31 AM

As this method focuses on working with LVM, we will first confirm that our partition type is actually Linux LVM by running the below command.

Changing user login password on templates

iscsi storage is used as shared storage in Redhat cluster, VMware vsphere, Redhat Enterprise Virtualization Manager, Ovirt, etc.

Article Number: 602 Rating: Unrated Last Updated: Tue, Jan 2, 2018 at 5:13 PM

Article Number: 38 Rating: Unrated Last Updated: Thu, Apr 28, 2016 at 9:49 PM

BT Cloud Compute. Adding a Volume to an existing VM running Linux. The power to build your own cloud solutions to serve your specific business needs

Adding a block devices and extending file systems in Linux environments

OPS235. Linux File Systems Partitioning Mounting File Systems

CIS UNIX System Administration

7. Try shrinking / -- what happens? Why? Cannot shrink the volume since we can not umount the / logical volume.

Disks, Filesystems, Booting Todd Kelley CST8177 Todd Kelley 1

Disks, Filesystems Todd Kelley CST8177 Todd Kelley 1

Partitioning and Formatting Guide

How To Resize ext3 Partitions Without Losing Data

Argument 1 = A number (0, 1, 2, 3) that will be used as the exit code the script will exit with (this is how Nagios determines the status)

FORTINET DOCUMENT LIBRARY FORTINET VIDEO GUIDE FORTINET BLOG CUSTOMER SERVICE & SUPPORT FORTIGATE COOKBOOK FORTINET TRAINING SERVICES

Project 3: An Introduction to File Systems. COP4610 Florida State University

Using Fluentd as an alternative to Splunk

Exam Name: Red Hat Certified Engineer on Redhat

Getting Started with Pentaho and Cloudera QuickStart VM

An introduction to Logical Volume Management

This is Worksheet and Assignment 12. Disks, Partitions, and File Systems

Ubuntu - How to Create Software RAID 1 in Ubuntu Linux - Tutorial

CST8207: GNU/Linux Operating Systems I Lab Nine Disks, Partitions, and File Systems Part 2. Disks, Partitions, and File Systems - Part 2 of 2

EX200.redhat

Disks, Filesystems 1

This section describes the procedures needed to add a new disk to a VM. vmkfstools -c 4g /vmfs/volumes/datastore_name/vmname/xxxx.

Chapter 6. Linux File System

Actual4Test. Actual4test - actual test exam dumps-pass for IT exams

Week 10 Project 3: An Introduction to File Systems. Classes COP4610 / CGS5765 Florida State University

Exam Actual. Higher Quality. Better Service! QUESTION & ANSWER

Project 3: An Introduction to File Systems. COP 4610 / CGS 5765 Principles of Operating Systems

SAP HANA Backup Guide (for A2040d SLES) 23 rd of January 2017 NEC SAP Global Competence Center

example.com index.html # vim /etc/httpd/conf/httpd.conf NameVirtualHost :80 <VirtualHost :80> DocumentRoot /var/www/html/

There are separate firewall daemons for for IPv4 and IPv6 and hence there are separate commands which are provided below.

CIS 191A Final Exam. Fall CIS 191 Final Exam

Configure Windows Server 2003 Release 2 Server Network File Share (NFS) as an authenticated storage repository for XenServer

cpouta exercises

More on file systems, Booting Todd Kelley CST8177 Todd Kelley 1

RH202. Redhat Certified Technician on Redhat Enterprise Linux 4 (Labs) Exam.

SAP HANA Backup Guide (for Ivy-Bridge Model)

Cloning and Repartitioning sessionmgr Disks

Author : admin. 1. Getting information about current file system partitions with fdisk and mount

EX200.exam.35q. Number: EX200 Passing Score: 800 Time Limit: 120 min. EX200. Red Hat Certified System Administrator RHCSA

For personnal use only


Quota LVM (Logical Volume Manager)

Nested Home Lab Setting up Shared Storage

Link Gateway ISO Installation Manual

Back Up (And Restore) LVM Partitions With LVM Snapshots

Actual4Test. Actual4test - actual test exam dumps-pass for IT exams

Downloading and installing Db2 Developer Community Edition on Red Hat Enterprise Linux Roger E. Sanders Yujing Ke Published on October 24, 2018

Linux System Administration, level 1. Lecture 4: Partitioning and Filesystems Part II: Tools & Methods

RG-MACC_2.0 Installation Manual

Linux Systems Security. Backup and Change Management NETS Fall 2016

RocketRAID 2680/2684 SAS Controller Red Hat Enterprise/CentOS Linux Installation Guide

Welcome to getting started with Ubuntu Server. This System Administrator Manual. guide to be simple to follow, with step by step instructions

Linux Hardware Management. Linux System Administration COMP2018 Summer 2017

RH-202. RedHat. Redhat Certified Technician on Redhat Enterprise Linux 4 (Labs)

Lab E2: bypassing authentication and resetting passwords

System Administration. Storage Systems

RHCE BOOT CAMP. Various Additional Topics

Production Installation and Configuration. Openfiler NSA

PR2 System Administration. ROS + PR2 Training Workshop

How to Back-Up a fit-pc2 Using Only a USB Stick (and some creative partitioning)

RocketRAID 231x/230x SATA Controller Red Hat Enterprise/CentOS Linux Installation Guide

New RHEL 7.5 features: VDO, USBGuard, NBDE and AIDE. RHUG Q Marc Skinner Principal Solutions Architect 3/21/2018

TestOut Linux Pro - English 4.0.x OBJECTIVE MAPPING: CompTIA Linux+ LX0-103

Exam Questions RH202

(32 KB) 216 * 215 = 231 = 2GB

SAP HANA Restore Guide (for A2040d SLES) 23 rd of January 2017 NEC SAP Global Competence Center

LiLo Crash Recovery. 1.0 Preparation Tips. 2.0 Quick Steps to recovery

Red Hat.Actualtests.EX200.v by.Dixon.22q. Exam Code: EX200. Exam Name: Red Hat Certified System Administrator (RHCSA) Exam

More on file systems, Booting Todd Kelley CST8177 Todd Kelley 1

Server guides for the GIRAF project

Method of Procedure to Upgrade RMS OS to Red Hat Enterprise Linux 6.7

The Ultimate Linux/Windows System

SLES Linux Installation Guide

Article Number: 801 Rating: Unrated Last Updated: Tue, Mar 13, 2018 at 9:19 PM

Installing caos with Cinch on Floppy Disk

Once your USB drive is formatted for the FAT32 file system it can be mounted and tested on the GESBC To do this, use the following command:

Manually Mount Usb Flash Drive Ubuntu Server

EX200 EX200. Red Hat Certified System Administrator RHCSA

EX200.Lead2pass.Exam.24q. Exam Code: EX200. Exam Name: Red Hat Certified System Administrator RHCSA. Version 14.0

Vendor: RedHat. Exam Code: EX200. Exam Name: Red Hat Certified System Administrator - RHCSA. Version: Demo

Unless otherwise noted, all references to STRM refer to STRM, STRM Log Manager, and STRM Network Anomaly Detection.

LPIC-1 System Administrator

Upgrading Prime Optical

RocketRAID 2310/2300 Controller Fedora Linux Installation Guide

exam.30q. Number: Passing Score: 800 Time Limit: 120 min File Version: 1 LPI

RocketRAID 231x/230x SATA Controller Fedora Linux Installation Guide

PiCloud. Building owncloud on a Raspberry PI

Purpose. Target Audience. Install SNMP On The Remote Linux Machine. Nagios XI. Monitoring Linux Using SNMP

Partitioning and Formatting Reference Guide

Transcription:

Movin g /var/log/ Article Number: 473 Rating: Unrated Last Updated: Tue, Mar 29, 2016 at 5:56 PM O ve r vie w This KB article will walk you through the steps of moving the /var/log directory to a new disk/volume in your server. This is sometimes necessary to free up disk space on a volume that cannot have extra disk space easily added. This guide was performed on a VM running Nagios XI 5.2.5, however it can be applied to any of the Nagios products as the steps are not specific to XI. This guide has separate steps for CentOS 6.x and 7.x as there are subtle differences in the operating system versions. Here is a quick outline of what will be performed: View existing disks Configure OS for single user mode Add new disk to VM Prepare the new disk Move existing /var/log to new location Configure new disk to mount on boot Configure OS in multi user mode and reboot Final check Wa rning This guide requires multiple reboots of your s erver. C e nt O S 6.x First establish an SSH session to your server as the user root. Vie w Exis t ing Dis ks This will show the existing disks: /dev/sda /dev/sda1 /dev/sda2 Here you can see there is currently only s d a (sda1 and sda2 are partitions on s d a ). You also need to make sure the lvm2 programs are installed. yum -y install lvm2 Wait while the program is downloaded and installed. C o nf igure OS Fo r Single Us e r Mo de

First we are going to configure the operating system in single user mode. This allows us to boot the OS with nothing running, this will prevent any issues from occurring while making these changes. Wa rning Fro m this po int o n, yo ur s erver will no t perfo rm any mo nito ring until we finis h and put the s erver bac k in multi us er mo de. sed -i 's/^id:3:/id:1:/g' /etc/inittab There will be no output from this command. Add Ne w Dis k To VM Now we are going to shutdown the VM. Wa rning O nc e yo u s hutdo wn the VM, yo u will no lo nger have netwo rk c o nnec tivity to it (bec aus e we are in s ingle us er mo de). O nc e yo u have po wered o n yo ur VM, all c o mmands will need to be do ne o n the c o ns o le o f the VM. shutdown -h now Once the server has shutdown, using your Hypervisor, add the new disk to the VM. In this example I will be adding a 100GB disk. Power on the VM and wait for it to boot up, once booted it will look something like: Pre pare Ne w Dis k This will now show the new /dev/sdb disk: Now you will use fdisk to create a new partition: fdisk /dev/sdb The screenshot below shows the following commands you need to type: Command: n (primary partition): p

(partition number): 1 For the first and last cylinder accept the defaults by pressing Enter Command: t (hex code): 8e Command: w Now that the disk has been partitioned, the next step is to create the volume. This will now show the new /dev/sdb1 partition: The following steps will create a vo lume g ro up (vg_log) and a lo g ic a l vo lume (lv_log). vgcreate vg_log /dev/sdb1 lvcreate -l 100%VG -n lv_log vg_log The following steps will define the volume with an e xt4 filesystem. mkfs -t ext4 /dev/vg_log/lv_log

Finally we'll temporarily mount the new volume so we can use it and check it has been mounted by listing the directory. mkdir /mnt/tmp_vol mount -t ext4 /dev/vg_log/lv_log /mnt/tmp_vol/ ls -la /mnt/tmp_vol/ Mo ve Exis t ing /var/lo g To Ne w Lo c at io n Now we'll move the existing files in /var/log/ to the new volume. mv /var/log/* /mnt/tmp_vol/ Depending on the amount of files will depend how long this takes. If everything goes well, there will be no errors output on the screen. Once finished, check to see if there are any files remaining: ls -l /var/log Just to be sure, check the new volume for the files: ls -l /mnt/tmp_vol

This should output a bunch of files and folders. C o nf igure Ne w Dis k To Mo unt On Bo o t First we will un-mount the volume: umount /mnt/tmp_vol Next we add an entry to the /etc/fstab file to mount this volume to /var/log on bootup: echo /dev/vg_log/lv_log /var/log ext4 defaults 0 0 >> /etc/fstab Now reload the fstab file to mount the volume: mount -a Check the files and folders to see it mounted ok: ls -l /var/log/ If you see the same files and folders as you did after moving the files everything is OK. C o nf igure OS Fo r Mult i Us e r Mo de And Re boot Finally we are going to configure the operating system in multi user mode. sed -i 's/^id:1:/id:3:/g' /etc/inittab There will be no output from this command. Now reboot: reboot Final C he c k Once the server has rebooted, establish an SSH session to your server as the user root.

df -h Here you'll see the disk has been mounted and is now /var/log with ample free space: This completes moving /var/log to a new disk drive on CentOS 6.x. C e nt O S 7.x First establish an SSH session to your server as the user root. Vie w Exis t ing Dis ks This will show the existing disks: /dev/sda /dev/sda1 /dev/sda2 Here you can see there is currently only s d a (sda1 and sda2 are partitions on s d a ). You also need to make sure the lvm2 programs are installed. yum -y install lvm2 Wait while the program is downloaded and installed. C o nf igure OS Fo r Re s c ue Mo de First we are going to configure the operating system in rescue mode. This allows us to boot the OS with nothing running, this will prevent any issues from occurring while making these changes. Wa rning Fro m this po int o n, yo ur s erver will no t perfo rm any mo nito ring until we finis h and put the s erver bac k in multi us er mo de.

systemctl set-default rescue.target The following output will be shown: Removed symlink /etc/systemd/system/default.target. Created symlink from /etc/systemd/system/default.target to /usr/lib/systemd/system/rescue.target. Add Ne w Dis k To VM Now we are going to shutdown the VM. Wa rning O nc e yo u s hutdo wn the VM, yo u will no lo nger have netwo rk c o nnec tivity to it (bec aus e we are in s ingle us er mo de). O nc e yo u have po wered o n yo ur VM, all c o mmands will need to be do ne o n the c o ns o le o f the VM. shutdown -h now Once the server has shutdown, using your Hypervisor, add the new disk to the VM. In this example I will be adding a 100GB disk. Power on the VM and wait for it to boot up, once booted it will prompt you for the root password: Pre pare Ne w Dis k This will now show the new /dev/sdb disk: Now you will use fdisk to create a new partition: fdisk /dev/sdb The screenshot below shows the following commands you need to type: Command: n (primary partition): p (partition number): 1 For the first and last cylinder accept the defaults by pressing Enter Command: t (hex code): 8e Command: w

Now that the disk has been partitioned, the next step is to create the volume. This will now show the new /dev/sdb1 partition: The following steps will create a vo lume g ro up (vg_log) and a lo g ic a l vo lume (lv_log). vgcreate vg_log /dev/sdb1 lvcreate -l 100%VG -n lv_log vg_log The following steps will define the volume with an e xt4 filesystem. mkfs -t ext4 /dev/vg_log/lv_log

Finally we'll temporarily mount the new volume so we can use it and check it has been mounted by listing the directory. mkdir /mnt/tmp_vol mount -t ext4 /dev/vg_log/lv_log /mnt/tmp_vol/ ls -la /mnt/tmp_vol/ Mo ve Exis t ing /var/lo g To Ne w Lo c at io n Now we'll move the existing files in /var/log/ to the new volume. mv /var/log/* /mnt/tmp_vol/ Depending on the amount of files will depend how long this takes. If everything goes well, there will be no errors output on the screen. Once finished, check to see if there are any files remaining: ls -l /var/log

Just to be sure, check the new volume for the files: ls -l /mnt/tmp_vol This should output a bunch of files and folders. C o nf igure Ne w Dis k To Mo unt On Bo o t First we will un-mount the volume: umount /mnt/tmp_vol Next we add an entry to the /etc/fstab file to mount this volume to /var/log on bootup: echo /dev/vg_log/lv_log /var/log ext4 defaults 0 0 >> /etc/fstab Now reload the fstab file to mount the volume: mount -a Check the files and folders to see it mounted ok: ls -l /var/log/ If you see the same files and folders as you did after moving the files everything is OK. C o nf igure OS Fo r Mult i Us e r Mo de And Re boot Finally we are going to configure the operating system in multi user mode. systemctl set-default multi-user.target Now reboot: reboot

Final C he c k Once the server has rebooted, establish an SSH session to your server as the user root. df -h Here you'll see the disk has been mounted and is now /var/log with ample free space: This completes moving /var/log to a new disk drive on CentOS 7.x. Fina l Tho ught s This guide can easily be adapted to move any folder location to another disk. For any support related questions please visit the Nagios Support Forums at: http://support.nagios.com/forum/ Posted by: tle a - Tue, Feb 23, 2016 at 11:04 PM. This article has been viewed 5475 times. Online URL: https://support.nagios.com/kb/article/moving- var- log- 473.html