Harddrive

From YobiWiki
Revision as of 00:23, 26 February 2008 by <bdi>PhilippeTeuwen</bdi> (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Converted with HTML::WikiConverter::MediaWiki from my old phpwiki site


S.M.A.R.T.

  • apt-get install smartmontools

If you have already smartsuite, it will be removed first.
On my system, there was a bug in the pre-removal script and I had to help a bit to remove this package:

  • /etc/init.d/smartsuite stop
  • echo "exit 0" > /etc/init.d/smartsuite
  • dpkg -r smartsuite

Turn SMART on (only once in HD's life):

  • smartctl --smart=on --offlineauto=on --saveauto=on /dev/hdX

Enable the daemon:

  • Edit /etc/default/smartmontools and uncomment start_smartd=yes
  • Edit /etc/smartd.conf:
    • DEVICESCAN -a -o on -S on -m root@teuwen.org -s (S/../.././02|L/../../6/03)

Selftests:

  • smartctl -t short /dev/hdX
  • smartctl -t long /dev/hdX
  • smartctl -l selftest /dev/hdX

Repairing

Forcing sector reallocations:

  • badblocks -n -s -v /dev/hdXX
  • Destructive: badblocks -w -s -v /dev/hdXX

Rescuing

  • apt-get install ddrescue
  • If you have a knoppix, dd-rescue was probably installed.
    This is an older version packaged only for the knoppix.
    dpkg -r dd-rescue;apt-get install ddrescue
  • dd_rescue -A -a -v /dev/hdXX /rescue-hdXX
  • dd_rescue -h for other options

See also

Rebuilding filesystem

For ReiserFS:

  • apt-get install reiserfsprogs
  • losetup /dev/loop0 rescue-hdXX
  • reiserfsck --rebuild-sb /dev/loop0
  • reiserfsck --rebuild-tree --scan-whole-partition --logfile rebuild.log /dev/loop0

Restoring from backuppc

Prepare the HD

  • delay backups on backuppc interface
  • boot on Knoppix
  • partition the HD
  • mount /dev/hdaX /mnt/hdaX

Make the computer accessible to backuppc as the computer to restore

  • attribute the correct IP
  • restore sshd keys on Knoppix ramdisk via tgz
  • /etc/init.d/ssh start
  • restore /root/.ssh/authorized_keys on Knoppix ramdisk

The big operation

  • restore all / on /mnt/hdaX via backuppc
  • check for errors (possibly failed restoration of some symlink and mknod...) and create them
    • gawk '/symlink/{match($0, /"(.*)".*"(.*)"/, a); system("ln -s " a[2] " " a[1])}'

Last steps: MBR and missing dirs if they were excluded from the backup:

  • /etc/init.d/libdevmapper1.00 start
  • cp -a /dev /mnt/hdaX/dev
  • chroot /mnt/hdaX
  • mkdir /tmp; chmod go+w /tmp; chmod +t /tmp
  • mkdir /proc
  • mkdir /mnt; cat /etc/fstab | gawk '/mnt/{system("mkdir " $2)}'
  • mkdir -p /var/cache/apt/archives/partial
  • mount /proc /proc -t proc
  • lilo/grub-install /dev/hda
  • exit
  • umount /mnt/hdaX
  • reboot

If you want to change the filesystem type, you are free to do so but pay attention:

  • change /etc/fstab accordingly
  • recreate the initrd image
    • mount /sys /sys -t sysfs
    • dpkg-reconfigure linux-image-XXXXX (look for initrd completion messages)