bad blocks / (e2)fsck – repair partitions

badblocks is a Linux utility to check for bad sectors on a disk drive (A bad sector is a sector on a computer’s disk drive or flash memory that cannot be used due to permanent damage or an OS inability to successfully access it.). It creates a list of these sectors that can be used with other programs, like mkfs, so that they are not used in the future and thus do not cause corruption of data. It is part of the e2fsprogs project.

It can be a good idea to periodically check for bad blocks. This is done with the badblocks command. It outputs a list of the numbers of all bad blocks it can find. This list can be fed to fsck to be recorded in the filesystem data structures so that the operating system won’t try to use the bad blocks for storing data. The following example will show how this could be done.

From the terminal, type following command:

$ sudo badblocks -v /dev/hda1 > bad-blocks

The above command will generate the file bad-blocks in the current directory from where you are running this command.

Now, you can pass this file to the fsck command to record these bad blocks

$ sudo fsck -t ext3 -l bad-blocks /dev/hda1
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Check reference counts.
Pass 5: Checking group summary information.

/dev/hda1: ***** FILE SYSTEM WAS MODIFIED *****

/dev/hda1: 11/360 files, 63/1440 blocks

If badblocks reports a block that was already used, e2fsck will try to move the block to another place. If the block was really bad, not just marginal, the contents of the file may be corrupted.


e2fsck /dev/sdX

Read More

screen

Starting screen

Start screen using

screen -d -R session_tomcat

Replace session_tomcat with any other helpful name for the session you’re about to create.
Sharing your Session

Ask your friend to connect using (assuming they are logged in using the same user account):

screen -x session_tomcat

Now it’s simply magical. Multiple persons can type and work on the same terminal – it works best when you’re coordinating over the phone. Note that the dimensions of your terminal output will be the same for every user – to change it, press Ctrl-A and then capital F. This will make the screen output fit your current terminal size, and change it to that size for every connected user.

Read More

bcache

Bcache is a caching method which can be used to utilize the power and speed of SSDs to speed up HDDs.

  • Backingdevice has to be a block device (no nfs or other networkfs)

  • raid is possible

There are multiple methods how the cache is populated:

  • wirte to disk and cache

  • write to disk only (writearound)

  • write only to cache

bcache needs to be enabled because its not a default setting.

zypper in bcache-tools

modprobe bcache

reboot?

now there are two files in /sys/fs/bcache/

-register -register_quiet

man make-bcache

to circumvent the process of matching the backing device with the caching device manually its recommended to create them simultaniously.

also make sure you unmounted the partitions you want to associate

umount /dev/sdXn

now we are ready for creation

make-bache -C /dev/sdXn -B /dev/sdXn

-C is caching device

-B is backingdevice obv..

i case theres an error use wipefs -a /dev/sdXn (the caching device) to clear the remaining filesystem

now there is a UUID in /sys/fs/bcache which represents the caching device by its UUID

you can also check in /proc/partitions if you find your bcache device(its a file => cat)

now you can set a filesystem for your newly created bcache device

mkfs -t btrfs -f /dev/bcache0

you can also use ext4 or xfs etc..

to make changes persistent put

/dev/bcache0 /home fstype defaults 1 2

in your fstab

remount your destination e.g mount /home

aaand you are DONE

Read More