Thursday, May 29, 2014

How To Resize Logical Partition (LVM) In Linux

A Red Hat Certified System Administrator (RHCSA) is able to perform the following tasks:

  • Understand and use essential tools for handling files, directories, command-line environments, and documentation
  • Operate running systems, including booting into different run levels, identifying processes, starting and stopping virtual machines, and controlling services
  • Configure local storage using partitions and logical volumes
  • Create and configure file systems and file system attributes, such as permissions, encryption, access control lists, and network file systems
  • Deploy, configure, and maintain systems, including software installation, update, and core services
  • Manage users and groups, including use of a centralized directory for authentication
  • Manage security, including basic firewall and SELinux configuration.




Resize your logical partition to 950Mb and resize your logical volume to 150Mb.

CMD:

To increase the partition size use following commands,

root@linuxstorage:~#df -h

root@linuxstorage:~#lvextend -L 950M /dev/mapper/vgsrv-home

lvextend - extend the size of a logical volume.

Resize your file system with resize2fs


root@linuxstorage:~#resize2fs /dev/mapper/vgsrv-home
CMD: 

To reduce the partition size use following commands,

root@linuxstorage:~#df -h

Unmount the partition

root@linuxstorage:~#unmount /home

Run fsck on your file system



    root@linuxstorage:~#e2fsck -f /dev/mapper/vgsrv-home
    e2fsck 1.41.12
    Pass 1: Checking inodes, blocks, and sizes
    Pass 2: Checking directory structure
    Pass 3: Checking directory connectivity
    Pass 4: Checking reference counts
    Pass 5: Checking group summary information
 


Resize your file system with resize2fs

root@linuxstorage:~#resize2fs /dev/mapper/vgsrv-home 150M

Lvreduce - reduce the size of a logical volume

root@linuxstorage:~#lvreduce -L 150M /dev/mapper/vgsrv-home


Remount the partition

root@linuxstorage:~#mount -a

How To Configure FTP Server In Linux

A Red Hat Certified System Administrator (RHCSA) is able to perform the following tasks:

  • Understand and use essential tools for handling files, directories, command-line environments, and documentation
  • Operate running systems, including booting into different run levels, identifying processes, starting and stopping virtual machines, and controlling services
  • Configure local storage using partitions and logical volumes
  • Create and configure file systems and file system attributes, such as permissions, encryption, access control lists, and network file systems
  • Deploy, configure, and maintain systems, including software installation, update, and core services
  • Manage users and groups, including use of a centralized directory for authentication
  • Manage security, including basic firewall and SELinux configuration.




Configure a FTP server which is anonymous download to all user in your network and allow the user without authentication.

CMD:

VSFTPD stands for "Very Secure FTP Daemon" is a GPL licensed FTP server for UNIX systems. It supports IPv6 and SSL. vsftpd supports explicit (since 2.0.0) and implicit (since 2.1.0) FTPS. vsftpd is the default FTP server in the Ubuntu, CentOS, Fedora, NimbleX, Slackware and RHEL Linux distributions. It is secure and extremely fast.

 It is stable. VSFTPD is a mature and trusted solution which supports virtual users with PAM (pluggable authentication modules). A virtual user is a user login which does not exist as a real login on the system in /etc/passwd and /etc/shadow file. Virtual users can therefore be more secure than real users, because a compromised account can only use the FTP server but cannot login to system to use other services such as SSH or SMTP.

root@linuxstorage:~#yum install vsftpd* -y

First install vsftpd and relative packages using yum command.

root@linuxstorage:~#vim /etc/vsftpd/vsftpd.conf

# Allow anonymous FTP? (Beware - allowed by default if you comment this out).
anonymous_enable=YES

Check line number 12 in configuration. Enable anonymous_enable=YES by removing # symbol in front of it.

root@linuxstorage:~#service vsftpd restart

After changing the configuration restart and enable chkconfig service for ftp.

root@linuxstorage:~#chkconfig vsftpd on


How To Schedule Cron Job For Users In Linux

A Red Hat Certified System Administrator (RHCSA) is able to perform the following tasks:


  • Understand and use essential tools for handling files, directories, command-line environments, and documentation
  • Operate running systems, including booting into different run levels, identifying processes, starting and stopping virtual machines, and controlling services
  • Configure local storage using partitions and logical volumes
  • Create and configure file systems and file system attributes, such as permissions, encryption, access control lists, and network file systems
  • Deploy, configure, and maintain systems, including software installation, update, and core services
  • Manage users and groups, including use of a centralized directory for authentication
  • Manage security, including basic firewall and SELinux configuration.



