Sei sulla pagina 1di 62

http://sysadminview.

com/compare-linux-xfs-vs-ext4-file-system/

How to Fix issue with File system Superblock in


Red Hat Linux
Leave a reply

Sometimes the file system superblock is getting corrupted. In worst case scenario we are also not
able to run the file system check. By default file system check will be performed the on the
superblock located at 0.
But nothing to worry as we know the superblock is having multiple copies saved at different locations
in a file system. We can use those copies to to run the e2fsck on file system or to mount the file
system.
Now the question arises

How would we come to know about the location of copies of superblock?

How can we run the file system check using another copy of superblock?

How can we mount the file system using another copy of superblock?

In this article I am going to address all these questions.


I have one file system of 19G on which I am going to perform all the actions.
Question 1 : How would we come to know about the location of copies of superblock?
Answer 1 : dumpe2fs and mke2fs commands can be used to know about superblock.
dumpe2fs : This command can be used on mounted file system as well means the file systems
which are working absolutely fine.
After running this command you will get to know each and every term associated with file system
from that platheora of information you can capture only superblock information.
[root@node1 ~]# dumpe2fs /dev/mapper/VolGroup01-VolLV01 | grep -i superblock
dumpe2fs 1.41.12 (17-May-2010)
Primary superblock at 0, Group descriptors at 1-2
Backup superblock at 32768, Group descriptors at 32769-32770
Backup superblock at 98304, Group descriptors at 98305-98306
Backup superblock at 163840, Group descriptors at 163841-163842
Backup superblock at 229376, Group descriptors at 229377-229378
Backup superblock at 294912, Group descriptors at 294913-294914
Backup superblock at 819200, Group descriptors at 819201-819202

Backup superblock at 884736, Group descriptors at 884737-884738


Backup superblock at 1605632, Group descriptors at 1605633-1605634
Backup superblock at 2654208, Group descriptors at 2654209-2654210
Backup superblock at 4096000, Group descriptors at 4096001-4096002
mke2fs : This command should be run on unmounted file system. NOTE : Dont run this command
without -n option.
[root@node1 ~]# mke2fs -n /dev/mapper/VolGroup01-VolLV01
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
1245184 inodes, 4980736 blocks
249036 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
152 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000
So first most important question is answered.
Question 2 : How can we run the file system check using another copy of superblock?
Answer 2 : As we were not able to run the file system check on superblock at 0 location. Hence we
proceed with file system check on superblock at 32768(Value taken from Step1 output).
Able to run the file system check on copy of superblock.
[root@node1 ~]# e2fsck -b 32768 /dev/mapper/VolGroup01-VolLV01
e2fsck 1.41.12 (17-May-2010)
One or more block group descriptor checksums are invalid. Fix<y>? yes
Group descriptor 0 checksum is invalid. FIXED.
Group descriptor 1 checksum is invalid. FIXED.
Group descriptor 2 checksum is invalid. FIXED.

Group descriptor 3 checksum is invalid. FIXED.


Group descriptor 4 checksum is invalid. FIXED.
Question 3 : How can we mount the file system using another copy of superblock?
Answer 3 : As we are not able to mount the file system using default superblock which starts at 0.
We will try to mount the file system copy of superblock.
[root@node1 ~]# mount -o sb=98304 /dev/mapper/VolGroup01-VolLV01 /var/crash1
Tip : One useful command to determine when the file system is created and last mount time
[root@node1 ~]# dumpe2fs -h /dev/mapper/vg_node1-lv_root | grep -E Filesystem created|Last
mount time
dumpe2fs 1.41.12 (17-May-2010)
Filesystem created: Fri May 9 15:05:30 2014
Last mount time: Thu Jun 26 22:37:06 2014

https://ervikrant06.wordpress.com/2014/06/26/how-to-fix-issue-with-file-systemsuperblock-in-red-hat-linux/

How to take backup of GFS2 in Redhat ?


Leave a reply

As we know that in case of clustered file system its not possible to take the snapshots. To take the snapshot we
have to mount them exclusively. To show how to do that
I have created two node Redhat cluster and mounted one GFS2 file system on mount point /mygfs2 on both
nodes.
My Test Lab OS : Redhat 6.2 64 bit
[root@Node1 mygfs2]# clustat -l
Cluster Status for Shiv @ Tue Sep 30 03:08:18 2014
Member Status: Quorate
Member Name
192.168.56.10
192.168.56.11

ID Status
-
1 Online, Local
2 Online

[root@Node1 ~]# df -h /mygfs2/


Filesystem
Size Used Avail Use% Mounted on

/dev/mapper/gfs_vg1-gfs_lv1
700M 281M 420M 41% /mygfs2
[root@Node2 ~]# df -h /mygfs2/
Filesystem
Size Used Avail Use% Mounted on
/dev/mapper/gfs_vg1-gfs_lv1
700M 281M 420M 41% /mygfs2
Step 1 : I have unmounted the GFS2 file system on both cluster nodes.
[root@Node1 ~]# umount /mygfs2
[root@Node1 ~]#
[root@Node2 ~]# umount /mygfs2
[root@Node2 ~]#
[root@Node1 ~]# lvs gfs_vg1/gfs_lv1
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
gfs_lv1 gfs_vg1 -wi-a- 700.00m
[root@Node2 ~]# lvs gfs_vg1/gfs_lv1
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
gfs_lv1 gfs_vg1 -wi-a- 700.00m
Step 2 : Deactivate the logical volume on both nodes using below commands.
[root@Node1 ~]# lvchange -an gfs_vg1/gfs_lv1
[root@Node1 ~]# lvs gfs_vg1/gfs_lv1
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
gfs_lv1 gfs_vg1 -wi 700.00m
[root@Node2 ~]# lvchange -an gfs_vg1/gfs_lv1
[root@Node2 ~]# lvs gfs_vg1/gfs_lv1
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
gfs_lv1 gfs_vg1 -wi 700.00m
Step 3 : Changed the logical volume to exclusive single node by using below command. This needs to be
done only on one node.
[root@Node1 ~]# lvchange -aey gfs_vg1/gfs_lv1
[root@Node1 ~]# lvs gfs_vg1/gfs_lv1
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
gfs_lv1 gfs_vg1 -wi-a- 700.00m
Step 4 : Created the snapshot volume from that volume. Snapshot volume is named as snap and it is of
size 100MB.
[root@Node1 ~]# lvcreate size 100M snapshot name snap /dev/gfs_vg
Logical volume snap created

[root@Node1 ~]# lvs


LV VG
Attr LSize Origin Snap% Move Log Copy% Conver
gfs_lv1 gfs_vg1 owi-a- 700.00m
snap gfs_vg1 swi-a- 100.00m gfs_lv1 0.00
Step 5 : I mounted the snapshot volume on one temporary mountpoint to access the data inside it.
[root@Node1 ~]# mount -o lockproto=lock_nolock /dev/gfs_vg1/snap /mnt
[root@Node1 ~]# df -h /mnt
Filesystem
Size Used Avail Use% Mounted on
/dev/mapper/gfs_vg1-snap
700M 281M 420M 41% /mnt
Step 6 : After that I tried to mount the original file system I was getting error this was becuase my snap
was still mounted. I unmounted my snap volume and tried to mount the original volume again after
changing the volume to cluster mode.
[root@Node1 ~]# lvchange -aen gfs_vg1/gfs_lv1
LV gfs_vg1/gfs_lv1 has open snapshot snap: not deactivating
[root@Node1 ~]# umount /mnt
[root@Node1 ~]# lvchange -aen gfs_vg1/gfs_lv1
[root@Node1 ~]#
[root@Node1 ~]# lvchange -aey gfs_vg1/gfs_lv1
Step 7 : I removed the snap volume otherwise if you start using original volume and snap volume
reaches 100% value then it will create trouble.
[root@Node1 ~]# lvremove /dev/gfs_vg1/snap
Do you really want to remove active logical volume snap? [y/n]: y
Logical volume snap successfully removed
References :
How to backup GFS2 file system ?
https://access.redhat.com/solutions/307333
https://access.redhat.com/solutions/19283
How to change cluster Logical volume to non-clustered ?
https://access.redhat.com/solutions/3618
Why backup using rsync is very slow in GFS2 ?
https://access.redhat.com/solutions
This entry was posted in RedHat Cluster, RHEL 7 and
tagged backup, clustered, gfs2, snapshot on October 1, 2014.

Redhat Cluster Cheat Sheet Part 1


Leave a reply

Its a two Node cluster without any fencing device. I am trying to show you here the basic commands which we
can use to check the status of cluster these commands are also helpful from interview prospective.
How to check the version of cluster ?
[root@Node2 ~]# cman_tool -V
cman_tool 3.0.12.1 (built May 8 2012 12:22:25)
Copyright (C) Red Hat, Inc. 2004-2010 All rights reserved.
How to list the gfs2 file system present on server ?
GFS file system can be mounted simultaneously on multiple nodes. To check on how many nodes it is
mounted.
[root@Node2 ~]# gfs2_control ls
gfs mountgroups
name gfs2
id 0x7474a276
flags 0x00000008 mounted
change member 2 joined 1 remove 0 failed 0 seq 1,1
members 1 2
How to list the fence device support for the cluster nodes?
Fencing device is used in cluster to make sure that cluster nodes which are separated from cluster will not try
to write on shared device at same time.
[root@Node2 ~]# ccs_tool lsfence
ccs_tool: Cant find fencedevices in /etc/cluster/cluster.conf
How to see any node is fenced from cluster?
How to see any node in cluster is fenced or not. Here I am not having fencing device as mentioned earlier.
[root@Node2 ~]# fence_tool ls
fence domain
member count 2
victim count 0
victim now 0
master nodeid 1
wait state none
members 1 2
How to list the journals of file system?
Journals are help to contain metadata. These help to achieve better performance in file system. Journal count at
minimum should be equal to node count.
[root@Node2 ~]# gfs2_tool journals /dev/mapper/cluster_vg-cluster_lv
journal2 128MB
journal1 128MB
journal0 128MB
3 journal(s) found.
How to list the tuning parameters for cluster?

