Add A Disk Image

Introduction

I suggest this as a way of separating you content data from your linux system install. We create any additional disk image and mount in the filesystem with an appropriate mount point. We can then use it to store what we like, e.g. website files, database files, home directories, subversion, etc.

Creating the Disk

Create the disk image in the Linode Manager. You must then assign the disk image to the VPS profile, choosing a device name (e.g. xvdc). Then reboot the server:

sudo reboot

Once rebooted, the new disk device will be visible to the server. The device is then available from /dev/<device name>.

Mounting the Disk

Create the Mount Point

Create the directory you would like the file system for the new disk to be mounted in. The default location is in /mnt, but you can mount the disk anywhere. For example:

sudo mkdir /mnt/data

Mounting Manually

The syntax for the mount command is as follows:

sudo mount <device location> <mount point>

For example:

sudo mount /dev/xvdc /mnt/data

The file system should then be accessible. You can test this using the df command:

df

Unmounting

Use the umount command. The syntax is as follows:

sudo umount <device or mount point>

Automatic Mounting

By default, the server will not mount the disk image automatically. To enable this, edit the /etc/fstab file:

sudo nano /etc/fstab

Refer to this tuxfiles.org article for an explanation of the file syntax. The key option to use in the options field is auto (this is also included in defaults).

Here is a good example,

# /etc/fstab: static file system information.
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    defaults        0       0
/dev/xvda       /               ext3    relatime,errors=remount-ro 0       1
/dev/xvdb       none            swap    sw              0       0
/dev/xvdc       /mnt/data       ext3    defaults        0       2

When you reboot the server the new disk should be mounted automatically.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License