Schedule cron job for user sowmya that every day "GoodMorning" message should be displayed at 19.27.

CMD:


root@linuxstorage:~#crontab -u sowmya -e

27             19         *              *              *              /bin/echo "hello"

:wq!

u    - Users
e    - Edit the file

32 -  Minutes
16 -  Hours ( 4 pm )
*   -  Every day
*   -  Every month
*   -  Every week                                    


wq! - save file

Cron will run every day at 7.27 pm.


root@linuxstorage:~#crontab -u sowmya -l

l = Print scheduled cron. 


root@linuxstorage:~#service crond restart

Enter the crond service in chkconfig

root@linuxstorage:~#chkconfig crond on

Wednesday, May 28, 2014

How To Configure NTP Client In Linux

A Red Hat Certified System Administrator (RHCSA) is able to perform the following tasks:



  • Understand and use essential tools for handling files, directories, command-line environments, and documentation
  • Operate running systems, including booting into different run levels, identifying processes, starting and stopping virtual machines, and controlling services
  • Configure local storage using partitions and logical volumes
  • Create and configure file systems and file system attributes, such as permissions, encryption, access control lists, and network file systems
  • Deploy, configure, and maintain systems, including software installation, update, and core services
  • Manage users and groups, including use of a centralized directory for authentication
  • Manage security, including basic firewall and SELinux configuration.



Configure NTP client


root@linuxstorage:~#system-config-date


Click the synchronize tab, Add server name (linuxstorages.com) as the table,

Click advanced option  and first option in that.


root@linuxstorage:~#service ntpd restart


Enable chkconfig for ntpd


root@linuxstorage:~#chkconfig ntpd on


Check chkconfig list of service


root@linuxstorage:~#chkconfig --list

How To Create Web Server In Linux

A Red Hat Certified System Administrator (RHCSA) is able to perform the following tasks:


  • Understand and use essential tools for handling files, directories, command-line environments, and documentation
  • Operate running systems, including booting into different run levels, identifying processes, starting and stopping virtual machines, and controlling services
  • Configure local storage using partitions and logical volumes
  • Create and configure file systems and file system attributes, such as permissions, encryption, access control lists, and network file systems
  • Deploy, configure, and maintain systems, including software installation, update, and core services
  • Manage users and groups, including use of a centralized directory for authentication
  • Manage security, including basic firewall and SELinux configuration.




Create a web server

Set document root to   /var/www/html

CMD:

root@linuxstorage:~#yum install httpd* -y

root@linuxstorage:~#vim /etc/httpd/conf/httpd.conf   (configuration path for web server)

#<VirtualHost *:80>
#    ServerAdmin webmaster@dummy-host.example.com
#    DocumentRoot /www/docs/dummy-host.example.com
#    ServerName dummy-host.example.com
#    ErrorLog logs/dummy-host.example.com-error_log
#    CustomLog logs/dummy-host.example.com-access_log common
#</VirtualHost>

copy the last 7 line and paste in last and change all dummy host in your hostname

change document root to /var/www/html

:wq   (save file)

root@linuxstorage:~#httpd -S    (to check above configuration is correct or not)

root@linuxstorage:~#httpd -t    (to check above configuration is correct or not)

root@linuxstorage:~#cd /var/www/html     (change directory to document root )

root@linuxstorage:~#vi index.html      (add some content in index.html to check )

Restart web server service after all configuration

root@linuxstorage:~#service httpd restart

Make sure httpd service is on in chkconfig so while server restarts this service will also will start if now we should manually start the service.So please on the service in chkconfig.



root@linuxstorage:~#chkconfig httpd on 

To check the web server in command line


root@linuxstorage:~#elinks httpd://linuxstorages.com

This will display the content of index.html which means our configuration is correct.

How To Create User With Particular UUID In Linux

A Red Hat Certified System Administrator (RHCSA) is able to perform the following tasks:


  • Understand and use essential tools for handling files, directories, command-line environments, and documentation
  • Operate running systems, including booting into different run levels, identifying processes, starting and stopping virtual machines, and controlling services
  • Configure local storage using partitions and logical volumes
  • Create and configure file systems and file system attributes, such as permissions, encryption, access control lists, and network file systems
  • Deploy, configure, and maintain systems, including software installation, update, and core services
  • Manage users and groups, including use of a centralized directory for authentication
  • Manage security, including basic firewall and SELinux configuration.



 How to create a user sowmya with UUID 199


CMD
root@linuxstorage:~#useradd -u 199 sowmya

root@linuxstorage:~#id sowmya
uid=199(sowmya) gid=1001(sowmya) groups=1001(sowmya)

id - this command use to check user details.

How To Update Kernel Version In Linux

A Red Hat Certified System Administrator (RHCSA) is able to perform the following tasks:


  • Understand and use essential tools for handling files, directories, command-line environments, and documentation
  • Operate running systems, including booting into different run levels, identifying processes, starting and stopping virtual machines, and controlling services
  • Configure local storage using partitions and logical volumes
  • Create and configure file systems and file system attributes, such as permissions, encryption, access control lists, and network file systems
  • Deploy, configure, and maintain systems, including software installation, update, and core services
  • Manage users and groups, including use of a centralized directory for authentication
  • Manage security, including basic firewall and SELinux configuration.



How to  install new kernel version.

CMD

root@linuxstorage:~#yum install lftp* -y

First install ftp service in server.

* - All dependency packages for ftp.
y - Install without asking permission.

 root@linuxstorage:~#lftp 192.168.1.1 

Connect the other server using ftp service (port - 21).

root@linuxstorage:~#cd /var/newfiles

change directory which having files in it.

root@linuxstorage:~#mget kernel-*

mget - use to download file from other server to our server.

root@linuxstorage:~#bye

bye - disconnecting ftp connection.

root@linuxstorage:~#rpm -ivh kernel-firmware*

rpm - redhat package management.
i - install package.
v - verbous

First install kernel firmware.

root@linuxstorage:~#rpm -ivh kernel-debug*

now install kernel package.

root@linuxstorage:~#uname -r

check current kernel version.

root@linuxstorage:~#vim /etc/grub.conf (check the title if updated kernel is in first title or default = 0)

root@linuxstorage:~#init 0   (reboot system)

root@linuxstorage:~#uname -r

now check the kernel version after restart, new kernel version is updated.


How To Create Collaborative Directory And Set Permission In Linux

A Red Hat Certified System Administrator (RHCSA) is able to perform the following tasks:

  • Understand and use essential tools for handling files, directories, command-line environments, and documentation
  • Operate running systems, including booting into different run levels, identifying processes, starting and stopping virtual machines, and controlling services
  • Configure local storage using partitions and logical volumes
  • Create and configure file systems and file system attributes, such as permissions, encryption, access control lists, and network file systems
  • Deploy, configure, and maintain systems, including software installation, update, and core services
  • Manage users and groups, including use of a centralized directory for authentication
  • Manage security, including basic firewall and SELinux configuration.


 Create a collaborative directory /linuxstorages/data with the following:

CMD:

  root@linuxstorage:~#mkdir -p /linuxstorages/data
                            p = can create a directory from any path.

  root@linuxstorage:~#chgrp -R central /linuxstorages/data

           chgrp = changing primary group for the directory.
         
            R = recursive . changes will reflect all sub-directories and files below sharedgrp.


  root@linuxstorage:~#chmod 2070 /linuxstorages/data

          chmod - modifying permission for sharedgrp.

          2070  - Giving full permission only to group users and zero permmision for other users.

           2 - Special Permission. set group id.
           0 -  User.(zero permission).
           7 -  4+2+1 = 7 (4= read, 2 = write, 1 = execute). Group user.
           0 - Other users.(zero permission).

How To Create Swap Partition In Linux

A Red Hat Certified System Administrator (RHCSA) is able to perform the following tasks:
  • Understand and use essential tools for handling files, directories, command-line environments, and documentation
  • Operate running systems, including booting into different run levels, identifying processes, starting and stopping virtual machines, and controlling services
  • Configure local storage using partitions and logical volumes
  • Create and configure file systems and file system attributes, such as permissions, encryption, access control lists, and network file systems
  • Deploy, configure, and maintain systems, including software installation, update, and core services
  • Manage users and groups, including use of a centralized directory for authentication
  • Manage security, including basic firewall and SELinux configuration.

 






 Create swap partition with 512 mb.