We can use this parameter to improve the performance of file system.


[root@Node2 ~]# gfs2_tool gettune /dev/mapper/cluster_vg-cluster_lv
incore_log_blocks = 1024
log_flush_secs = 60
quota_warn_period = 10
quota_quantum = 60
max_readahead = 262144
complain_secs = 10
statfs_slow = 0
quota_simul_sync = 64
statfs_quantum = 30
quota_scale = 1.0000 (1, 1)
new_files_jdata = 0
How to list the superblock of GFS2 file system?
Superblock contains the information related to whole file system Use the below command to retrieve the
superblock information of GFS file system.
[root@Node2 ~]# gfs2_tool sb /dev/mapper/cluster_vg-cluster_lv all
mh_magic = 0x01161970
mh_type = 1
mh_format = 100
sb_fs_format = 1801
sb_multihost_format = 1900
sb_bsize = 4096
sb_bsize_shift = 12
no_formal_ino = 2
no_addr = 23
no_formal_ino = 1
no_addr = 22
sb_lockproto = lock_dlm
sb_locktable = MysqlCluster:gfs2
uuid = f5a6304d-d176-a83d-75db-b3c9f8739ed3

https://ervikrant06.wordpress.com/category/solaris-2/page/5/

UNIX/LINUX PARTITIONS AND FILE


SYSTEMS FDISK, MKFS, MOUNT, SWAP

Ian! D. Allen idallen@idallen.ca www.idallen.com


Winter 2013 January to April 2013

COURSE HOME PAGE

COURSE OUTLINE

ALL WEEKS

PLAIN TEXT
UPDATED: 2014-11-14 05:41 EST

1 Introduction to File Systems

2 The useful

3 Creating File Systems Three Steps

command

3.1 Step 1: Create the partition using

o
o

file -s

fdisk

3.2 Step 2: Create the file system in the partition


using mkfs

3.2.1 Syntax: Using

3.2.2 Details on using

3.2.3 Choosing a File System Type

mkfs

to create a file system

mkfs

3.3 Step 3: Mount the file system on an existing


directory using mount

3.3.1 Manual mount: Use the


appropriate mount command

3.3.2 Details on using

3.3.3 Un-mounting a mounted file system:

3.3.4 Running a File System Check with

3.3.5 Using

3.3.6 Example of an

3.3.7 Some common options in

mount

mount

and the

/etc/fstab

/etc/fstab

umount

fsck

file

file
fstab

used by

mount

4 Virtual Memory Swap Partitions


o

4.1 Step 1: Create the partition using

4.2 Step 2: Initialize (format) the swap area using

fdisk
mkswap

4.3 Step 3: Connect the swap area to the system


using swapon

1 Introduction to File Systems


Creating a partition using fdisk simply divides up the space on a
disk. It doesnt by itself allow the operating system to store files
there. You first have to create some infrastructure to hold
content inside the partition; you have to create a File
System inside the partition.
A File System is a way of storing content inside a disk partition.
There are many kinds of file systems, each with different
characteristics. Linux supports a huge number. Proprietary
operating systems generally only support their own types of file
systems. (Linux can access Linux, Apple, and Microsoft file
systems, and dozens of others. Apple can only access Apple and

Microsoft file systems. Microsoft can only access Microsoft file


systems Does not play well with others.)
A file system is the way the O/S stores and retrieves data inside
the partition, e.g.

create, move and delete files and directories (touch


rmdir)

create, remove, modify filenames (ln,

open files for reading and writing (vi,

Search for files (find)

seek within a file (grep)

list content of a directory (ls)

etc.

cp mkdir

rm, mv)
cat, head, tail, sort)

The above basic functions are common to most operating


systems, but they are implemented and managed differently
from one O/S to another and perhaps even from one kind of file
system to another.

2 The useful

file -s

command

The Unix/Linux file command is very useful for identifying things


in the file system, such as directories, programs, images, files,
and special files such as disk partitions. The -s option is useful
for finding out what kind of file system (if any) is inside a disk
partition:
# file /dev/sda1
/dev/sda1: block special
# file -s /dev/sda1
/dev/sda1: Linux rev 1.0 ext4 filesystem data (needs journal recovery)
(extents) (large files) (huge files)

# file -s /dev/sda2
/dev/sda2: Linux/i386 swap file (new style) 1 (4K pages) size 140031 pages
# file -s /dev/sda
/dev/sda: x86 boot sector; GRand Unified Bootloader, stage1 version 0x3,
boot drive 0x80, 1st sector stage2 0x11cb38, GRUB version 0.94; partition
1: ID=0x83, active, starthead 32, startsector 2048, 3072000 sectors;
partition 2: ID=0x82, starthead 89, startsector 3074048, 1120256 sectors,
code offset 0x48

If file -s doesnt show a valid file system inside a disk partition,


then you cant mount the file system.

3 Creating File Systems Three Steps


The three steps to create a file system dont change much from
one operating system to another, but the specific details and
utilities used vary greatly. The steps are:
1.

Prepare the device (e.g. a disk, USB key, etc.) to receive a file
system
o

2.

i.e. partition the device into pieces (Linux

fdisk)

Create the file system inside the partition


o

i.e. format or prepare the partition with the chosen file


system (Linux mkfs)

optionally verify the file system integrity check for flaws


or errors (Linux fsck)

3.

Mount the new file system to make it visible to the users


o

i.e. connect the file system into the existing directory tree
(Linux mount)

The trio is always partition, make file system, and mount, in


that order. Lets look at each in more detail:

3.1 Step 1: Create the partition using

fdisk

See slides on Linux Disks and Partitions PDF

Create, modify or change partition information on the disk


o

Use fdisk, Disk Druid or any other partitioning tool that


can manage and create Linux partitions

Changing a partition start or end usually destroys


whatever was inside the partition back up first!

Using fdisk:
see http://tldp.org/HOWTO/Partition/fdisk_partitioning.html

You must create partitions first, before creating file systems


inside them

3.2 Step 2: Create the file system in the partition using

mkfs

Linux organizes data inside partitions using various types of file


systems. Linux supports a large number of different file system
types, including most of the Windows file system types. You can
use mkfs to create a file system to optimize the way data being
stored in a partition. The mkfs command is actually a front-end
for a whole set of mkfs commands, each different one selected by
the -t option to mkfs.
3.2.1 Syntax: Using mkfs to create a file system

mkfs -t type [other options] device_name

common types:

ext3, ext4, vfat

use vfat for USB keys, floppy disks, and Microsoft


compatibility

the device_name is almost always the


existing partition, not a whole disk

e.g.

mkfs -t ext4 /dev/sda1

e.g.

mkfs -t vfat /dev/fd0

/dev/

name of an

(first disk, first partition)


(first floppy disk)

mke2fs [options] device_name

specialized version of mkfs specific to


Linux ext2/ext3/ext4 file systems

used when you want more control of the details of the file
system (RTFM)

fsck [options] device_name

Optionally, you can check a file system for inconsistencies


or errors after creating it using fsck. (Almost never done right
after mkfs unless you suspect that your disk may have bad
blocks on it.)

3.2.2 Details on using mkfs

A file system must be created inside an existing drive/partition


o

You must have an existing partition before you can create


a file system.
You must have a file system created before you can mount it.

The type defaults to the old ext2 type, but for modern Linux
hard disk systems you should always specify the type explicitly as
either ext3 or ext4. These newer file system types are journalling file
systems. Do not use the old default ext2 file system type, especially
on large (over 400MB) disks.

The device_name is the pathname (usually absolute) of the


existing device or partition that will be used, usually of the
form /dev/sdXN, where X is the letter of the device (disk) being used
and N is the partition number on that device. (Recall that partitions
are created using the fdisk command.)

The mkfs commands do not check to see what is in the partition


already. They will not ask Are You Sure? before they re-format a
partition and destroy whatever was previously there. Be extremely

careful to get the device name correct! A partition destroyed


by mkfs is impossible to recover.

The mkfs commands do not care about the System ID (type) of


a partition given in the partition table. You can create any type of
file system in any type of partition. (For example, you can create
an ext4 file system on a partition labelled in the partition table as
NTFS or as Swap, but this is a bad idea.)

Creating a partition with fdisk does not automatically create


any type of file system in that partition.

Creating a file system with mkfs does not automatically mount


or make available that file system for use in Linux. The new file
system is not accessible. More on mounting file systems in the next
section.

If file -s cant find a file system inside a disk partition, you


cannot mount it you probably forgot to make one using mkfs.

3.2.3 Choosing a File System Type

Your system install likely created journalling file systems on


your virtual disk, using the -t ext4option to mkfs. Another way to
request this kind of file system is to use the -j (Journalling)
option to the original mke2fs command. This type of Linux
journalling file system is usually called ext3 or ext4, and some
distributions may have a small shell script
named mke3fs or mke4fs that simply calls mke2fswith the
appropriate -t or -j option.
Journalling file systems are more resistant to corruption due to
sudden power loss, allowing the system to come back up more
quickly by avoiding a long file system check at boot time. This
does NOT give you permission to power off a running Linux
system! Always shut down cleanly. The correct command-line for
an immediate, safe system shut down is:
# shutdown -h now
# shutdown -r now

# shut down and halt (usually power off)


# shut down and then reboot

See the man page for other options.

3.3 Step 3: Mount the file system on an existing directory using


mount

Linux File System


