Update 2017-02, Ubuntu 16.04.  I still use this method for my home fileserver.


This page shows methods that can be used to partition a hard drive and add a second hard disk to a computer running Ubuntu 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.

  • Install The Software if Needed

    Since the latest Ubuntu distribution comes with a very nice disk utility, you will only need to add "gparted" software if you are working with an existing install. There aren't good menus with this. During my latest partitioning, I noticed I had to double-click the partition to get a dialog box and choose "format".

    me@myhost$ sudo apt-get install gnome-schedule gparted
  • Partitions Info

    To find out the details about your storage devices, you can type "sudo lshw" into a terminal and hunt around the output. Otherwise, Ubuntu 16.04 has the GUI you can use called Disk Usage Analyzer.

    me@myhost$ sudo lshw

    WARNING: REMEMBER that deleting /removing a partition will ERASE ALL DATA on the partition! There is no "undo". Below is an example of what to expect from the partitioning software.

    Gparted Partitioner

    If you want to change partitions, you must first unmount them. Here is some important gparted documentation. I believe gparted is used from the Ubuntu live CD, for example, if you want to create a custom partition scheme, such as having a separate "/home" partition. You can switch which hard drive you are looking at by selecting from the drop-down menu on the right. Before creating new partitions, remove the old one(s) first, as a separate step.

  • Mount Second Hard Drive by editing /etc/fstab

    WARNING: You can seriously mess up access to your system if you ruin the fstab (Filesystem Table) file. Make sure you make a backup FIRST and know how to revert to it.

    On a home system it is easy enough to edit the /etc/fstab file using gedit:

    me@myhost$ sudo gedit /etc/fstab

    I suggest you follow the suggestions in the /etc/fstab file and make your changes robust by getting a UUID number. In a separate terminal, the command for drive /dev/sda1 (see above) would be:

    me@myhost$ sudo blkid /dev/sda1

    Enter the data using the spacing of the lines above it. There is and explanation of the /etc/fstab file at the Fstab Wiki. In my example, the "/", "/home", and "swap" partitions are all on the same disk, but have different UUID numbers generated at installation. For my 2 backup disks, I manually enterd the names "/bu300" and "/bu250" after I had created these directories (folders) at the top level. This file will associate the physical disks to these mount points.

    # /etc/fstab: static file system information.
    #[PARTIAL FILE:  Columns are as follows: File System Name, Mount Point, Filesystem Type, Options, Dump, and Pass*.
    # / was on /dev/sda1 during installation
    UUID=71537a2a-2c85-40b1-9969-6b73ead86456 / ext4 errors=remount-ro 0 1
    # /home was on /dev/sda3 during installation
    UUID=edbed3cc-dd0a-404c-898e-551eb41a1bb3 /home ext4 defaults  0 2
    # swap was on /dev/sda5 during installation
    UUID=99e91184-e43b-4889-8bfb-ae86017ed5ec none swap sw 0 0
    # Two backup drives 300GB and 250GB.  Get UUID with "blkid" command.
    UUID=ab5830c2-6591-48f9-854e-ee702ccdda5b /bu300 ext4 defaults 0 2
    UUID=43ff7d13-ece5-4459-9a0c-8421d86d51a0 /bu250 ext4 defaults 0 2

    There is a graphical program (GUI) that may help you do this called Storage Device Manager (search in Synaptic). I have successfully used it with a single backup drive, but now use the direct method described above.

  • Create & Run A Backup Script Using rsync

    Give yourself permissions if necessary on your /backup drive:

    me@myhost$ sudo chown -R USER_NAME /backup
    me@myhost$ sudo chgrp -R USER_NAME /backup

    The program rsync efficiently synchronizes two folders by only modifying the files in the final directory that have changed since the last synchronization. The -av options DO NOT delete files, though, 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 an sample backup script that matches the default files in a Ubuntu Linux installation. In this example the only mount point created was /backup for a single backup hard drive. You need to substitute your user name for USER_NAME. I create and extra folder called "Voice" for lectures, foreign language CDs, etc. You need to delete the comment sign "#" to use.

    rsync -av /home/USER_NAME/Documents/    /backup/Documents
    rsync -av /home/USER_NAME/Downloads/    /backup/Downloads
    rsync -av /home/USER_NAME/Music/        /backup/Music
    rsync -av /home/USER_NAME/Pictures/     /backup/Pictures
    rsync -av /home/USER_NAME/Public/       /backup/Public
    rsync -av /home/USER_NAME/Videos/       /backup/Videos
    #rsync -av /home/USER_NAME/Voice/       /backup/Voice

    Unfortunately, the program gnome-schedule, a GUI window to cron jobs, has died. An alternative to get regular backups is to add a item to the program Startup Applications. If you named your backup script above "backup.sh" in your home directory, then the "Command" box item would be "/home/USER_NAME/backup.sh", or "./backup.sh". For a home-based system that gets turned off regularly, this will cause your files to be backed up every time you turn the comptuer on, and it won't rely on the computer being on at "X o-clock". It is probably a better option for me.

    startup apps