CMD:
                        root@linuxstorage:~#fdisk -cu /dev/vda
          
                      -command(for help m):n   (n - to create new partition)

                      -command(for help m):e   (e - extended partition)

                      - partition number:4

                      -firstsector= press enter

                      -last sector= by default(press enter)

                       -(logical,physical)

                        l    (l -logical)

                        first sector - by default

                       last sector = +512M

                      -t (and) type - partition number is 5

                     -hex code is 82  (for linux swap)

                     --w (save)

                     root@linuxstorage:~#init 6           (restarting system )

                     root@linuxstorage:~#mkswap /dev/vda5      (formating file structure)

                     root@linuxstorage:~#swapon /dev/vda5

                     root@linuxstorage:~#vim /etc/fstab  (enter new swap partition in fstab)

                    /dev/vda5     swap      swap  defaults   0     0

                   :wq (save the file)

                    root@linuxstorage:~# mount -a      

                    root@linuxstorage:~# swapon -s (to verify swap partition)

Monday, May 26, 2014

Cron Job In Linux

Cron is time-based job scheduler. People who set up and maintain software environments use cron to schedule jobs (commands or shell scripts) to run periodically at fixed times, dates, or intervals.

Cron is driven by a crontab (cron table) file, a configuration file that specifies shell commands to run periodically on a given schedule. The crontab files are stored where the lists of jobs and other instructions to the cron daemon are kept. Users can have their own individual crontab files and often there is a system wide crontab file (usually in /etc or a subdirectory of /etc) that only system administrators can edit.


Linux Crontab Format


  *         *             *        *          *                   /path-of-script
(min)   (hour)   (dom)   (mon)  (dow )


Field        Description       Allowed Value

MIN        Minute field         0 to 59
HOUR     Hour field           0 to 23
DOM      Day of Month     1-31
MON      Month field         1-12
DOW      Day Of Week     0-6

1. How to list crontab entries

root@linuxstorage:~#crontab -l

2. How to edit and add crontab entries

root@linuxstorage:~#crontab -e 

3.Schedule a Job for Every Minute Using Cron 

* * * * * .         /path-of-script

4.Schedule a Background Cron Job For Every 10 Minutes

*/10 * * * *     /path-of-script

5.Scheduling a Job For a Specific Time

30 09 10 08 *  /path-0f-script
job will run at Aug month(8 month) , 10 day , 9.30 time(am).

6. Schedule a Job For More Than One Instance

00 09,19 * * *   /path-of-script

00 - 0 minute
09 - 9 am
19 - 7 pm

job will run in both timings 9:00 & 19:00.

7 .Schedule a Job for Specific Range of Time

00 09-19 * * *   /path-of-script
09 - 19 = time from 9 to 19.  9,10,11,12,13,14,15,16,17,18 & 19.

job will run from 9:00 to 19:00 every one hour.

8. Cron for visiting URL

* * * * *    /usr/bin/wget   http://your-website/cron.php 

* * * * *   /usr/bin/curl      http://your-website/cron.php

* * * * *    /usr/bin/wget   -q -o http://your-website/cron.php  

Linux Commands - 4

This article explains some of the most used Linux commands and their basic usage which will be more helpful for beginners. All these commands should be entered at the command prompt and you must press the ENTER button to execute the desired command. Please note that all Linux commands are case sensitive.

31. rpm command

To install mysql using rpm

root@linuxstorage:~#  rpm -ivh mysql-server-5.5.i386.rpm

To upgrade mysql using rpm.

root@linuxstorage:~#  rpm  -uvh mysql-server-5.5.i386.rpm

To uninstall/remove mysql using rpm.

root@linuxstorage:~#  rpm -ev mysql

32. yum command 

 To install mysql

root@linuxstorage:~#yum install mysql -y

To upgrade mysql

root@linuxstorage:~#yum update mysql

To uninstall/remove mysql

root@linuxstorage:~#yum remove mysql

33. apt-get command

 
 To install mysql

root@linuxstorage:~#apt-get install mysql-server

To upgrade mysql

root@linuxstorage:~#apt-get update mysql-server

To uninstall/remove mysql 

root@linuxstorage:~#apt-get remove mysql-server

34. su - switch user. we switch to different users account in system using su command in terminal.Super user can switch to any other user without entering their password.

 root@linuxstorage:~#su - username