Unlike Windows with its multiple drive letters, Linux has a
single-ROOTed file system tree. Mounting attaches an existing
file system found on a block device (usually a disk partition,
e.g. /dev/hda2 or /dev/sda2) to the Linux directory structure,
e.g. onto some directory /boot. Accessing that directory, and
everything under that directory, accesses the file system on that
disk partition.
Any number of separate file systems (stored in disk partitions)
can be attached anywhere in the same Linux directory tree,
resulting in one single ROOTed tree to access every file on every
disk. You can detach a file system from one place in the tree and

attach it somewhere else, but then the pathnames to files inside


that file system would change to reflect the new mount location.
File systems can be mounted from the Unix/Linux command line
using the mount command. File systems can be mounted
automatically at system boot time by putting their names and
mount points into the /etc/fstab file. File systems on removable
devices (USB keys, DVDs) can also be mounted dynamically at
device insertion time using rules in system configuration files
(automounting).
(Most distribution use an existing /mnt/ directory to attach file
systems dynamically and temporarily to the directory structure,
e.g. USB keys, CDROM and DVD, floppy disks, etc.) Desktop
operating systems may also use a /media/ directory for dynamic
storage devices.
You can only mount file systems, not partitions. An empty partition
(one created with fdisk but not initialized with mkfs) cannot be
mounted. If file -s cant find a file system inside a disk partition,
you cannot mount it you probably forgot to make one using mkfs.
3.3.1 Manual mount: Use the appropriate mount command

mount

mount -a

Without any options: list all the currently mounted


devices and their contained file systems. This is a very
common command usage.

Mount all the file systems listed for auto mounting in


the /etc/fstab file (possible for root only).
mount [options] { device_name | directory_name }

Mount the file system in


name.

You
give either the device_name or the directory_name of the
entry in the fstab file. The system gets the other one from
the fstab.

e.g.
point

e.g. mount /home


partition device name

mount /dev/sda1

/etc/fstab

that matches the given

/etc/fstab

will supply the mount

/etc/fstab

will supply the

mount [options] device_name directory_name

Ignore /etc/fstab and mount the file system inside the


given device_name onto the given directory_name mount
point.

The partition must have a file system created in it


(e.g. with mkfs).

The directory_name must already exist. (You may need


to create it.)

e.g.

mount /dev/sda1 /home

/etc/fstab

is not used

3.3.2 Details on using mount

Syntax:

mount [options] device_name directory_name

The device_name is the pathname (usually absolute) of the


device containing the file system, e.g. a partition name such
as/dev/sdb9. The device is usually a partition name, not a disk name.
The partition must have a recognized file system created inside it
already, because you are mounting the file system that is inside
the partition, not the partition itself.

The directory_name is the pathname (often absolute) of an


existing Linux directory, usually an empty directory. The file system
inside the partition will be mounted on this existing directory
mount point. If the mount fails, check to make sure the directory
exists! Let me repeat that: If the mount command fails,
make sure that the mount point directory exists!
o

Use
needed.

You can cover up a non-empty directory by mounting


on top of it; this temporarily hides the original contents of the
directory and is not usually a good idea.

mkdir

to create a new empty directory mount point, if

Modern mount commands are smart enough to know what type


of file system resides inside a partition, but rarely you may have to
specify the type of file system in the partition using the -toption.
o

If Linux cant automatically figure out the type, it usually


means the partition has no file system created on it at all
you forgot to use mkfs first. Use file -s to check.
You can pass mount-time options using the

o
o

-o

option.

the options are the same options you can use in


the /etc/fstab file
e.g.

mount -o 'ro,noatime' /dev/fd0 /mnt/floppy

The user mounting the file system (if not root) must have
access rights to the mount point directory and to
the mount command.

Mounting a file system onto a directory that already contains


files will temporarily hide those files until the file system is
unmounted again.

Examples:
o

mkdir /mnt/foo ; mount /dev/sda1 /mnt/foo

mkdir /mnt/dosfloppy ; mount -t vfat /dev/fd0 /mnt/dosfloppy

mkdir /mnt/foobar ; mount /dev/sdb9 /mnt/foobar

3.3.3 Un-mounting a mounted file system: umount

You can un-mount a file system using the (badly spelled)


Linux umount command and give either the device name or the
mount point, but not both:
o

umount /dev/sda1

umount /home

To un-mount a file system, no files must be open inside it and


no programs must have it as a current directory.

If the message device is busy appears, a process is currently


accessing the device.

A common mistake is to try (and fail) to unmount the file


system of the current directory you have to cd all your shells and
processes out of the file system first.

Sometimes you have to find and kill processes that are using a
file system as a current directory, so that you can unmount the file
system.

Commands to list files open on a file system (use these as


root, and give the Linux directory that is the root of the file
system):
o

fuser /boot

lsof /

3.3.4 Running a File System Check with fsck

If the system reboots and ends up in repair file system


mode, all the file systems will be mounted read only so that you
can repair them.

If you need to edit/modify/change any files (/etc/fstab for


example) you will need to re-mount that file system as readwrite.

To switch
option:
o

/dev/sda1

to read-write mode use the remount

mount o remount,rw /dev/sda1

3.3.5 Using mount and the /etc/fstab file

To ensure that a file system is mounted at every boot, add the


file system to the /etc/fstab file and it will always be mounted at
boot time. To learn about the format of this file: man 5 fstab
File systems can be listed in the /etc/fstab file to automate the
mounting process. Both the mount point (the existing directory
on which the file system is to be mounted) and any other
options can be stored in the fstab file.
The file systems can be identified in fstab in the traditional way
by partition name (e.g. /dev/sda1), which is a bit risky since disk
names can change depending on what is attached to your
machine at boot time. Another way to identify file systems is
with a Volume Label or UUID (Unique UID) identifier that is
configured into the partition and that doesnt change even if the
partition name changes. You can see these Labels and UUIDs
using the blkid command. You can set Labels and UUIDs into a
partition using the tune2fs command.
If a file system is not listed in the /etc/fstab file and you wish to
mount it, then all mount information about the file system and
all options need to be given on the command line. At minimum,
you need the device name (partition) and the existing mount
point (directory) where the file system should be mounted:

e.g.

mount /dev/sda2 /home

e.g.

mount -o 'ro' /dev/sda2 /home_readonly

If a file system is listed in the /etc/fstab file, then indicating


either just the mount point (the directory name) or just the
device name (e.g. /dev/sda1) will indicate to the mount command
that the rest of the information needed for the mount should be
copied from the matching entry in the /etc/fstab file:

e.g. mount
from /etc/fstab

e.g. mount /home


options from /etc/fstab

# gets the directory name and options

/dev/sda1

# gets the device name and

3.3.6 Example of an /etc/fstab file

Lines in

/etc/fstab

starting with

are comments and are ignored:

# Sample /etc/fstab taken from Linux installed with two disk partitions
# 1

MOUNT POINT

TYPE

OPTIONS

ext4

defaults

swap

defaults

/dev/shm

tmpfs

defaults

/dev/pts

devpts

gid=5,mode=620

5 6
# DEVICE
BACKUP FSCK
UUID=dd2e3867-0f87-4fe9-9195-d60ad7b28897 /
1
UUID=16dfd36c-7422-43ac-89eb-5132488274d7 swap
0
tmpfs
0
devpts
0

sysfs

/sys

sysfs

defaults

/proc

proc

defaults

0
proc
0
# 1
6

Each line in
1.

2.

has six fields that describes a file system:

Field 1: Identifies the device (partition) to be mounted


o

traditionally, this a partition name under


a file system, e.g. /dev/sda1

can be a LABEL or a UUID: Above, both ROOT


are mounted by UUID instead of by device name

we mount file systems by partition name, but the


partition really does have to have a file system created inside
it for the mount to work, and the type field has to match the
file system that is in the partition

/dev/

containing

and swap

Field 2: Names the existing mount point directory where that


device is to be mounted
o

this directory is called the mount


point and must already exist

usually, the directory should be empty (but it doesnt


have to be)

3.

/etc/fstab

you can cover up a non-empty directory by


mounting on top of it; not usually a good idea

Field 3: Names the type of file system inside the partition


being mounted

4.

modern Unix/Linux systems can figure this out


automatically for most types of file systems if you use the
keyword auto here

is the best idea, since if youre wrong about the type,


the system wont boot properly

many types in fstab refer to pseudo-file-systems that


dont have real device names, e.g. tmpfs, devpts, sysfs, proc, and
sometimes the device name is given as simply none

Field 4: Optional mount options as a comma-separated list


(no spaces!)
o
o

5.

6.

auto

useful options (see below):

noauto, user

the keyword defaults uses some default options that


depend on the file system type RTFM
Field 5: Which file systems to back up

A non-zero value indicates backup priority/order

A zero means dont back up this file system

Field 6: The order in which file system checks are done at


boot time
o
o

The
order

fsck

program uses this to run file system checks in

The root should always be checked first value 1

Use value 2 or larger for any others that need to be


checked

No value or a value of 0 means no file system check

File systems do not need to be listed in the /etc/fstab file to be


mounted you can always mount anything manually from the

command line. The fstab is just for things that you want
mounted when the system boots.
Having a file system listed in the fstab means you only need to
specify the device name or the mount point to the mount command;
the other information for the mount will be read from
the /etc/fstab file:
# grep foo /etc/fstab
/dev/sdb1 /mnt/foo ext4 defaults,noauto 1 2
# mount /dev/sdb1

# system gets /mnt/foo mount point from

fstab
*** OR ***
# mount /mnt/foo

# system gets /dev/sdb1 device from

fstab
*** OR ***
# mount /dev/sdb1 /mnt/bar

# ignore fstab and do explicit mount

3.3.7 Some common options in fstab used by mount

will be mounted when mount is used with the -a option


(and so mounted at boot time) (default)
auto

noauto

