Linux Partitions & Second Hard Drive with Back-up Script
Summary: This page shows simple graphical (GUI) methods that can be used to partition a hard drive and add a second hard disk to a computer running linux. You MUST make backups of any important files whenever you change the partitioning on a hard drive. You can easily wipe your drive with no chance of recovery. That said, using the programs described below, it is not difficult to manage partitions or add a second hard drive.
Notes: If you are creating a new computer and have two hard drives, I have found it to be easier to get the operating system installed with only one hard drive and then add the second hard drive after powering down your new system.
-
Install The Software:
I list the method for getting software for Debian GNU/Linux based distributions that use apt. Names of other package managers could be yum, Yast, etc. As the root user, either su for a root prompt or using sudo. (You can also search for the packages using Synaptic package manager).
me@myhost$ su
Password:
me@myhost# apt-get install gnome-schedule gparted pysdmThe package gparted may be included in a default Debian install. If the package pysdm is NOT in the repository, you can get the .deb package at the pysdm homepage. Right click on the package and choose "Open with GDebi Package Installer" for a near-automatic install.
-
Partitions Info:
If you want to examine your hard drive (disk) partitions, start up the gparted program: System -> Administration under Ubuntu or start it from a terminal as root under Debian.
me@myhost# gparted
If you want to change partitions, you must first unmount them. Here is some important gparted documentation. This program is used from the Ubuntu live CD, for example, if you want to create a separate "/home" partition. You can switch which hard drive you are looking at by selecting from the drop-down menu on the right.
To modify a partition, you must first select it. Before creating new partitions, remove the old one(s) first, as a separate step. REMEMBER that deleting /removing a partition will ERASE ALL DATA on the partition! There is no "undo".
-
Mount Second Hard Drive:
After powering down your computer, plug in the second hard drive. After rebooting, start up the Python Storage Device Manager (pysdm). Should be an Adminstration menu entry for "Storage Device Manager", or:
me@myhost# pysdmIn the program window below, hdb is my second hard drive. When first rebooting, the hardware is recognized by the operating system, but it doesn't have a "mount point" assigned to it. In the example below, I have already clicked on the folder across from "Mountpoint" and browsed to the root directory, chose "Create New" and added "backup" to be a top-level directory.

Using pysdm once will allow the hard drive to be mounted at the chosen directory each time you reboot. I think this is much easier than trying to manually edit the /etc/fstab file.
-
Create & Run A Backup Script Using rsync:
The program rsync efficiently synchronizes two folders by only modifying the parts of the final directory that have changed since the last synchronization. The -av options DO NOT delete files, however, they only update changed files and add new ones. You need to eventually "clean up" the /backup folder of stuff you REALLY want to delete.
Below is the content of the backup script I use. You could always simplify this by backing up the entire users directory, but I haven't wanted to do that yet. There are directories (folders) in my home directory and in the /backup directory with the same names: audio, documents, music_CDs, photos, videos, and public_html. Note that you need the trailing slash after the first listing. Modify the username without including the quotes and change the folder names to match yours.
rsync -av /home/"user_name"/audio/ /backup/audio
rsync -av /home/"user_name"/documents/ /backup/documents
rsync -av /home/"user_name"/music_CDs/ /backup/music_CDs
rsync -av /home/"user_name"/photos/ /backup/photos
rsync -av /home/"user_name"/videos/ /backup/videos
rsync -av /home/"user_name"/public_html/ /backup/public_html
If you give yourself permissions necessary on your /backup drive
me@myhost# chown -R user_name /backup
me@myhost# chgrp -R user_name /backupYou can create a cron job easily using the GUI tool gnome-schedule (Applications -> System Tools -> Schedule). If you named your backup script above "backup.sh" in your home directory, then the "Command" box in Schedule would be "/home/user_name/backup.sh". Schedule it for once a day when you know your computer will be on and CHECK IT OFTEN to be sure your files are getting backed up.


