Sunday, January 27, 2013

Unveiling the Significance of Disk Partitioning in Linux

Disk Partitioning is a general practice followed by Linux users to split their hard disk space into two or more logical sections. This is typically done to isolate user data from program files and operating system files. Disk partitioning in Linux is performed with the help of partition editors, such as fdisk. A majority of Linux sys admins are inclined to keep two partitions on the hard drive, i.e. root partition and swap partition. However, this approach is not reliable. The idea of having multiple partitions on your hard drive always proves to be worthwhile. The following things may benefit you if you are using Linux on a server:

Enhanced Reliability
If your operating system installation goes corrupt or the underlying file system turns bad, you can easily have your system up and running in no time. You data will remain unaffected even if the operating system files are damaged.

Performance
You can have a dedicated swap partition to enhance performance. Working with smaller file systems can help reduce errors and the risk of corruption.

Stability and Efficiency
Having several partitions with different file systems can help to improve disk space efficiency. You can format your hard disk with different block sizes according to the size of files to be stored on the drive.


Suppose you are using 120 GB SCSI hard disk containing only two partitions: '/' and swap. If you perform an operation that consumes all of your disk space, it can result in total disaster. The file system can face a denial-of-service attack (DoS attack). It will temporarily become unavailable to the user. For instance, you may run the following script using cron in your /tmp directory:

#!/bin/sh
man bash > $(mktemp)
$0
It can consume all disk space available in /var/log/. You may run the risks of following if you do not consider having a partition schema:
  • Unable to do performance tuning
  • Unable to mount /usr as read only for security reasons
  • Denial of Service Attack

Not having a partition schema increases the risks of file system corruption, which indeed causes data loss on your Linux system. If you run into a similar problem, take help of professional Linux data recovery software. These software have dedicated mechanisms for fixing file system corruption and safely recovering all your irreplaceable data stored on the Linux hard disk. In addition, they support all the mainstream Linux distributions, such as Debian, Unix, Red Hat, and more. 
 

Thursday, January 24, 2013

Detailed Procedure to Run 'fsck' for Fixing Linux File Systems

The Linux operating system may comprise several file systems, one for each partition on your hard drive. These file systems become vulnerable to corruption after a disgraceful shutdown of your Linux computer. Power surges, hardware failures, and human errors are a few typical causes of file system damage in Linux. A useful file system check utility called ‘fsck’ is bundled with all Linux distributions. It enables you to correct errors and fix corruption in Linux file systems. However, you can use this command only in single user mode that allows only the root user to log in to the Linux system. Moreover, the command supports only journaling file systems that maintain a record of changes made to the file system. You should unmount the partition to be checked before using this command. For performing a check on the root file system, you should use a Linux Live CD for unmounting the entire drive.

Using ‘fsck’ command to fix Linux file system corruption:
  • Navigate to the terminal window. To do this, go to ‘Applications’ or ‘Programs’ menu, and then the ‘Accessories’, ‘Utilities’ or ‘Xterm’ section. You will find the terminal window.
  • Type the command ‘su’ to run as a root user and specify the root password when asked for.
  • Run the ‘mount’ command. This will display a list of all file systems on your hard drive. Determine the name and type of the file system to be fixed. The name can be anything like ‘dev/sda2’ or ‘/home’.
  • Run the command ‘init 1’ to switch to single user mode or run level one. Now, only the root user can access the system. You will not have access to the network or any daemons running in this mode.
  • Run the following command at the file system to unmount the file system to be fixed:
    Umount /dev/sda2

    (Assuming ‘/dev/sda’ to be the file system you need to fix)
  • Run the following command to scan and repair the file system:
    fsck -t ext2 /dev/sda2

    (Assuming the type of file system to be ‘ext2’)
  • The time taken by this command would depend on the size of your file system.
  • Repeat the two preceding steps until all the errors have disappeared.
  • Remount the file system by running ‘mount /dev/sda2’.
  • Run the command ‘init 3’ to switch to multi-user mode.

In case you have issues with your file system even after the aforementioned fix, take help of professional Linux data recovery software. With these advanced tools, you can fix Linux file system corruption and easily recover all your seemingly lost data stored on the Linux hard drive.