will be ignored by the -a option (not mounted at boot

time)
exec

permit execution of binaries (default)

mount the file system read-only (read, execute, no


writing)
ro

rw

mount the file system read-write (default)

user

nouser

let a non-root user mount and unmount this file system


only root can mount and unmount this file system

(default)

defaults

use default options:

auto, exec, rw, nouser

Defaults may vary with distribution! Be careful!

4 Virtual Memory Swap Partitions


Another use for disk partitions is to hold memory pages used to
implement Unix/Linux Virtual Memory. These are
called swap partitions or the swap area, and they, too need some
minimal structure created to be used by the system. Usually,
you find only one swap partition in a system, but systems with a
lot of memory may have more.
Again, there are the usual three steps: Partition, Create, and
Connect

4.1 Step 1: Create the partition using

fdisk

Same as creating any other kind of partition use

fdisk

Set the partition type ID to be Linux Swap to document that this


is a swap partition. Many systems will automatically connect and
use swap partitions if they have the correct type ID.

4.2 Step 2: Initialize (format) the swap area using

Make a Linux partition into a swap partition


o

mkswap [options] device_name

e.g.

rarely need any options

mkswap /dev/sdb9

mkswap

This destroys whatever else was in the partition!


o

you dont get asked to confirm type it right the first


time

The device_name is the pathname (usually absolute) of the existing


swap partition that will be used. These commands do not care
about the System ID (type) of a partition given in the partition
table. You can initialize as swap any type of partition. Most Linux
systems at boot time will automatically use as swap all partitions
that have a type of Linux swap, if they are initialized as swap.
You can add more swap space to a running system using the
above two commands.
To display the currently active swap partitions, omit
the device_name and use only the -s or --summaryoption to
the swapon command:

Display currently active swap partitions:

swapon -s

4.3 Step 3: Connect the swap area to the system using

Use

swapon

to activate the swap area you just created with

swapon device_name

e.g.

swapon

swapon /dev/sdb9

To list the currently active swap areas:


o

swapon -s

Use

swapoff

(list all currently active swap areas)

to de-activate (stop using) a swap area:

swapoff device_name

e.g.

swapoff /dev/sdb9

mkswap

de-activates that swap partition and allows the partition


to be re-formatted and used for something else

the -a option will disconnect all swap areas (not usually a


good idea)

At boot time, partitions in /etc/fstab marked with type


be automatically connected and used as swap areas

You can manually ask that all


connected using:
o

swapon -a

fstab

swap

will

swap partitions be

(connect and enable all known swap

partitions)
o

the swapoff command has an identical option


to disconnect all active swap areas

http://teaching.idallen.com/cst8207/13w/notes/720_partitions_and_file_systems.htm
l

What is Ext2, Ext3 & Ext4 and How to


Create and Convert Linux File
Systems
by Narad Shrestha | Published: July 12, 2012 | Last Updated: January 7, 2015
Download Your Free eBooks NOW - 10 Free Linux eBooks for Administrators | 4 Free
Shell Scripting eBooks

I have used my Fedora old system to test where I converted


from ext2 to ext3, ext2 to ext4 and ext3 to ext4 file systems
successfully. By following this guide anyone can convert their file
systems smartly, but still I like to WARN youll before doing this,
because the following task required skilled administrative practices
and make sure you must take important backup of your files before

doing this. If in case something goes wrong at least you can revert
to back with your backup data.

Linux File System

In a computer, a file system is the way in which files are named and
placed logically to store, retrieve and update the data and also used
to manage space on the available devices.
File system is divided in two segments called User
Data and Metadata. In this article I am trying to explore how to
create and convert various Linux file systems and high level
difference amongst Ext2, Ext3 and Ext4 file systems. Before moving
further readings, let me introduce a brief about Linux file systems.

Ext2 Second Extended File System


Ext2 file system was introduced in 1993 and Ext2 was
developed by Remy Card. It was the first default file system in
several Linux distro like RedHat and Debian.

It was to overcome limitation of legacy Ext file system.

Maximum file size is 16GB 2TB.

Journaling feature is not available.

Its being used for normally Flash based storage media like USB
Flash drive, SD Card etc.

Ext3 Third Extended File System


Ext3 file system was introduced in 2001 and same was
integrated in Kernel 2.4.15 with journaling feature, which is to
improve reliability and eliminates need to check file system after
unclean shutdown.

Max file size 16GB 2TB.

Provide facility to upgrade from Ext2 to Ext3 file systems


without having to back up and restore data.

Ext4 Fourth Extended File System

Ext4, the high-anticipated Ext3 successor.


On October 2008, Ext4 as stable code were merged in
the Kernel 2.6.28 which contains Ext4 file system.
Backward compatibility.
Max file size 16GB to 16TB.
Ext4 file system have option to Turn Off journaling feature.
Other features like Sub Directory Scalability, Multiblock
Allocation, Delayed Allocation, Fast FSCK etc.

How to Determine File System Type?


To determing your linux file system type, run the following command
in terminal as a root user.

#dfhT|awk'{print$1,$2,$NF}'|grep"^/dev"

/dev/sda3ext3/

/dev/sda1ext3/boot

Warning: Please take important data backup before


executing below commands.

Creating an Ext2, or Ext3, or Ext4 File


Systems
Once you create file system using fdisk or partd command,
use mke2fs command to create either of file system and make sure
you replace hdXX with your device name.

Creating Ext2 File System


#mke2fs/dev/hdXX

Creating Ext3 File System


#mke2fsj/dev/hdXX

OR

#mkfs.ext3/dev/hdXX

-j option is used for journaling.

Creating Ext4 File System


#mke2fstext4/dev/hdXX

OR

#mkfs.ext4/dev/hdXX

-t option to specify the file system type.

Converting an Ext2, or Ext3, or Ext4


File Systems
It is always better way to unmount file system and convert.
Conversion can be done without unmounting and mounting
filesystem. Again replace hdXX with your device name.

Converting Ext2 to Ext3


To change an ext2 file system to ext3 enabling the journal feature,
use the command.

#tune2fsj/dev/hdXX

Converting Ext2 to Ext4


To convert from old ext2 to new ext4 file system with latest
journaling feature. Run the following command.

#tune2fsOdir_index,has_journal,uninit_bg/dev/hdXX

Next do a complete file system check with e2fsck command to fix


and repair.

#e2fsckpf/dev/hdXX

-p option automatically repairs the file system.


-f option force checking file system even it seems clean.

Converting Ext3 to Ext4


To enable the ext4 features on an existing ext3 filesystem, use the
command.

#tune2fsOextents,uninit_bg,dir_index/dev/hdXX

WARNING: You cannot revert or mount back to ext3 filesystem once


you run above command.
After running this command we MUST run fsck to fix up some ondisk structures that tune2fs has modified.

#e2fsckpf/dev/hdXX

WARNING: Please try all these above commands on your tesing


Linux server.
http://www.tecmint.com/what-is-ext2-ext3-ext4-and-how-to-create-and-convertlinux-file-systems/

A GRUB error will stop a Linux server


cold, but following these steps should
get you back on track.
THIS ARTICLE COVERS

Linux monitoring and troubleshooting


RELATED TOPICS

Introduction to Linux system administration

Linux administration tools

Linux interoperability

Linux licensing and support

Linux management and configuration


LOOKING FOR SOMETHING ELSE?

Secure remote Linux logging with rsyslog

Linux debugging with SystemTap dynamic instrumentation

Tracking Linux server performance with Munin

+ Show More

Related Content

Configuring GRUB 2: Tweaking the boot procedure in ... SearchEnterpriseLinux

Using Xen PyGRUB, ionice to manage storage and disks SearchITChannel

Fixing Linux boot problems with GRUB SearchEnterpriseLinux

Vendor Resources

Oracle Solaris 11 Administrator's Cheat Sheet Oracle Corporation

Reduce data center complexity when you 'go virtual' HP and Intel

Converting Linux and Windows Physical and Virtual Machines to Oracle VM Virtual... Oracle
Corporation

Intel Cloud Builders Guide: Cloud Design and Development on Intel Platforms ... Intel

GRUB, the boot loader for most Linux server and desktop distributions, is one
place your enterprise can't afford to have issues. When your server wont start
anything, you most likely have a GRUB error. Fortunately, its a simple fix
to get GRUB going again.

Download this free guide

Download: 14 Must Know Linux Commands


Discover the top 14 must-know Linux commands for server administrators, with 2 bonus
articles giving in-depth knowledge on the benefits of the IP and Mount commands.

Corporate E-mail Address:

Dow nload Now

By submitting your personal information, you agree that TechTarget and its partners may contact you regarding
relevant content, products and special offers.
You also agree that your personal information may be transferred and processed in the United States, and that you
have read and agree to the Terms of Use and the Privacy Policy.

Currently, there are two versions of GRUB GRUB 1 and GRUB 2 but
both essentially start a kernelthat allows you to work on your Linux server.
We're going to work off of enterprise Linux distributions of SUSE and Red Hat,
which run GRUB 1. The steps below won't work on GRUB 2 as the code is
different.

If your server powers on but doesn't boot, you probably have a GRUB error.
The easiest thing to try is booting the server from a rescue disk. The
installation disks for both SUSE Linux Server and Red Hat Enterprise
Linux(RHEL) contain a rescue system.
Once you've booted to the rescue system, you can mount everything on your
servers hard drive. In this scenario we can use the same steps for SUSE or
RHEL. The only requirement is that you know which disk contains the root file
system. Here we'll assume it's on /dev/sda2.
1.

Use mkdir /temp to create a directory that you can use as the
temporary mount point.

2.

Use mount /dev/sda2 /temp to mount the root file system on this
directory.

3.

Use mount -o bind /dev /temp/dev to make the directory that contains
all devices available as a subdirectory of /temp

