| MBR-Backup | 
Copy the first 512 bytes of your hard drive, which contains the MBR, to a file.
dd if=/dev/sda of=/boot/mbr_backup bs=512 count=1
Two parameters are used:
If you can't boot a server because of a problem in the MBR, boot from a rescue disk and use the command:
dd if=/boot/mbr_backup of=/dev/sda bs=446 count=1
In this restore command, only 446 bytes are written back. This is because you may have changed the partition table since you've created the backup. By writing back only the first 446 bytes of your backup file, you don't overwrite the original partition table, which is between bytes 447 and 511.
Sample script to write MBR backup:
#!/bin/bash #dd if=/dev/sda of=/boot/mbr_backup bs=512 count=1 /bin/dd if=/dev/sdb of=/boot/mbr_backup bs=512 count=1 # /bin/echo "Output of file cmd should be:" /bin/echo "/boot/mbr_backup: x86 boot sector, code offset 0x48" /bin/echo "" /bin/echo "Actual file cmd output:" /usr/bin/file /boot/mbr_backup
Extending swap space
Let's say that you're alerted at 3 a.m. by a message saying your server is about to run out of memory entirely, due to an undiscovered memory leak. All you have to do is create an empty file and specify that it should be added to the swap space.
Creating an empty file using dd:
dd if=/dev/zero of=/swapfile bs=1024 count=1000000
This would write a file of one gigabyte, and that can be added to the swap space using mkswap /swapfile and swapon /swapfile.
For more assistance contact Ron Parachoniak, rap@phas.ubc.ca ( Sysadmin)
 
| webmaster@phas.ubc.ca | [Dept. Home Page] | last updated: 14 Sep 06 |