wiki.ipfire.org

The community-maintained documentation platform of IPFire

User Tools

Site Tools


optimization:transfer_logs:start

Transfer the logs to an external drive

When using a CF-card as the system disk, it is advisable to link permanent writing files to an external media to extend the lifetime of that flash memory. An external hard drive can be for example an USB stick or USB hard drive.

Preparation of the USB-media

Integrate the hard disk via Webinterface

The first step is to connect the device to one of IPFire's USB ports. Then the external media will be tethered by the service ExtraHD via the webinterface in the section –>services–>ExtraHD. In the area below the new media /dev/sdb can then be integrated by clicking the red pencil with the “+” symbol.

external_hd_add_en.jpg

Now the new media should be listed in the upper section of the “ExtraHD” site and may look similar to the following screenshoot:

extra_hd_mounted.jpg

UUID=abcd1234-1234-1234-abcd-1234567890 	auto 	/mnt/WhatEverYouEntered

Prepare IPFire over the shell

Connect to IPFire now via Putty, WinSCP or simply by the console via SSH .

You should enable the SSH service and log in with:

user@mypc:$ ssh -p 222 root@yourIPFromIPFire 

Now the new target directory, where the logs should be placed on the new media, will be shown.

1. Create the log directory for the USB-media:

user@myipfire~:#mkdir /mnt/MyNewHD/log

2. Copy the existing log file content to the new directory:

user@myipfire~:#cp -a /var/log/* /mnt/MyNewHD/log/

3. Investigate the UUID if it isn´t established yet:

[user@myipfire~]# ls -l /dev/disk/by-uuid
total 0
lrwxrwxrwx 1 root root 10 2012-01-14 12:56 qwertzui-2af7-4729-qrst-123456789012 -> ../../sda4

lrwxrwxrwx 1 root root 10 2012-01-14 12:56 asdfghjk-1318-4239-mnop-123450987650 -> ../../sdb1

lrwxrwxrwx 1 root root 10 2012-01-14 12:56 yxcvbnmä-573a-4713-ijkl-567890543215 -> ../../sdb2

lrwxrwxrwx 1 root root 10 2012-01-14 12:56 üpoiuztr-9231-4524-efgh-098765432109 -> ../../sda1

lrwxrwxrwx 1 root root 10 2012-01-14 12:56 äölkjhgf-fb35-4922-abcd-222223334444 -> ../../sda3

Info: sda1 & 3 & 4 are the sectors of three partitions of the system on the CF Card

Info: sdb1 is on the USB-media which will be used for the log directory

Info: sdb2 is a section on the USB-media which won´t be used in here

Customize the FSTAB

1. Now the FSTAB will be configured with the investigated UUID for e.g. sdb1:

user@myipfire~:#nano /etc/fstab

Attention: By misusing nano or another editor during the modification of FSTAB, it may happen that your system don´t work properly anymore, so take care when changing this entries.

Find some additional information how to use Nano here.

 UUID=asdfghjk-1318-4239-mnop-123450987650 /var/log ext2 defaults 0 0

2. Rename the log file:

user@myipfire~:#cd /var/
user@myipfire~:#mv log logold

3. Secure remove of the log backup (e.g. with logged):

user@myipfire~:#cd /var/
user@myipfire~:#rm -rf logold

If you delete the directory, it is possible some functions are bugging out (e.g. cron/logwatch) and statistics may be wrong. So it should only be deleted if you are really sure that the USB-media is used for the log. This can be checked if the Firewall-Logs in the webinterface are up to date.

4. Now create a symbolic link, otherwise the system will do it:

user@myipfire~:#cd /var/
user@myipfire~:#ln -s /mnt/MyNewHD/log/ /var/log

5. Check if the symbolic link was created:

user@myipfire~:#cd /mnt/MyNewHD/log
user@myipfire~:#ls -al

The output should look like:

rwxrwxrwx 1 root root 10 2012-01-14 12:56 log -> /var/log

Now the system can be rebooted and from now on the logs should be written to the USB-media.

After updates the symbolic links will be overwritten and set back to default. Repeat the steps from “mv log logold” –> “ln -s /mnt/MyNewHD/log/ /var/log” and reboot the system to let the changes on the system take effect. That´s it.

If there are update jumps over min. two versions, the log directory should be copied back to the CF-card otherwise faults will be occur.

The IPFire team would like to say thanks to 5p9 for this wiki :-)

optimization/transfer_logs/start.txt · Last modified: 2018/08/24 22:40 by Jon