4.

Use mount -t proc proc /temp/proc to mount the proc kernel interface
as well.

5.
6.

At this point, you can turn the /temp directory into your new root
with chroot /temp.
Now mount all remaining file systems, using mount -a.

After applying the steps described above, you can re-install GRUB. Type
the grub command to open the grub> prompt. From there, type setup (hd0).
This will reinstall GRUB to the master boot loader of your server.
If the setup command from the GRUB prompt fails, you can run grubinstallfrom a shell prompt. Before using grub-install, type exit to quit the
GRUBprompt, then type grub-install /dev/sda. SUSE no longer officially
supports this approach, so you'll have to use grub-install.unsupported

/dev/sda. Don't worry about "unsupported" in the command; it works fine


anyway!
If the install fails after those approaches, you'll want to check the GRUB
configuration file found in /boot/grub. On RHEL, the name of the file
is grub.conf; on SUSE it's menu.lst. The contents of both files are similar, as
illustrated here:
Sample grub.conf
[root@hnl ~]# cat /boot/grub/grub.conf
# grub.conf generated by anaconda
#
# You do not have to run grub after making changes to
this file
# NOTE:

You have a /boot partition.

This means that

#
all kernel and initrd paths are relative to
/boot/, eg.
#

root (hd0,0)

#
kernel /vmlinuz-version ro
root=/dev/mapper/vg_hnl-lv_root
#

initrd /initrd-[generic-]version.img

#boot=/dev/sda
default=0
timeout=5

splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux (2.6.32-220.el6.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.32-220.el6.x86_64 ro
root=/dev/mapper/vg_hnl-lv_root rd_NO_LUKS
LANG=en_US.UTF-8 KEYBOARDTYPE=pc KEYTABLE=us-acentos
rd_NO_MD quiet SYSFONT=latarcyrheb-sun16 rhgb
crashkernel=128M rd_LVM_LV=vg_hnl/lv_swap
rd_LVM_LV=vg_hnl/lv_root rd_NO_DM
initrd /initramfs-2.6.32-220.el6.x86_64.img
[root@hnl ~]#
The most important part of the GRUB configuration file is the three lines under
the line that starts with title Red Hat Enterprise Linux. First, root
(hd0,0) identifies where GRUB should try to find the kernel. Since the kernel is
not loaded yet, the kernel name /dev/sda1 cannot be used, and we have to
use the BIOS device name (hd0,0). The second line begins with kernel / and
specifies the kernel's location. It has one important argument: root=, which
specifies the device containing the root file system. Finally, the initrd line
identifies where the initramfs can be found. Both the kernel and initrd lines
refer to a file in the / directory, the root file system that was specified on root
(hd0,0).
If you encounter errors reinstalling GRUB, check that the files referred to on
these lines actually exist and try again.
http://searchenterpriselinux.techtarget.com/tip/Its-an-easy-fix-to-clean-up-a-GRUBerror-on-your-Linux-server

Repairing Common Problems in Linux


I. Losing the Boot Loader

Video: http://www.youtube.com/watch?

v=PA6-VujA0kM

A common problem people have with Linux installations when they combine
them with Windows into multi-partition, multi-boot configurations is that
when they go to upgrade or install a new version of Windows, they lose the
ability to boot into their Linux installation. This is because on installation of
the Windows boot loader, both Vista/2008 and XP/2003 will terminate other
boot loaders with extreme prejudice. Linux can be a bit more polite, it will
peek and if it sees other operating systems it will add them to the boot
loader menu in GRUB, allowing you to choose any previous operating system
that you had before. Linux will also disappear when someone runs
fixboot or fixmbr from recovery console to clean a boot sector virus or
corrupt MBR. When this happens, the Linux system partition is still there but
hidden, it simply requires that GRUB be re-installed as a boot loader. There
are several ways to do this depending on the flavor of Linux you are using:
A. In Ubuntu, Grub may be reinstalled by:
1. Booting up with the Live! Ubuntu CD or DVD.
2. After booting is complete, open a terminal or console from
Accessories.
3. The root Linux system partition will appear to be in place. You will find
/boot/grub.his is not from the hard drive, however, it is from the
Live!
CD or DVD file system.
4. To access the file system on the hard drive, use the command sudo fdisk
l to
see a listing of all partitions and physical drives on the system and their
device
labels.
5. Find the partition that your Linux system is on. It will be ext2 or ext3 .If
it says
Type 82, you dont want that, thats your swap partition. You want
Type 83,
your Linux system partition.
6. Once you have located it, use the command mount to see if the Live!

CD/DVD
has already mounted it. It should have.
5. If it is not mounted, use the command sudo mount t ext2 /dev/hd0
/media.
4. To access configuration files and the entire file system, cd to the
directory
where the partition is mounted. You will be able to see, edit and
manipulate the
file system just as if it were mounted to the root \ mount point. Type
pwd
to see where you are.
5. You can then check the grub.conf file to check your configuration by
accessing the
/boot/grub folder of the root directory mounted to /media/dev???,
where the ???
is whatever name the subdirectory has been given that the partition
mounts to. In other
words, where you would go to /boot/grub if you had booted off your
hard drive, you
must go to the relative path of /media/dev???/boot/grub/grub.conf
because you booted
off of the Live! CD.
6. Use the cat command or vim to view your grub.conf file and see
which physical hard
drive and partition it is installed on. Example: (hd0,1) = 1 st physical drive,
2nd partition.
7. Enter the following sequence of commands to change to the grub prompt
and reinstall
it to the MBR (substituting where your Linux system partition is in place
of (hd0,0) ):
#> grub
#> root (hd0,0)
#> setup (hd0)
8. The GRUB boot loader is reinstalled. You may now boot both Linux and
Windows.

B. In Fedora, Grub can be reinstalled by:


1. Booting up with CD # 1 and pressing F5 to interrupt the normal boot
process.
2. Type linux rescue at the prompt when it appears.
3. After booting is complete, logon. The root Linux system partition will be
mounted
to a directory called /mnt/sysimage/.
4. To access configuration files and the entire file system, cd to this
directory and
you will be able to see, edit and manipulate the file system just as if it
were mounted
to the root \ mount point. Type pwd to see where you are.
5. You can then check the grub.conf file to check your configuration by
accessing the
/boot/grub folder of the root directory mounted to /mnt/sysimage.
In other words,
where you would go to /boot/grub if you had booted off your hard
drive, you must go
to the relative path of /mnt/sysimage/boot/grub/grub.conf because
you booted off
of the CD . Again, this is because you have mounted the drive with the
rescue disk,
otherwise it would just be /boot/grub/grub.conf .
6. Open a console or terminal and CD to
/mnt/sysimage/boot/grub/grub.conf.
7. Use the cat command or vim to view your grub.conf file and see which
physical hard
drive and partition it is installed on. Example: (hd0,1) = 1 st physical drive,
2nd partition.
8. Enter the following sequence of commands to change to the grub prompt
and reinstall
it to the MBR (substituting where your Linux system partition is in place
of (hd0,0) ):
#> grub

#> root (hd0,0)


#> setup (hd0)
9. The GRUB boot loader is reinstalled. You may now boot both Linux and
Windows.
II. Recovering a System with a Lost Password

Video:

http://www.youtube.com/watch?v=q0euqsewex8

What do you do if you forget or do not have the root password? Similar to
the process above,
use a Live! or bootable Linux CD to mount the file system and edit the
passwd file.
1. Boot up with an Ubuntu Live! or Fedora CD or DVD.
2. If using Fedora, hit the "F5" button and type "linux rescue" to boot.
3. Mount the root partition in read/write mode to /mnt/sysimage.
4. CD to "/mnt/sysimage/etc" and sudo vim the /etc/passwd file.
Remember that you are not really in "/" when you see "/".
5. With the passwd file open, delete everything between the first two colons
for the account you want to crack. Usually this is root. Removing the
hash
value will allow login as root without a password.
6. If shadow passwords are enabled, then perform this procedure with the
/etc/shadow file.
III. Rescuing a Damaged Linux File System
Video: http://www.youtube.com/watch?v=q0Vy57uGzc8

In Fedora, boot up with a red hat Fedora Core install CD/DVD and press F5
to interrupt the normal boot process. Then type linux rescue at the
prompt. Alternatively, use an Ubuntu or Fedora Live! CD/DVD to boot and
mount the file system.
In Fedora, when using a rescue CD, the root Linux system partition will be
mounted to a directory called /mnt/sysimage/. When using Ubuntu and
Fedora Live! CDs, look for where the system partition is mounted with the
mount command. If it is not mounted, use the command sudo fdisk l-

to see where the physical drive and partition are. Then use the command
sudo mount t ext2 /dev/??? /media to mount the partition, where ???
would be the type and number such as sda1 or hdb2.
Once the system partition is mounted, you can cd to the /etc folder
and edit inittab, fstab, or dozens of other configuration files and
subdirectories that control daemon start-up and may interfere with the boot
process.
For corrupt file systems or inode problems, run fsck -f to perform a
thorough check of the file system and repair errors and inode problems. Use
fsck -y or fsck f -y if you dont want to be prompted for each file,
directory or inode that fsck attempts to repair. Alternatively, e2fsck may
be run. This is equivalent to running chkdsk or scandisk in Windows, and
many times does the trick after a reboot.
Video: Booting off the "Live!" CD = http://www.youtube.com/watch?v=r9wbrpDPlyc

Other Stuff
grub-md5-crypt = creates an encrypted boot password for grub booting.
In addition to modifying the menu and adding operating systems, you may also change the splash
image displayed on boot with grub by modifying the splashimage= line to point to whatever your
*.xpm.gz file is (like a Windows bitmap).

Recompiling and Customizing the Linux Kernel


modprobe = checks prerequisite modules have been loaded before specified module.
insmod = same as modprobe but doesnt require the full path
rmmod = remove module
lsmod = list modules inserted into kernel
/etc/modprobe.conf holds modules to be inserted into kernel automatically using the modprobe
command at boot time.

Steps to Recompile the Linux Kernel


1. Download the rpm source code file from:
http://download.fedora.redhat.com/pub/fedora/linux/core/updates/4/SRPMS/

2. cd to the directory of the rpm and create a spec file by typing rpm -ivh + file name:
rpm -ivh kernel-2.6.14*
3. Check to see if the spec file was created. Do ls /usr/src/redhat/SPECS to see if a file such as
kernel-2.6.spec is there.
4. Now type the following command to install the source into /usr/src/redhat/BUILD/kernel2.6.14/linux-2.6.14:
rpmbuild -bp --target=noarch /usr/src/redhat/SPECS/kernel-2.6.spec
5. Now move the source to the default location:
mv /usr/src/redhat/BUILD/kernel-2.6.14/linux-2.6.14 /usr/src/linux-2.6.14
6. cd to the directory you created and moved the source to:
cd /usr/src/linux-2.6.14
7. Run the command make mrproper from within the directory to put the kernel source in a clean
state.
8. cd to the directory /usr/src. Create a softlink called linux to the source file using:
ln -s /usr/src/linux-2.6.14 linux
9. cd to /usr/src/<kernel-version> and use the make commands:
make mrproper = remove/clean files created by previous recompiles
make oldconfig = save current settings into file in case you want to go
back.
make config text interface asking what modules to compile into
kernel.
make menuconfig like make config, but with an ASCII menu.
make xconfig = graphical make config
make gconfig = graphical make config
Note: The above are text-based and GUI options. You must at least run make
oldconfig and make config. You can hold down the Enter key to accept all the
defaults if you do not want to wade through thousands of options.
10. Type make clean to remove any unused files before compiling.

11. make bzImage = compiles the kernel. You can just type make for short. This
will create a bzip compressed kernel in /usr/src/linux/arch/i386/boot/bzImage.
12. Copy this compressed kernel to the directory /boot .
13. Rename the bzImage file vmlinuz-<kernel-version> using the mv command, so:
mv bzImage vmlinuz-2.6.14_FC4
14. Copy the /usr/src/linux/System.map file to the /boot directory as well with:
cp /usr/src/linux/System.map /boot
15. Type:
make all
make modules_install
make install
16. Create a ramdisk image. Necessary for grub/loading.

Type:

mkinitrd v /boot/initrd-2.6.14_FC4 2.6.14-prep


Note: The 1st argument is what you want to name the RAMDISK image. The 2nd argument is
whatever the directory is called for the kernel you want to use located in the directory
/lib/modules on your system.
17. Add lines to /boot/grub/grub.conf to add the image to the boot menu, unless it was added
automatically with the previous commands. Example: vi /boot/grub/grub.conf .

patch = patches the Linux kernel. Syntax = patch ThePatchFile .

System Confguration
mkbootdisk = creates a Linux boot disk.
ldd = identify shared libraries required by programs. Example: ldd /usr/xmms
ldconfig = updated shared libraries when changed.

Advanced Installation Options


1. Kickstart Files = Like a Windows answer file for automated installation. To open this program,
click RedHat -> System Tools -> KickStart . This will let you create a ks.cfg file.
2. FIPS First non-destructive Interactive Partition Splitter. Like Partition Magic for Linux. Available
for download from: http://www.igd.fhg.de/~aschaefe/fips/ . This free tool allows you to resize
partitions, so you could set up a multiboot of Linux/Windows without having to reinstall your Windows
installation.

3. Using the Windows boot.ini file and loader - You may use the Windows boot loader and boot.ini
file to load Linux, if you prefer, instead of using grub/LILO to boot Windows, when setting up a
multiboot configuration. To do this:
1. Be sure Windows is insalled on 1st primary partition.
2. Be sure that NTLOADER is installed on the hard drives MBR.
3. Install GRUB, specifying that it be installed on the 1 st sector of the partition
rather than the MBR (note: this is not the default setup option.)
4. Reboot PC after finishing installation with Fedora Core 4 CD # 1.
5. Press [F5} and type linux rescue to enter rescue mode.
6. Format a floppy with FAT file system. Insert it into the drive.
7. Mount it with mount t vfat /dev/fd0 /hold .
8. cd to the directory /hold .
9. Create a bootable image file of GRUB wherever you installed it. Use:
dd if=/dev/hda1 bs=512 count=1 of=linboot.bin .
10. Copy the linboot.bin file you just made to the Windows primary partition
using the disk you just made.
11. Add a line to the boot.ini file to point to the linboot.bin file:
C:\linboot.bin=Red Hat Fedora Core 4

Troubleshooting Device Files


/dev/MAKEDEV = remakes device files if deleted or missing such as /dev/fd0 . Dont
need to know major/minor/type.
mknod = also creates device files, but must know major/minor/type.
Major number = device driver in Linux kernel
Minor number = the device itself
Type = f (floppy), hd (hard drive), etc.
Note: Device files are located in the /dev folder.
character devices = transfer data by characters, like tape drives .

block devices = transfer data in blocks, like hard drives, floppies and cdroms.

Nice Software to Install for Linux (My personal "must have it" list.)
1. RealPlayer10Gold http://www.real.com (play videos/audios) tar.gz file.
2. Flash Player http://www.macromedis.com (play flash media) RPM file.
3. ntfs kernel rpm Allows your kernel version to mount NTFS partitions. Great for multiboot
systems, you can make a NTFS data partition and share it between your Windows operating
systems and Linux. On my laptop and desktop, I have multiboots with Windows 98, 2003, XP
Professional and Linux Fedora Core 4, so this comes in handy as a space saver, allowing me to use
one data partition for all operating systems (except 98, which is only used once in a while
anyway).
4. xmms The Linux media player. Plays sound files. Run from command line.
5. xmms MP3 plugin allows xmms to play MP3s.
6. xmms VQF plugin allows xmms to play vqfs.
7. mplayer = allows playing avis and DivX videos. Run from command line.
8. ogle DVD player, add associated libraries. Video player. RPM.
9. JRE Java Runtime Environment allows Java applets and programs. You have to make a
softlink in the Mozilla plugin subdirectory to the Java run time I norder for applets to work.
10.

J2SDK Java compiler and developer.

11. wine an RPM that allows running and installing Windows applications in Linux.
It fools software into thinking its running on Windows. I was able to get halflife and
Office 200 to work with this on a Linux machine. It gets better every year.
12.

marlin - wave file editor.

NIS (Network Information Service)


Used to coordinate many Unix/Linux computers on a network so they can share the
same configuration files.

https://www.networkingprogramming.com/1024x768/linux5.html
https://www.networkingprogramming.com/1024x768/linux5.html
]

FilesystemTroubleshooting

Filesystem troubleshooting

Introduction

Contents
1.
2.

3.
4.
5.

Introduction
Basic filesystem checks and repairs
1. e2fsprogs - ext2, ext3, ext4
filesystems
2. dosfstools - FAT12, FAT16 and FAT32
(vfat) filesystem
3. ntfs-3g (previously also ntfsprogs) NTFS filesystem
4. reiserfstools - reiserfs
5. xfsprogs - xfs
Missing superblock
Bad blocks
Sources and further reading

This guide will help diagnose filesystem problems one may come across on a GNU/Linux
system. New sections are still being added to this howto.

Basic filesystem checks and repairs


The most common method of checking filesystem's health is by running what's commonly
known as the fsck utility. This tool should only be run against an unmounted filesystem to
check for possible issues. Nearly all well established filesystem types have their fsck tool.
e.g.: ext2/3/4 filesystems have the e2fsck tool. Most notable exception until very recently
was btrfs. There are also filesystems that do not need a filesystem check tool i.e.: read-only
filesystems like iso9660 and udf.

e2fsprogs - ext2, ext3, ext4 filesystems


Ext2/3/4 have the previously mentioned e2fsck tool for checking and repairing filesystem.
This is a part of e2fsprogs package - the package needs to be installed to have the fsck tool
available. Unless one removes it in aptitude during installation, it should already be
installed.
There are 4 ways the fsck tool usually gets run (listed in order of frequency of occurrence):

1.

it runs automatically during computer bootup every X days or Y mounts (whichever


comes first). This is determined during the creation of the filesystem and can later be
adjusted using tune2fs.
2.
it runs automatically if a filesystem has not been cleanly unmounted (e.g.: powercut)
3.
user runs it against an unmounted filesystem
4.

user makes it run at next bootup

case 1
When filesystem check is run automatically X days after the last check or after Y mounts,
Ubuntu gives user the option to interrupt the check and continue bootup normally. It is
recommended that user lets it finish the check.

case 2
If a filesystem has not been cleanly unmounted, the system detects a dirty bit on the
filesystem during the next bootup and starts a check. It is strongly recommended that one
lets it finish. It is almost certain there are errors on the filesystem that fsck will detect and
attempt to fix. Nevertheless, one can still interrupt the check and let the system boot up on
a possibly corrupted filesystem.
2 things can go wrong
1.

fsck dies - If fsck dies for whatever reason, you have the option to press ^D (Ctrl +
D) to continue with an unchecked filesystem or run fsck manually. See e2fsck
cheatsheet for details how.

2.

fsck fails to fix all errors with default settings - If fsck fails to fix all errors with
default settings, it will ask to be run manually by the user. See e2fsck cheatsheet for
details how.

case 3
User may run fsck against any filesystem that can be unmounted on a running system. e.g.
if you can issue umount /dev/sda3 without an error, you can run fsck against /dev/sda3.

