13.07.2015 Views

Linux System Administration Recipes A Problem-Solution Approach

Linux System Administration Recipes A Problem-Solution Approach

Linux System Administration Recipes A Problem-Solution Approach

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER 4 ■ TAKING BACKUPS AND MANAGING DATA1. The first thing to try is a straightforward run of fsck:fsck /dev/sda1If you’re lucky, this may be all you need. If this succeeds, fsck will probably askyou to confirm a few fixes. To avoid being asked this, use the -y option.However, be warned that this should be used with caution, because it meansthat fsck will attempt to fix any and all errors it encounters, which may causedata loss.■ Note This is not true of all filesystems. If you’re using XFS, for example, then checking is conducted on mount,and fsck does nothing. xfs_check and xfs_repair may also be useful. However, fsck is fine with the <strong>Linux</strong>standardext3 (and ext2) filesystems.If this does work, update your backups immediately in case it wasn’t just aone-off failure!2. If you get a “bad superblock” error, you can try using an alternative block. Onan ext2 or ext3 filesystem, the superblock contains the filesystem metadata.Because it’s essential to the filesystem, backup copies of the superblock arekept, but you may need to use them explicitly.To get the superblock information for the problem filesystem, run thefollowing:dumpe2fs /dev/hda2 | grep superblockThis will work for both ext2 and ext3. Your output should look a bit like this:Primary superblock at 0, Group descriptors at 1-3Backup superblock at 32768, Group descriptors at 32769-32771Backup superblock at 98304, Group descriptors at 98305-98307Backup superblock at 163840, Group descriptors at 163841-163843[ etc ... ]Pass in one of the backup superblocks as an option to fsck:fsck -b 32768 /dev/hda2If this runs successfully, try mounting the filesystem with mount. If you stillhave problems, try passing the backup superblock into mount explicitly:mount sb=32768 /dev/hda2 /mnt3. The next stage, if steps 1 and 2 have both failed, is to use dd to generate a bitfor-bitcopy of the failed disk. To do this, you’ll need a spare drive at least aslarge as the failed one because dd copies even empty space over.For a spare drive mounted at /mnt/recovery (this must not be the drive youbooted from) and a failed drive connected at /dev/hda, use the following:114Download at WoweBook.Com

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!