only su will change to root user.

 username@linuxstorage:~#su

35.  less-  less is very efficient while viewing huge files, as it doesn’t need to load the full file while opening.

 root@linuxstorage:~# less data.log

36. tail - tail use to view last 10 line in file.it's use full for viewing log files.

 root@linuxstorage:~#tail data.log

Print N number of lines from the file

root@linuxstorage:~#tail -n 20 data.log

now we can see last 20 line in that file.

37. whatis - Whatis command displays a single line description about a command.

root@linuxstorage:~#whatis cp
cp                   (1)  - copy files and directories
cp                   (1p)  - copy files

38. ps  - ps command is used to display information about the processes that are running in the system.

To view current running processes

root@linuxstorage:~#ps -ef | more
 UID        PID  PPID  C STIME TTY          TIME CMD
root         1     0  0 09:11 ?        00:00:00 /sbin/init
root         2     0  0 09:11 ?        00:00:00 [kthreadd]
root         3     2  0 09:11 ?        00:00:00 [migration/0]
root         4     2  0 09:11 ?        00:00:00 [ksoftirqd/0]
root         5     2  0 09:11 ?        00:00:00 [migration/0]
root         6     2  0 09:11 ?        00:00:00 [watchdog/0]
root         7     2  0 09:11 ?        00:00:00 [migration/1]
root         8     2  0 09:11 ?        00:00:00 [migration/1]
root         9     2  0 09:11 ?        00:00:00 [ksoftirqd/1]
root        10     2  0 09:11 ?        00:00:00 [watchdog/1]
root        11     2  0 09:11 ?        00:00:00 [events/0]
root        12     2  0 09:11 ?        00:00:00 [events/1]
root        13     2  0 09:11 ?        00:00:00 [cgroup]
root        14     2  0 09:11 ?        00:00:00 [khelper]
 more




to view particular service process id

root@linuxstorage:~#ps -ef |grep httpd
root      1871     1  0 09:11 ?        00:00:00 /usr/sbin/httpd
apache    2356  1871  1 10:26 ?        00:03:25 /usr/sbin/httpd
apache    2357  1871  0 10:26 ?        00:01:43 /usr/sbin/httpd
apache    2358  1871  0 10:26 ?        00:01:52 /usr/sbin/httpd
apache    2359  1871  0 10:26 ?        00:02:09 /usr/sbin/httpd
apache    2360  1871  0 10:26 ?        00:02:32 /usr/sbin/httpd
apache    2361  1871  0 10:26 ?        00:02:17 /usr/sbin/httpd
apache    2362  1871  0 10:26 ?        00:02:35 /usr/sbin/httpd
apache    2363  1871  0 10:26 ?        00:00:35 /usr/sbin/httpd
apache    3057  1871  0 12:47 ?        00:00:13 /usr/sbin/httpd

39. pgrep - pgrep is an acronym that stands for "Process-ID Global Regular Expressions Print".

pgrep looks through the currently running processes and lists the process IDs which matches the selection criteria to stdout. pgrep is handy when all you want to know is the process id integer of a process.


root@linuxstorage:~#pgrep httpd
1871
2356
2357
2358
2359
2360
2361
2362
2363

40. kill - Use kill command to terminate a process.First get the process id using ps -ef command, then use kill -9 to kill the running Linux process as shown below. You can also use killall, pkill, xkill to terminate a unix process.

First find the process id using below command

root@linuxstorage:~#pgrep httpd
1871

now kill that process id

 root@linuxstorage:~#kill -9 1871

Encrypt/Decrypt Zip File In Linux

We can see how zip utility is used and how it's beneficial to use as well as how to secure your zip files and what precautions you should take while zipping or while providing security to your zip files.To enhance security of zip files i have also included encryption and decryption concept a bit.

Encrypting a file in gpg command


root@linuxstorage:~#gpg -c data.zip
Enter passphrase:

gpg utility has been used here to encrypt the zip file.

-c option is used to create gpg based encrypted file.


root@linuxstorage:ls
data.zip.gpg

We can't able to unzip the gpg zipped file without decrypting. So first decrypt and then unzip the file.


root@linuxstorage:gpg data.zip.gpg
Enter passphrase:

now when you enter the passphrase which you have given during encryption time the file will be decrypted.


root@linuxstorage:unzip data.zip
root@linuxstorage:ls
data

How To Compress/Decompress File Or Folder In Linux

In Linux there various commands which  help us to compress and decompress a data. By doing a compression  we can able to reduce the size of the data and data will not be missing while transferring from one server to other.

Zip

zip is a compression and file packaging utility for Unix/Linux. Each file is stored in single .zip {.zip-filename} file with the extension .zip.

Compress for zip

root@linuxstorage:~#zip data.zip data
root@linuxstorage:~#ls
data.zip

Zip a folder for zip

root@linuxstorage:~#zip -r folder.zip data
root@linuxstorage:~#ls
folder.zip

Decompress

root@linuxstorage:~#unzip data.zip
root@linuxstorage:~#ls
data

Gzip 

Gzip compress the size of the given files using Lempel-Ziv coding (LZ77). Whenever possible, each file is replaced by one with the extension .gz.

gzip is a commonly used compression format in GNU/Linux platforms

Compress for gzip

root@linuxstorage:~#gzip data
root@linuxstorage:~#ls
data.gz

Decompress for gzip
 
root@linuxstorage:~#gunzip data.gz
root@linuxstorage:~#ls
data
 OR
root@linuxstorage:~#gzip -d data.gz
root@linuxstorage:~#ls
data


Bzip2

bzip2 compresses files using the Burrows-Wheeler block sorting text compression algorithm, and Huffman coding. Compression is generally considerably better than that achieved by bzip command (LZ77/LZ78-based compressors). Whenever possible, each file is replaced by one with the extension .bz2

Compress for bzip2
 
 root@linuxstorage:~#bzip2 data
 root@linuxstorage:~#ls
 data.bz2

 Decompress for bzip2

root@linuxstorage:~# bzip2 -ddata.bz2
or
root@linuxstorage:~#gunzip data.bz2
root@linuxstorage:~#ls
data
  
Gzip and Bzip2 with tarball

The GNU tar is archiving utility but it can be use to compressing large file(s). GNU tar supports both archive compressing through gzip and bzip2. If you have more than 2 files then it is recommended to use tar instead of gzip or bzip2

-z: use gzip compress
-j:
use bzip2 compress

Compress for gzip

root@linuxstorage:~#tar  -zcvf  data.tar.gz   [/path/files]
root@linuxstorage:~#ls
data.tar.gz
  • -z: Compress archive using gzip program
  • -c: Create archive
  • -v: Verbose i.e display progress while creating archive
  • -f: Archive File name
Decompress for gzip

root@linuxstorage:~#tar -zxvf data.tar.gz
root@linuxstorage:~#ls
data
  • -x: Extract files

Compress for bzip2

root@linuxstorage:~#tar  -jcvf  data.tar.bz2 [/path/files]
root@linuxstorage:~#ls
data.tar.bz2

Decompress for bzip2

root@linuxstorage:~#tar -jxvf data.tar.bz2
root@linuxstorage:~#ls
data



Sunday, May 25, 2014

How To Convert Ext3 to Ext4 and Ext2 to Ext4 In Linux

Ext4 provides some additional benefits and perforce over ext3  & ext2 file system. You can easily convert ext3 to ext4 file system and ext2 to ext4.

Converting from Ext3 to Ext4 file system.

1.  Login into linux system as root user.

2. Check current linux file system in fstab.

root@linuxstorage:~#cat /etc/fstab

which display all mount partition and current file system.


3. Unmount the mounted partition.

root@linuxstorage:~#umount /dev/sda5

4.tune2fs command is one of the advanced unix commands which allows you to adjust various tunable parameters of the ext2/ext3 filesystems. Naturally, it also helps you confirm the existing parameters configured for your filesystems.

 root@linuxstorage:~#tune2fs -O extents,uninit_bg,dir_index /dev/sda5

5. e2fsck is to check a Linux ext2/ext3 file system. e2fsck is a file system check utility that check the file systems for bad sectors , I/O errors related to HDD . e2fsck is used to check and optionally repair one or more Linux file systems. 

root@linuxstorage:~# e2fsck -pf /dev/sda5

6.Remount the converted file system.


 root@linuxstorage:~#mount /dev/sda5 /

7.Reboot the system.

 root@linuxstorage:~#init 6

8. Test all the above command in testing server. While doing in production server please backup all data's and implement these above command.



