Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
com/compare-linux-xfs-vs-ext4-file-system/
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 can we run the file system check using another copy of superblock?
How can we mount the file system using another copy of superblock?
https://ervikrant06.wordpress.com/2014/06/26/how-to-fix-issue-with-file-systemsuperblock-in-red-hat-linux/
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
/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
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?
https://ervikrant06.wordpress.com/category/solaris-2/page/5/
COURSE OUTLINE
ALL WEEKS
PLAIN TEXT
UPDATED: 2014-11-14 05:41 EST
2 The useful
command
o
o
file -s
fdisk
mkfs
mkfs
3.3.5 Using
3.3.6 Example of an
mount
mount
and the
/etc/fstab
/etc/fstab
umount
fsck
file
file
fstab
used by
mount
fdisk
mkswap
etc.
cp mkdir
rm, mv)
cat, head, tail, sort)
2 The useful
file -s
command
# 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
Prepare the device (e.g. a disk, USB key, etc.) to receive a file
system
o
2.
fdisk)
3.
i.e. connect the file system into the existing directory tree
(Linux mount)
fdisk
Using fdisk:
see http://tldp.org/HOWTO/Partition/fdisk_partitioning.html
mkfs
common types:
e.g.
e.g.
/dev/
name of an
used when you want more control of the details of the file
system (RTFM)
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.
mount
mount -a
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
mount /dev/sda1
/etc/fstab
/etc/fstab
/etc/fstab
e.g.
/etc/fstab
is not used
Syntax:
Use
needed.
mkdir
o
o
-o
option.
The user mounting the file system (if not root) must have
access rights to the mount point directory and to
the mount command.
Examples:
o
umount /dev/sda1
umount /home
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.
fuser /boot
lsof /
To switch
option:
o
/dev/sda1
e.g.
e.g.
e.g. mount
from /etc/fstab
/dev/sda1
Lines in
/etc/fstab
starting with
# 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.
/dev/
containing
and swap
3.
/etc/fstab
4.
5.
6.
auto
noauto, user
The
order
fsck
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
fstab
*** OR ***
# mount /mnt/foo
fstab
*** OR ***
# mount /dev/sdb1 /mnt/bar
noauto
time)
exec
rw
user
nouser
(default)
defaults
fdisk
fdisk
e.g.
mkswap /dev/sdb9
mkswap
swapon -s
Use
swapon
swapon device_name
e.g.
swapon
swapon /dev/sdb9
swapon -s
Use
swapoff
swapoff device_name
e.g.
swapoff /dev/sdb9
mkswap
swapon -a
fstab
swap
will
swap partitions be
partitions)
o
http://teaching.idallen.com/cst8207/13w/notes/720_partitions_and_file_systems.htm
l
doing this. If in case something goes wrong at least you can revert
to back with your backup data.
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.
Its being used for normally Flash based storage media like USB
Flash drive, SD Card etc.
#dfhT|awk'{print$1,$2,$NF}'|grep"^/dev"
/dev/sda3ext3/
/dev/sda1ext3/boot
OR
#mkfs.ext3/dev/hdXX
OR
#mkfs.ext4/dev/hdXX
#tune2fsj/dev/hdXX
#tune2fsOdir_index,has_journal,uninit_bg/dev/hdXX
#e2fsckpf/dev/hdXX
#tune2fsOextents,uninit_bg,dir_index/dev/hdXX
#e2fsckpf/dev/hdXX
Linux interoperability
+ Show More
Related Content
Vendor Resources
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.
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
#
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
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.
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).
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:
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.
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
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.
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.
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.
1.
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.
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.
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.
dosfsck cheatsheet
These examples will use FAT32 and /dev/sdc1
1.
2.
3.
4.
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.
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.
2.
fsck.reiserfs --fix-fixable /dev/sda1 - does basic fixes but will not rebuild
filesystem tree
3.
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.
otherwise:
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.
Missing superblock
Bad blocks
Sources and further reading
1.
man pages
2.
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.
1.
user
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.
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.
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.
dosfsck cheatsheet
These examples will use FAT32 and /dev/sdc1
1.
2.
3.
4.
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.
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.
2.
fsck.reiserfs --fix-fixable /dev/sda1 - does basic fixes but will not rebuild
filesystem tree
3.
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.
otherwise:
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.
Missing superblock
Bad blocks
Sources and further reading
1.
man pages
2.
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