case 4
You can make your system run fsck by creating an empty 'forcefsck' file in the root of your
root filesystem. i.e.: touch /forcefsck Filesystems that have 0 or nothing specified in the
sixth column of your /etc/fstab, will not be checked
Till Ubuntu 6.06 you can also issue shutdown -rF now to reboot your filesystem and check
all partitions with non-zero value in sixth column of your /etc/fstab. Later versions of Ubuntu
use Upstart version of shutdown which does not support the -F option any more.
Refer to man fstab for what values are allowed.

e2fsck cheatsheet
e2fsck has softlinks in /sbin that one can use to keep the names of fsck tools more uniform.
i.e. fsck.ext2, fsck.ext3 and fsck.ext4 (similarly, other filesystem types have e.g.: fsck.ntfs)
This cheatsheet will make use of these softlinks and will use ext4 and /dev/sda1 as an
example.
1.

fsck.ext4 -p /dev/sda1 - will check filesystem on /dev/sda1 partition. It will also


automatically fix all problems that can be fixed without human intervention. It will do
nothing, if the partition is deemed clean (no dirty bit set).

2.

fsck.ext4 -p -f /dev/sda1 - same as before, but fsck will ignore the fact that the
filesystem is clean and check+fix it nevertheless.

3.

fsck.ext4 -p -f -C0 /dev/sda1 - same as before, but with a progress bar.

4.

fsck.ext4 -f -y /dev/sda1 - whereas previously fsck would ask for user input before
fixing any nontrivial problems, -y means that it will simply assume you want to answer
"YES" to all its suggestions, thus making the check completely non-interactive. This is
potentially dangerous but sometimes unavoidable; especially when one has to go
through thousands of errors. It is recommended that (if you can) you back up your
partition before you have to run this kind of check. (see dd command for backing up
filesystems/partitions/volumes)

5.

fsck.ext4 -f -c -C0 /dev/sda1 - will attempt to find bad blocks on the device and
make those blocks unusable by new files and directories.

6.

fsck.ext4 -f -cc -C0 /dev/sda1 - a more thorough version of the bad blocks check.

7.

fsck.ext4 -n -f -C0 /dev/sda1 - the -n option allows you to run fsck against a
mounted filesystem in a read-only mode. This is almost completely pointless and will
often result in false alarms. Do not use.

dosfstools - FAT12, FAT16 and FAT32 (vfat) filesystem


In order to create and check/repair these Microsoft(TM)'s filesystems, dosfstools package
needs to be installed. Similarly to ext filesystems' tools, dosfsck has softlinks too fsck.msdos and fsck.vfat. Options, however, vary slightly.

dosfsck cheatsheet
These examples will use FAT32 and /dev/sdc1
1.
2.

fsck.vfat -n /dev/sdc1 - a simple non-interactive read-only check


fsck.vfat -a /dev/sdc1 - checks the file system and fixes non-interactively. Least
destructive approach is always used.

3.

fsck.vfat -r /dev/sdc1 - interactive repair. User is always prompted when there is


more than a single approach to fixing a problem.

4.

fsck.vfat -l -v -a -t /dev/sdc1 - a very verbose way of checking and repairing the


filesystem non-interactively. The -t parameter will mark unreadable clusters as bad,
thus making them unavailable to newly created files and directories.

Recovered data will be dumped in the root of the filesystem as fsck0000.rec, fsck0001.rec,
etc. This is similar to CHK files created by scandisk and chkdisk on MS Windows.

ntfs-3g (previously also ntfsprogs) - NTFS filesystem