Converting from Ext2 to Ext4 file system


1.  Login into linux system as root user.

2. Check current linux file system in fstab.

root@linuxstorage:~#cat /etc/fstab

which display all mount partition and current file system.


3. Unmount the mounted partition.

root@linuxstorage:~#umount /dev/sda5

4. .tune2fs command is one of the advanced unix commands which allows you to adjust various tunable parameters of the ext2/ext3 filesystems. Naturally, it also helps you confirm the existing parameters configured for your filesystems.

root@linuxstorage:~#tune2fs -O dir_index,has_journal,uninit_bg /dev/sda5

5.e2fsck is to check a Linux ext2/ext3 file system. e2fsck is a file system check utility that check the file systems for bad sectors , I/O errors related to HDD . e2fsck is used to check and optionally repair one or more Linux file systems. 


 root@linuxstorage:~# e2fsck -pf /dev/sda5

6.Remount the converted file system.


 root@linuxstorage:~#mount /dev/sda5 /

7.Reboot the system.

 root@linuxstorage:~#init 6

8. Test all the above command in testing server. While doing in production server please backup all data's and implement these above command.

How To Convert Ext2 To Ext3 Files System In Linux

We can able to convert from ext2 to ext3 to improve your linux file system.  Ext2 filesystem has been the Linux default but when the computer is rebooted or powered off without correctly shutting down, Ext2 filesystems are placed in an error state. When the computer comes back up, the user is confronted with some mildly confusing, and very intimidating, messages and choices, this may lead to warning, of  lose data.

Journalized filesystems are made to eliminate such error messages. The Ext3 filesystem is an Ext2 filesystem with a journal file and some filesystem driver additions making the filesystem journalized.


1.  Login into linux system as root user.

2. Check current linux file system in fstab.

root@linuxstorage:~#cat /etc/fstab

which display all mount partition and current file system.

3. Unmount the mounted partition.

root@linuxstorage:~#umount /dev/sda5


If you can't unmount it, then remount it read only (mount -o remount,ro /dev/sda5).

4. tune2fs -j /dev/sda5

root@linuxstorage:~# tune2fs -j /dev/sda5

5. Edit /etc/fstab, and for /dev/sda5, change ext2 to ext3.

root@linuxstorage:~#vi /etc/fstab

6. mount the converted file system partition(sda5 ).

root@linuxstorage:~#mount /dev/sda5

7.Reboot the system and check the file system.

root@linuxstorage:~#init 6

Difference between Ext2, Ext3 & Ext4


Ext stands for Extended file system. In this article we can discuss about difference between  ext2, ext3 & ext4 file systems in linux and specification for each file system.Ext2 file system is default file system in linux.


Ext2(Extended 2 file system )
Ext3(Extended 3 file system )
Ext4(Extended 4 file system )
This was developed to overcome the limitation of the original ext file system.
The main benefit of ext3 is that it allows journaling. Journaling has a dedicated area in the file system, where all the changes are tracked. When the system crashes, the possibility of file system corruption is less because of journaling.
The ext4 file system has major improvements in terms of performance, scalability, and reliability.
Maximum individual file size can be from 16 GB to 2 TB
Overall ext2 file system size can be from 2 TB to 32 TB
Maximum individual file size can be from 16 GB to 2 TB
Overall ext2 file system size can be from 2 TB to 32 TB
support files and file systems of up to 16 terabytes in size
You can’t convert a ext2 file system to ext3 file system
You can convert a ext2 file system to ext3 file system directly (without backup/restore).
You can convert a ext3 file system to ext4 file system directly
Ext2 faster than ext3
prevent filesystem corruption in the case of an unclean shutdown, That makes ext3 a bit slower than ext2
. Ext4 uses extents , which improves performance when using large files and reduces metadata overhead for large files
it has sparse super blocks feature which increase file system performance
But ext3 gets more reliability and a better performance
The ext4 file system, often waits several seconds to write out changes to disk, allowing it to combine and reorder writes for better disk performance than ext3
Ext2 will not provide a fast recovery from disk problems
allows fast recovery from disk problems
ext4 also labels unallocated block groups and inode table sections accordingly, which allows them to be skipped during a file system check. This makes for quicker file system checks, which becomes more beneficial as the file system grows in size.








 

© 2014 Linux Storages | Updated . All rights resevered. Designed by Templateism