Being an Application or a Database administrator you must have come across a situations many times wherein you would require a mountpoint for some requirements. In this article we’ll ses how it happens step by step.
List the attached disks using fdisk.
[root@dbnode1 ~]# fdisk -l
Disk /dev/xvda: 214.7 GB, 214748364800 bytes, 419430400 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000cdbad
Device Boot Start End Blocks Id System
/dev/xvda1 * 2048 2099199 1048576 83 Linux
/dev/xvda2 2099200 419430399 208665600 8e Linux LVM
Disk /dev/mapper/ol_dbnode1-root: 53.7 GB, 53687091200 bytes, 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/ol_dbnode1-swap: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/ol_dbnode1-home: 157.8 GB, 157831659520 bytes, 308264960 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/xvdb: 5368 MB, 5368709120 bytes, 10485760 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
In order to use this disk, before we can mount it we will have to create a partition first and then file system.
So let’s create a partiton first.
Select the newly attached which disk you want to mount.
[root@dbnode1 ~]# fdisk /dev/xvdb
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0xc5005674.
Command (m for help):
Type m to list all fdisk commands.
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
g create a new empty GPT partition table
G create an IRIX (SGI) partition table
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
As listed above use n to add a new partition on selected disk.
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select primary using p or just hit enter as p is the default one. Then keep and hitting enter for fdisk to take default first and last sector in order to use entire disk for this partition.
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-10485759, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-10485759, default 10485759):
Using default value 10485759
Partition 1 of type Linux and of size 5 GiB is set
Once the partition is created, save it using w.
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
The partition is now created, let’s create a file system now.
[root@dbnode1 ~]# mkfs -t ext3 /dev/xvdb1
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
327680 inodes, 1310464 blocks
65523 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1342177280
40 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
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
File System is also created now. Let’s create a directory and mount our new device.
[root@dbnode1 ~]# mkdir /pg_bin
[root@dbnode1 ~]# mount -t ext3 /dev/xvdb1 /pg_bin/
Verify
[root@dbnode1 ~]# df -hTP | grep pg_bin
/dev/xvdb1 ext3 4.8G 11M 4.6G 1% /pg_bin
There you go, we have mounted the new disk on /pg_bin mountpoint.
Check this post to see how to add a disk to a running VM.
Peace 🙂