Due to the closed sourced nature of this filesystem and its complexity, there is no fsck.ntfs
available on GNU/Linux (ntfsck isn't being developed anymore). There is a simple tool
called ntfsfix included in ntfs-3g package. Its focus isn't on fixing NTFS volumes that have
been seriously corrupted; its sole purpose seems to be making an NTFS volume mountable
under GNU/Linux.
Normally, NTFS volumes are non-mountable if their dirty bit is set. ntfsfix can help with
that by clearing trying to fix the most basic NTFS problems:
1.

2.
3.

ntfsfix /dev/sda1 - will attempt to fix basic NTFS problems. e.g.: detects and fixes a
Windows XP bug, leading to a corrupt MFT; clears bad cluster marks; fixes boot sector
problems
ntfsfix -d /dev/sda1 - will clear the dirty bit on an NTFS volume.
ntfsfix -b /dev/sda1 - clears the list of bad sectors. This is useful after cloning an
old disk with bad sectors to a new disk.
Windows 8 and GNU/Linux cohabitation problems This segment is taken
from http://www.tuxera.com/community/ntfs-3g-advanced/When Windows 8 is
restarted using its fast restarting feature, part of the metadata of all mounted
partitions are restored to the state they were at the previous closing down. As a
consequence, changes made on Linux may be lost. This can happen on any partition of
an internal disk when leaving Windows 8 by selecting Shut down or Hibernate.
Leaving Windows 8 by selecting Restart is apparently safe.
To avoid any loss of data, be sure the fast restarting of Windows 8 is disabled. This can
be achieved by issuing as an administrator the command : powercfg /h of

reiserfstools - reiserfs
Install reiserfstools package to have reiserfsck and a softlink fsck.reiserfs available.
Reiserfsck is a very talkative tool that will let you know what to do should it find errors.

1.

fsck.reiserfs /dev/sda1 - a readonly check of the filesystem, no changes made


(same as running with --check). This is what you should run before you include any
other options.

2.

fsck.reiserfs --fix-fixable /dev/sda1 - does basic fixes but will not rebuild
filesystem tree

3.

fsck.reiserfs --scan-whole-partition --rebuild-tree /dev/sda1 - if basic check


recommends running with --rebuild-tree, run it with --scan-whole-partition and do NOT
interrupt it! This will take a long time. On a non-empty 1TB partition, expect something
in the range of 10-24 hours.

xfsprogs - xfs
If a check is necessary, it is performed automatically at mount time. Because of this, fsck.xfs
is just a dummy shell script that does absolutely nothing. If you want to check the filesystem
consistency and/or repair it, you can do so using the xfs_repair tool.
1.

xfs_repair -n /dev/sda - will only scan the volume and report what fixes are needed.
This is the no modify mode and you should run this first.
1.

2.

xfs_repair will exit with exit status 0 if it found no errors and with exit status 1
if it found some. (You can check exit status with echo $?)

xfs_repair /dev/sda - will scan the volume and perform all fixes necessary. Large
volumes take long to process.

XFS filesystem has a feature called allocation groups (AG) that enable it to use more
parallelism when allocating blocks and inodes. AGs are more or less self contained parts of
the filesystem (separate free space and inode management). mkfs.xfs creates only a single
AG by default.
xfs_repair checks and fixes your filesystems by going through 7 phases. Phase 3 (inode
discovery and checks) and Phase 4 (extent discovery and checking) work sequentially
through filesystem's allocation groups (AG). With multiple AGs, this can be heavily
parallelised. xfs_repair is clever enough to not process multiple AGs on same disks.
Do NOT bother with this if any of these is true for your system:
1.
2.

3.

you created your XFS filesystem with only a single AG.


your xfs_repair is older than version 2.9.4 or you will make the checks even slower on
GNU/Linux. You can check your version with xfs_repair -V
your filesystem does not span across multiple disks

otherwise:

1.

xfs_repair -o ag_stride=8 -t 5 -v /dev/sda - same as previous example but


reduces the check/fix time by utilising multiple threads, reports back on its progress
every 5 minutes (default is 15) and its output is more verbose.
1.

2.

if your filesystem had 32 AGs, the -o ag_stride=8 would start 4 threads, one
to process AGs 0-7, another for 8-15, etc... If ag_stride is not specified, it defaults
to the number of AGs in the filesystem.

xfs_repair -o ag_stride=8 -t 5 -v -m 2048 /dev/sda - same as above but limits


xfs_repair's memory usage to a maximum of 2048 megabytes. By default, it would use
up to 75% of available ram. Please note, -o bhash=xxx has been superseded by the m option

== jfsutils - jfs == == btrfs ==

Missing superblock
Bad blocks
Sources and further reading
1.

man pages

2.

<XFS user guide> - more details about XFS filesystem

Partners
Support
Community
Ubuntu.com

Official Documentation
Community Help Wiki
Contribute
Page History
Login to edit
Search

FilesystemTroubleshooting

Filesystem troubleshooting

Introduction

Contents
1.
2.

3.
4.
5.

Introduction
Basic filesystem checks and repairs
1. e2fsprogs - ext2, ext3, ext4
filesystems
2. dosfstools - FAT12, FAT16 and FAT32
(vfat) filesystem
3. ntfs-3g (previously also ntfsprogs) NTFS filesystem
4. reiserfstools - reiserfs
5. xfsprogs - xfs
Missing superblock
Bad blocks
Sources and further reading

This guide will help diagnose filesystem problems one may come across on a GNU/Linux
system. New sections are still being added to this howto.

Basic filesystem checks and repairs


The most common method of checking filesystem's health is by running what's commonly
known as the fsck utility. This tool should only be run against an unmounted filesystem to
check for possible issues. Nearly all well established filesystem types have their fsck tool.
e.g.: ext2/3/4 filesystems have the e2fsck tool. Most notable exception until very recently
was btrfs. There are also filesystems that do not need a filesystem check tool i.e.: read-only
filesystems like iso9660 and udf.

e2fsprogs - ext2, ext3, ext4 filesystems


Ext2/3/4 have the previously mentioned e2fsck tool for checking and repairing filesystem.
This is a part of e2fsprogs package - the package needs to be installed to have the fsck tool
available. Unless one removes it in aptitude during installation, it should already be
installed.
There are 4 ways the fsck tool usually gets run (listed in order of frequency of occurrence):

1.

it runs automatically during computer bootup every X days or Y mounts (whichever


comes first). This is determined during the creation of the filesystem and can later be
adjusted using tune2fs.
2.
it runs automatically if a filesystem has not been cleanly unmounted (e.g.: powercut)
3.
user runs it against an unmounted filesystem
4.

user

makes it run at next bootup

case 1
When filesystem check is run automatically X days after the last check or after Y mounts,
Ubuntu gives user the option to interrupt the check and continue bootup normally. It is
recommended that user lets it finish the check.

case 2
If a filesystem has not been cleanly unmounted, the system detects a dirty bit on the
filesystem during the next bootup and starts a check. It is strongly recommended that one
lets it finish. It is almost certain there are errors on the filesystem that fsck will detect and
attempt to fix. Nevertheless, one can still interrupt the check and let the system boot up on
a possibly corrupted filesystem.
2 things can go wrong
1.

fsck dies - If fsck dies for whatever reason, you have the option to press ^D (Ctrl +
D) to continue with an unchecked filesystem or run fsck manually. See e2fsck
cheatsheet for details how.

2.

fsck fails to fix all errors with default settings - If fsck fails to fix all errors with
default settings, it will ask to be run manually by the user. See e2fsck cheatsheet for
details how.

case 3
User may run fsck against any filesystem that can be unmounted on a running system. e.g.
if you can issue umount /dev/sda3 without an error, you can run fsck against /dev/sda3.

case 4
You can make your system run fsck by creating an empty 'forcefsck' file in the root of your
root filesystem. i.e.: touch /forcefsck Filesystems that have 0 or nothing specified in the
sixth column of your /etc/fstab, will not be checked
Till Ubuntu 6.06 you can also issue shutdown -rF now to reboot your filesystem and check
all partitions with non-zero value in sixth column of your /etc/fstab. Later versions of Ubuntu
use Upstart version of shutdown which does not support the -F option any more.
Refer to man fstab for what values are allowed.

e2fsck cheatsheet
e2fsck has softlinks in /sbin that one can use to keep the names of fsck tools more uniform.
i.e. fsck.ext2, fsck.ext3 and fsck.ext4 (similarly, other filesystem types have e.g.: fsck.ntfs)
This cheatsheet will make use of these softlinks and will use ext4 and /dev/sda1 as an
example.
1.

fsck.ext4 -p /dev/sda1 - will check filesystem on /dev/sda1 partition. It will also


automatically fix all problems that can be fixed without human intervention. It will do
nothing, if the partition is deemed clean (no dirty bit set).

2.

fsck.ext4 -p -f /dev/sda1 - same as before, but fsck will ignore the fact that the
filesystem is clean and check+fix it nevertheless.

3.

fsck.ext4 -p -f -C0 /dev/sda1 - same as before, but with a progress bar.

4.

fsck.ext4 -f -y /dev/sda1 - whereas previously fsck would ask for user input before
fixing any nontrivial problems, -y means that it will simply assume you want to answer
"YES" to all its suggestions, thus making the check completely non-interactive. This is
potentially dangerous but sometimes unavoidable; especially when one has to go
through thousands of errors. It is recommended that (if you can) you back up your
partition before you have to run this kind of check. (see dd command for backing up
filesystems/partitions/volumes)

5.

fsck.ext4 -f -c -C0 /dev/sda1 - will attempt to find bad blocks on the device and
make those blocks unusable by new files and directories.

6.

fsck.ext4 -f -cc -C0 /dev/sda1 - a more thorough version of the bad blocks check.

7.

fsck.ext4 -n -f -C0 /dev/sda1 - the -n option allows you to run fsck against a
mounted filesystem in a read-only mode. This is almost completely pointless and will
often result in false alarms. Do not use.

dosfstools - FAT12, FAT16 and FAT32 (vfat) filesystem


In order to create and check/repair these Microsoft(TM)'s filesystems, dosfstools package
needs to be installed. Similarly to ext filesystems' tools, dosfsck has softlinks too fsck.msdos and fsck.vfat. Options, however, vary slightly.

dosfsck cheatsheet
These examples will use FAT32 and /dev/sdc1
1.
2.

fsck.vfat -n /dev/sdc1 - a simple non-interactive read-only check


fsck.vfat -a /dev/sdc1 - checks the file system and fixes non-interactively. Least
destructive approach is always used.

3.

fsck.vfat -r /dev/sdc1 - interactive repair. User is always prompted when there is


more than a single approach to fixing a problem.

4.

fsck.vfat -l -v -a -t /dev/sdc1 - a very verbose way of checking and repairing the


filesystem non-interactively. The -t parameter will mark unreadable clusters as bad,
thus making them unavailable to newly created files and directories.

Recovered data will be dumped in the root of the filesystem as fsck0000.rec, fsck0001.rec,
etc. This is similar to CHK files created by scandisk and chkdisk on MS Windows.

ntfs-3g (previously also ntfsprogs) - NTFS filesystem


Due to the closed sourced nature of this filesystem and its complexity, there is no fsck.ntfs
available on GNU/Linux (ntfsck isn't being developed anymore). There is a simple tool
called ntfsfix included in ntfs-3g package. Its focus isn't on fixing NTFS volumes that have
been seriously corrupted; its sole purpose seems to be making an NTFS volume mountable
under GNU/Linux.
Normally, NTFS volumes are non-mountable if their dirty bit is set. ntfsfix can help with
that by clearing trying to fix the most basic NTFS problems:
1.

2.
3.

ntfsfix /dev/sda1 - will attempt to fix basic NTFS problems. e.g.: detects and fixes a
Windows XP bug, leading to a corrupt MFT; clears bad cluster marks; fixes boot sector
problems
ntfsfix -d /dev/sda1 - will clear the dirty bit on an NTFS volume.
ntfsfix -b /dev/sda1 - clears the list of bad sectors. This is useful after cloning an
old disk with bad sectors to a new disk.
Windows 8 and GNU/Linux cohabitation problems This segment is taken
from http://www.tuxera.com/community/ntfs-3g-advanced/When Windows 8 is
restarted using its fast restarting feature, part of the metadata of all mounted
partitions are restored to the state they were at the previous closing down. As a
consequence, changes made on Linux may be lost. This can happen on any partition of
an internal disk when leaving Windows 8 by selecting Shut down or Hibernate.
Leaving Windows 8 by selecting Restart is apparently safe.
To avoid any loss of data, be sure the fast restarting of Windows 8 is disabled. This can
be achieved by issuing as an administrator the command : powercfg /h of

reiserfstools - reiserfs
Install reiserfstools package to have reiserfsck and a softlink fsck.reiserfs available.
Reiserfsck is a very talkative tool that will let you know what to do should it find errors.

1.

fsck.reiserfs /dev/sda1 - a readonly check of the filesystem, no changes made


(same as running with --check). This is what you should run before you include any
other options.

2.

fsck.reiserfs --fix-fixable /dev/sda1 - does basic fixes but will not rebuild
filesystem tree

3.

fsck.reiserfs --scan-whole-partition --rebuild-tree /dev/sda1 - if basic check


recommends running with --rebuild-tree, run it with --scan-whole-partition and do NOT
interrupt it! This will take a long time. On a non-empty 1TB partition, expect something
in the range of 10-24 hours.

xfsprogs - xfs
If a check is necessary, it is performed automatically at mount time. Because of this, fsck.xfs
is just a dummy shell script that does absolutely nothing. If you want to check the filesystem
consistency and/or repair it, you can do so using the xfs_repair tool.
1.

xfs_repair -n /dev/sda - will only scan the volume and report what fixes are needed.
This is the no modify mode and you should run this first.
1.

2.

xfs_repair will exit with exit status 0 if it found no errors and with exit status 1
if it found some. (You can check exit status with echo $?)

xfs_repair /dev/sda - will scan the volume and perform all fixes necessary. Large
volumes take long to process.

XFS filesystem has a feature called allocation groups (AG) that enable it to use more
parallelism when allocating blocks and inodes. AGs are more or less self contained parts of
the filesystem (separate free space and inode management). mkfs.xfs creates only a single
AG by default.
xfs_repair checks and fixes your filesystems by going through 7 phases. Phase 3 (inode
discovery and checks) and Phase 4 (extent discovery and checking) work sequentially
through filesystem's allocation groups (AG). With multiple AGs, this can be heavily
parallelised. xfs_repair is clever enough to not process multiple AGs on same disks.
Do NOT bother with this if any of these is true for your system:
1.
2.

3.

you created your XFS filesystem with only a single AG.


your xfs_repair is older than version 2.9.4 or you will make the checks even slower on
GNU/Linux. You can check your version with xfs_repair -V
your filesystem does not span across multiple disks

otherwise:

1.

xfs_repair -o ag_stride=8 -t 5 -v /dev/sda - same as previous example but


reduces the check/fix time by utilising multiple threads, reports back on its progress
every 5 minutes (default is 15) and its output is more verbose.
1.

2.

if your filesystem had 32 AGs, the -o ag_stride=8 would start 4 threads, one
to process AGs 0-7, another for 8-15, etc... If ag_stride is not specified, it defaults
to the number of AGs in the filesystem.

xfs_repair -o ag_stride=8 -t 5 -v -m 2048 /dev/sda - same as above but limits


xfs_repair's memory usage to a maximum of 2048 megabytes. By default, it would use
up to 75% of available ram. Please note, -o bhash=xxx has been superseded by the m option

== jfsutils - jfs == == btrfs ==

Missing superblock
Bad blocks
Sources and further reading
1.

man pages

2.

<XFS user guide> - more details about XFS filesystem


FilesystemTroubleshooting (last edited 2014-10-14 09:14:04 by pabouk)

The material on this wiki is available under a free license, see Copyright / License for details
You can contribute to this wiki, see Wiki Guide for details

Potrebbero piacerti anche