Inodes, Compression and Archiving
Inodes, Compression and Archiving
It deals with how data is write to the hard disk, Linux file system in RHEL 6 was
ext4, now the file system in RHEL 7 is xfs. In windows FAT32, NTFS.
In Linux each partitions have its own partition table we called this table inode
table, this table holds information about each file and directory.
Each inode represents no. of blocks that is reserved for each file. So it is very
limited resource.
Note: on copy new inode created, in move the inode did not changed (in the same
partition), but move in different partition will make copy first then move with new
inode.
Note: every directory have its own partition table, each directory must have the .
and .. To see this we can use ls -ila.
We have two types of inodes hardlink or softlink.
Hard link create in the same partition, it can be used for backup:
[root@server /]# ln /root/f1 /home/iti/f20
ln: failed to create hard link ‘/home/iti/f20 ==> ‘/root/f1’: Invalid cross-device link
Note: see the pointer to the original file with the permissions and type of file, soft
link can be used between directories.
[root@server /]#stat /var/log/messages ==> to see the access, modification and
Change time.
Compression:
Before we compress we have to decide some points:
-performance: time take to compress the files.
-Compression ratio: save the size of the file after backup.
1. gzip:
[root@srv1 ~]# ls –lh
/run/log/journal/b35c19c139b74e8082e555b588764007/system.journal
-rw-r-----+ 1 root systemd-journal 8.0M Nov 15 13:28
[root@srv1 ~]# cp
/run/log/journal/b35c19c139b74e8082e555b588764007/system.journal
system.log
[root@srv1 ~]# ls -lh system.log
-rw-r-----. 1 root root 8.0M Nov 15 13:40 system.log
It is the fastest compression tool and it is the most popular among linux
distributions.
2. Bzip2:
To compress the file via bzip2 tool:
[root@srv1 ~]# bzip2 system.log
[root@srv1 ~]# ls -lh system.log.bz2
-rw-r-----. 1 root root 752K Nov 15 13:40 system.log.bz2
Note: bzip2 compress the file but it takes more time than gzip but the
compression ratio is perfect.
Note: xz tool have the highest compression ration but takes more time.
Archiving:
It is used to make backup of important file, there is big difference between archive
and compression but they can integrate with each other.
Backup files: root scripts, home directory, yum configuration, ssh configuration,
logs.
If we use the option -f so it will make backup as a file, but its default to take our
backup to tape drive.
It helps you to create the same directory structure to be extracted in the other
location.
When taking the archive with absolute path, the leading / is removed from the file
name by default and the files extracted relative to the current working directory of
the tar command.
Note: the tar command did not store file SEinux contexts and ACL.
[root@srv1 ~]# tar -cvf home.tar /home ==> to backup and create the tar file
[root@srv1 ~]# ls -lh home.tar
-rw-r--r--. 1 root root 12M Nov 15 14:59 home.tar
[root@srv1 ~]# tar -tf home.tar ==> to show file inside the home.tar
[root@srv1 ~]# tar -xf home.tar home/ali/.bashrc ==> to extract one file from the
archive.
Machine centos8:
[root@srv1 backup]# ip addr show ens160 | grep -w inet
inet 192.168.10.25/24 brd 192.168.10.255 scope global noprefixroute ens160
To copy directory to machine centos 8, we use the option -r with scp command
Centos8 machine: