Mounting additional storage disks in Linux aside from the root disk.

Mounting additional storage disks in Linux aside from the root disk

When you attach additional storage to your Cloud Server, this becomes an additional partition. One is a root disk for the operating system and one larger sized partition for your data that varies in size depending upon your choice. Out of the box, your Cloud Server will have its first partition mounted as / in Linux

To get access to your second partition, you need to do the following:

Linux Operating Systems:

1). Type 'cat /proc/partitions' at the command prompt to display the partitions your system has available. You should notice the following on a brand new Nano Cloud Server (the size of your data disk will change depending upon your Cloud Server size):

major minor #blocks name

8     0   16777216 sda   
8     1   15719571 sda1   
8     2    1052257 sda2   
8    16   16777216 sdb

2). Type 'df -H' to show the file systems that are currently mounted for your Cloud Server.  You should notice the following on a brand new Nano Cloud Server:

Filesystem             Size    Used   Avail  Use%  Mounted on
/dev/sda1             16G     815M  15G    6%      /
tmpfs                   135M   0        135M  0%      /lib/init/rw
udev                    11M     574k   10M    6%     /dev
tmpfs                   135M   0        135M  0%     /dev/shm

3). Type 'fdisk /dev/sdb' to create a new partition on your second disk that has not yet been partitioned:
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xa9f4769a.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

The number of cylinders for this disk is set to 2088.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs   
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): 

4). Type 'n' to commence the process of creating a new partition, then type 'p' to select primary partition, then type '1' to create the first partition on the disk, then type 'Enter' to accept all defaults when prompted, you will then be taken back to the fdisk main menu.

5). Type 'w' to write the partition table to disk, this also exits the fdisk program.  Your new partition will be written to the disk and you will now be returned to the prompt.

6). Type 'cat /proc/partitions' to list the partition table, you will notice a new partition has been created, in this case /dev/sdb1.  We now need to format the new partition with a file system in order to store files on it.

major minor  #blocks     name
8        0       16777216   sda
8        1       15719571   sda1
8        2       1052257     sda2
8       16      16777216   sdb
8       17      16771828   sdb1

7). To create a new EXT3 file system on your new partition, type 'mkfs.ext3 /dev/sdb1' at the prompt.  You can also choose to format the file system with another file system of your choosing, but EXT3 is a sensible default for most workloads.  This process will take anywhere from 1 to 30 minutes depending upon the size of your partition. For our 16GB partition, it only took 30 seconds.

mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
2097152 inodes,
4192957 blocks
209647 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
128 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000

Writing inode tables: done         
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 22 mounts or 180 days, whichever comes first.  Use tune2fs -c or -i to override.

8). The final step of the process is deciding where to mount your new file system ready for use.  We recommend creating a new directory such as /data to mount your file system.  Type 'mkdir /data' to create the new directory.

9).  In order to have your file system mounted automatically at boot time, you should add an entry to your /etc/fstab file, which is the file that is used by the Linux operating system in order to determine what file systems should be mounted at boot time.

Use your favourite text editor such as 'vi' or 'nano' to edit /etc/fstab (type 'yum install nano' or 'apt-get install nano' if nano is not present on your system).

Add the following line to mount your new file system on your newly created mount point /data, then save the file:

/dev/sdb1               /data                   ext3    defaults        1 1

10). Type 'mount /data' to mount your new file system for the first time.

11). Type 'df -H' to show your newly mounted storage:

Filesystem             Size   Used  Avail Use% Mounted on
/dev/sda1               16G   815M    15G   6% /
tmpfs                  135M      0   135M   0% /lib/init/rw
udev                    11M   578k    10M   6% /dev
tmpfs                  135M      0   135M   0% /dev/shm
/dev/sdb1               17G   181M    16G   2% /data

Add Feedback