Friday, January 18, 2013

How to Get Back Accidentally Deleted Files in Linux Using Simple Terminal Commands

Much to the delight of a Linux user, it takes only a little effort to recover an accidentally deleted file in Linux provided the file is still intact on the hard disk. If you have heard about file deletion in Windows, it has the same concept in Linux as well. When a file gets deleted from your Linux system, only a link to an inode on your disk is broken. This inode stores essential information with respect to the file. If the process that deleted the file still has it open, the inode cannot be used for writing. Thus, the deleted file can be recovered, but only for that fairly short time period. You can search for the directory corresponding to this process by running the command ‘ls /proc’. This will list all the currently running processes as directories along with their names or PIDs. To know the PID of a specific process, you can use the ‘ps’ command. After finding the process in /proc, you may collect the data from this directory and save it again. 

For instance, you have a file named ‘test_file’ that contains some text. Let us first delete this file and then recover it using the aforementioned approach:

  • Run the ‘less’ command to see the contents of ‘test_file’ as follows:
    less ~/test_file
  • Once the file is opened, press the ‘Ctrl’ and ‘z’ keys together. This will make the process a ‘zombie’.
  • Run the command ‘ls -l ~/test_file’ to see if the file is still there.
  • Next, delete the file with the command ‘rm ~/test_file’.
  • If you again check this file using the ‘ls’ command, you will find that the file is not there anymore. As you have zombied the command that was used to view the contents of the file, you can still recover this file from the data withheld.
  • Run the following command:
    ‘lsof | grep test_file’ 
  • This can make you wait for a while. In the end, you will be presented with something like:
    less 14675 zombie 4r REG 8,1 21 5127399 /home/zombie/test_file (deleted)
  • Get the PID of the file (i.e. value in the second column – ‘14675’) and its descriptor (in fourth column – ‘4’).
  • Run the below command to recover the file:
    ‘cp /proc/14675/fd/4 ~/recovered_file’
  • View the contents of the recovered file as follows:
    ‘less ~/recovered_file’

In case you fail to do a successful recovery, use professional data recovery Linux utilities. These software can rigorously scan your drive to recover every piece of valuable information from your Linux system.

Wednesday, January 9, 2013

Examining 'Nuts and Bolts' of a Linux File System and Related Data Corruption

A Linux file system comprises a set of files and directories stored together on a separate partition on your hard disk. Digging a little deeper, it contains user data and metadata. User data is the actual information stored in files, whereas metadata represents the objects that keep your file system's structural information (such as inodes, directories, and superblock). Overall, the file system is divided into blocks. Each block either contains user data or metadata. One block that is the most critical to your file system is superblock.

A Linux superblock has every information about your file system, i.e. file system type, size, status, and information about other objects. This information is required for the proper functioning of various file system operations. If something corrupts the superblock, you will be at the risk of losing all data on the hard disk. This is the reason why a file system contains multiple copies of its superblock. In the event that the block damages or corrupt itself, you can take help of these backup copies to rebuild or restore the primary superblock. You can use the following command to find out the location of the primary and backup superblock on a partition ('/dev/sda3' in this case):

# dumpe2fs /dev/hda3 | grep -i superblock

Linux is no exception to file system failures. They can occur because of plethora of reasons, such as power failures, faulty device drivers, kernel bugs, and human errors. A common sign is that the file system will fail to mount. In case you are able to mount the corrupt file system, you will have intermittent problems of system hangs, hard reboots, and more. Further, you may see some gibberish characters in your directory listings.

You can force a file system check on a particular partition using 'e2fsck' utility with the '-f' option as follows:

# e2fsck -f /dev/sda3

If the utility fails to find the primary superblock, it may return a fatal error. You can also use this command to get the backup superblock location:

# mke2fs -n /dev/sda3

Run the below given command to fix file system corruption using the backup or alternate superblock:

# e2fsck -f -b 8193 /dev/sda3

If the above resolution fails to repair the file system, you should take help of professional Linux data recovery software. Using these utilities, you can easily repair all types of Linux file systems. Further, you can quickly regain access to all lost files, photos, videos, and other personal information in your system.



Wednesday, January 2, 2013

How to Salvage Your Data Post Linux File System Failures

Every time you do not blame the operating system for issues. Even if you are running solid operating system and using robust file system, you are not immune to failures or corruption. Anything can go wrong with your hardware and cause the underlying file system to get corrupt. In such situations, you will find files missing from their original folders or deleted accidentally from your system. However, if you are using Linux, then you are still on the safe side. A range of essential utilities are built into Linux that can help you get past typical file system errors and recover your deleted files intact. 'e2fsck' is one of the critical Linux file system check tools used for the Ext2/Ext3/Ext4 family of file systems.

The e2fsck tool is a successor to UNIX fsck utility. It can verify the integrity of your file system to repair corruption induced by an unclean shutdown or other similar reasons. Further, it can repair a range of file system errors. One issue that is a pain in the neck for many is that the e2fsck tool can be only used for unmounted partitions. This means you cannot repair a file system that you are currently working on. One way out of this problem is to get your system to run level 1 using 'Init 1' and then unmount the file system to be checked. To run this command, you need to have administrator's rights.

Once you get your system to run level 1, unmount the partition (for instance /dev/sdb1) as follows:

umount /dev/sdb1

Next, perform the check by running 'e2fsck' as shown:

e2fsck -y /dev/sdb1


The '-y' option used with e2fsck will specify 'Yes' for each of the questions asked by the command. The e2fsck utility will find errors on the file system and repair them at the same time. The overall time taken by the repair varies depending on the size of the partition and the extent of corruption. You can rerun the same command to see if all the errors have disappeared.

An alternative to the above workaround is to use your distribution's live CD for booting and then perform the file system check. After performing the check, you need to unmount the file system. If the same errors occur again, you can take help of professional Linux data recovery software. These software enable you to fix file system errors and recover every bit of precious data from your Linux systems. 

Wednesday, February 29, 2012

How to Run Safely E2fsck on a Live, Mounted File System in your Linux system without Facing Data Loss


File system corruption is a common issue faced by Linux users over and over again. This problem usually results due to sudden power failures, bugs in the Linux code, hardware issues, etc. Linux has an inbuilt tool 'e2fsck' that is responsible for verifying and checking the consistency of the ext2/ext3/ext4 family of file systems. In case of ext3 and ext4 file systems that use journaling, this program generally replays the journal and then terminates. 

In a majority of cases, the file system is marked as clean after the application of journal. However, if the superblock shows that the file system needs repair, 'e2fsck' will carry out further processing. If the 'e2gsck' tool fails to repair corruption in the file system, you need to use advanced Linux Data Recovery software.

It is not safe or recommended to run 'e2fsck' on a mounted file system. This may lead to disk corruption and subsequent data loss. To do this, you can try the following two methods:

I)       Try to take your system to a single user mode and then unmount it:

·         Run 'init' (process control initialization) command to switch to runlevel 1, i.e. single user mode.
# init 1

·         Now, unmount '/home' file system with the help of 'umount' command.
# umount /home
# umount /dev/sda

·         Run the fsck or e2fsck tool
# fsck /home
or
# fsck /dev/sda3
or
# e2fsck -y /dev/sda3

II)    Boot your Linux computer using the installation CD and switch to rescue mode:

·         If you have Cent OS/Fedora Core/RHEL Linux, boot from the installation disc and run the following command at the boot prompt:
boot: linux rescue nomount
·         Create a new node for your hard disk and partition 3:
# mknod /dev/sda
# mknod /dev/sda3
# fsck /dev/sda3

You can also do the following:
# e2fsck -y /dev/sda3

If 'e2fsck' fails to resolve your file system issues, you should take help of a professional data recovery Linux utility. These third-party tools have a knack of recovering every bit of your lost, deleted, or formatted data from Linux hard drives and volumes. They support Ext4, Ext3, Ext2, FAT32, FAT16, and FAT12 file systems. 

Some of these utilities also provide an option to create an clone or exact replica of your hard drive. Moreover, they include support for all commonly-used Linux distributions, such as Red Hat, SUSE, Debian, Caldera, Mandrake, etc.