Creating the Directories
To create the toplevel directories run:
sudo mkdir /myBackup /myDatabases
You may also want to make yourself the owner of these folders:
sudo chown -R ubuntuka:ubuntuka /myBackup /myDatabases
(replace ubuntuka
with your user name)
Choosing a Partition
You can list the available partitions using this command:
sudo fdisk -l
Each partition will have a location like /dev/sda1
. Choose the partition you want to automount and remember this location.
Finding Partition Information
You now need to find the UUID (unique identification) of the partition and the filesystem type. To do this, use the udisks command. I can't remember if this is installed by default but if it isn't, run:
sudo apt-get install udisks
to install it.
Finding the UUID
To get the UUID (of /dev/sda1 in this example), run:
udisks --show-info /dev/sda1 | grep uuid
You will get output like:
by-id: /dev/disk/by-uuid/228EF188-BDEE-11E0-8F41-F5A84824019B
uuid: 228EF188-BDEE-11E0-8F41-F5A84824019B
uuid:
where 228EF188-BDEE-11E0-8F41-F5A84824019B
is the UUID.
Finding the Filesystem Type
To get the filesystem type of the partition (/dev/sda1 in the example), run:
udisks --show-info /dev/sda1 | grep type
You will get output like:
type: ext4
type: 0x83
where ext4
is the filesystem type.
Backing up fstab
To get partitions to mount on boot, you need to edit /etc/fstab. This file is pretty vital for the use of your computer so you should back up the current version whenever you make a change.
To do this, you can run:
sudo cp -v "/etc/fstab" "/etc/fstab-$(date +%s)"
You will get output like this:
`/etc/fstab' -> `/etc/fstab-1312389815'
For this example, to restore the old settings run:
sudo cp -v "/etc/fstab" "/etc/fstab-$(date +%s)" && sudo cp -v /etc/fstab-1312389815 /etc/fstab
Editing fstab
To edit /etc/fstab, run:
sudo nano /etc/fstab
To add an automounted partition, add a line like this:
UUID=228EF188-BDEE-11E0-8F41-F5A84824019B /myBackup ext4 defaults 0 0
and press Ctrl+O to save. This example would automount /dev/sda1 to /myBackup. You will need to replace 228EF188-BDEE-11E0-8F41-F5A84824019B
, /myBackup
and ext4
with the respective UUID, mountpoint and filesystem type of the partition.
Testing
You don't need to reboot to test this out. Instead, run:
sudo mount -a
You should then test to see if the contents of the directories are as you expected.