Table of Contents

System Maintenance

Copy image to USB stick and make it bootable

Plug in the USB stick and find it's drive identifier:

find /dev/disk -ls | grep sdx

Umount /dev/sdx1, then copy the image:

umount /dev/sdx1
cp image.iso /dev/sdx

Check disk drives for errors and bad blocks

From the terminal, type following command:

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

The above command will generate the file bad-blocks-sda1 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/sda1
  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/sda1: ***** FILE SYSTEM WAS MODIFIED *****
  /dev/sda1: 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.

Read More

Copy content of entire partition

rsync -avH /backup /mnt/new_backup/

Adding and removing autostart scripts

Put an autostart script into /etc/init.d, for example startme:

#! /bin/bash
Start the application here

Then run the following command to setup the autostart in the different runlevels:

update-rc.d startme defaults

You can check existing entries with the following command:

ls -l /etc/rc?.d/*startme

To remove the autostart:

update-rc.d [-n] [-f] startme remove

-n: no action, just show what would happen. -f: force removal even if vmachine.sh still exists

Various helpful command line commands

Determine size of a folder path:

du -hs

Diskspace information:

df -h

Change permissions for all files in a directory tree:

find -type f -print0 | xargs -0 chmod 644