2) Format & Mount a Data Disk

To make the data disk ready for use, you need to format and mount the disk to YMP instance.

You need to attach data disk to YMP instance before formatting and mounting the disk.

  1. Log in YMP server via SSH.
  2. Run sudo -i to get administrator privileges.
  3. Run the fdisk -l command to view the data disk.
    Note: If you do not find /dev/vdb after running the command, it indicates that your YMP instance does not have a data disk.
  4. Create a single-partition data disk and execute the following commands in sequence:
    1. Run fdisk /dev/vdb to partition the data disk.
    2. Enter n and press the Enter key to create a new partition.
    3. Enter p and press the Enter key to select the primary partition.
    4. Enter the partition number. Press the Enter key to use the default value.
    5. Enter the first available sector number. Press the Enter key to use the default value.
    6. Enter a number for the last sector. Press the Enter key to use the default value.
    7. Run wq and press the Enter key.
    [root@iXXXXXXX ~]# fdisk /dev/vdb
    Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
    Building a new DOS disklabel with disk identifier 0x5f46a8a2.
    Changes will remain in memory only, until you decide to write them.
    After that, of course, the previous content won't be recoverable.
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
    WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
    switch off the mode (command 'c') and change display units to
    sectors (command 'u').
    Command (m for help): n
    Command action
    e extended
    p primary partition (1-4)
    p
    Partition number (1-4): 1
    First cylinder (1-41610, default 1): 1
    Last cylinder, +cylinders or +size{K,M,G} (1-41610, default 41610):
    Using default value 41610
    Command (m for help): wq
    The partition table has been altered!
    Calling ioctl() to re-read partition table.
    Syncing disks.
  5. Run the fdisk -l command to view the new partition. If the following information appears, the new partition /dev/vdb1 is created.
    [root@iXXXXXXX ~]# fdisk -l
    Disk /dev/vda: 42.9 GB, 42949672960 bytes
    255 heads, 63 sectors/track, 5221 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x00053156
    Device Boot Start End Blocks Id System
    /dev/vda1 * 1 5222 41942016 83 Linux
    Disk /dev/vdb: 21.5 GB, 21474836480 bytes
    16 heads, 63 sectors/track, 41610 cylinders
    Units = cylinders of 1008 * 512 = 516096 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x5f46a8a2
    Device Boot Start End Blocks Id System
    /dev/vdb1 1 41610 20971408+ 83 Linux
  6. Run the command mkfs.ext4 /dev/vdb1 to create a file system on the new partition.
  7. Run the command cp /etc/fstab /etc/fstab.bak to back up the data disk.
  8. Run the command echo /dev/vdb1 /mnt/autorecording ext4 defaults,nofail 0 0 >> /etc/fstab to write new partition information to /etc/fstab.
  9. View the new partition information in /etc/fstab: Run the command cat /etc/fstab.
    [root@iXXXXXXX ~]# cat /etc/fstab
    #
    # /etc/fstab
    # Created by anaconda on Thu Feb 23 07:28:22 2017
    #
    # Accessible filesystems, by reference, are maintained under '/dev/disk'
    # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
    #
    UUID=3d083579-f5d9-4df5-9347-8d27925805d4 / ext4 defaults 1 1
    tmpfs /dev/shm tmpfs defaults 0 0
    devpts /dev/pts devpts gid=5,mode=620 0 0
    sysfs /sys sysfs defaults 0 0
    proc /proc proc defaults 0 0
    /dev/vdb1 /mnt ext4 defaults 0 0
  10. Create a folder autorecording under /mnt: Run the command mkdir -p /mnt/autorecording.
  11. Mount the file system: Run the command mount /dev/vdb1 /mnt/autorecording.
  12. To view disk space and usage: Run the command df -h.

    If the new file system information appears in the returned results, the mount operation is successful and you can use the new file system.

    [root@iXXXXXXX ~]# mount /dev/vdb1 /mnt/autorecording
    [root@iXXXXXXX ~]# df -h
    Filesystem Size Used Avail Use% Mounted on
    /dev/vda1 40G 6.6G 31G 18% /
    tmpfs 499M 0 499M 0% /dev/shm
    /dev/vdb1 20G 173M 19G 1% /mnt/autorecording