Wednesday, September 14, 2016

Mounting a storage volume on an Oracle Compute Cloud Linux instance

If you've provisioned an Oracle Compute Cloud instance (Linux) and have already created a storage volume for it during the wizard-based installation through the My Services Console, then you need to mount your volume on your Linux box:

1. Find out your mounted volumes.
[root@d6c1c9 ~]# df -m
Filesystem     1M-blocks  Used Available Use% Mounted on
/dev/xvdb3         17522  5347     11283  33% /
tmpfs               7392     0      7392   0% /dev/shm

/dev/xvdb1           477   121       327  27% /boot 
You'll notice that on a fresh installation, your 3 main mount points are on the /dev/xvdb device:
  • /boot is on /dev/xvdb1
  • /dev/shm is on /dev/xvdb2 (although not clear here)
  • / is on /dev/xvdb3 

2. View the list of your devices.
[root@d6c1c9 ~]# ls /dev/xvd*
/dev/xvdb  /dev/xvdb1  /dev/xvdb2  /dev/xvdb3  /dev/xvdc
Here you will notice a new device called /dev/xvdc which is not used in your previous step. This is likely your unused storage volume.

3. Create a filesystem. Note that this will trash all data in this device.
[root@d6c1c9 ~]# mkfs -t ext4 /dev/xvdc
mke2fs 1.43-WIP (20-Jun-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
19660800 inodes, 78643200 blocks
3932160 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
2400 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424, 20480000, 23887872, 71663616

Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
4. Now create a directory, mount it, and change ownership of it.
[root@d6c1c9 ~]# mkdir /u01
[root@d6c1c9 ~]# mount /dev/xvdc /u01
[root@d6c1c9 ~]# chown oracle:oinstall /u01
5. Now you'll see your file system mounted and ready to use.
[root@d6c1c9 ~]# df -m
Filesystem     1M-blocks  Used Available Use% Mounted on
/dev/xvdb3         17522  5347     11283  33% /
tmpfs               7392     0      7392   0% /dev/shm
/dev/xvdb1           477   121       327  27% /boot
/dev/xvdc         302380   191    286830   1% /u01
6. Don't forget to add an entry in /etc/fstab so that your file system is mounted on server reboot.
[root@d6c1c9 ~]# echo "/dev/xvdc /u01 ext4 defaults,nofail 0 2" >> /etc/fstab


Applicable Versions:
  • Oracle Compute Cloud (2016)

References:


No comments: