2) Format & Mount a Persistent Disk

The new persistent disk starts with no data or file system. You must format the disk after you attach it to YMP instance.

  1. Log in YMP server via SSH.
  2. Run sudo -i to get administrator privileges.
  3. Run the lsblk command to view the data disk that is attached to your instance and find the disk that you want to format and mount.
    root@XXXXXXX:~# lsblk
    NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
    sda      8:0    0   10G  0 disk 
    └─sda1   8:1    0   10G  0 part /
    sdb      8:16   0  500G  0 disk 
    The output removes the /dev/ prefix from full device paths.
    In this example, /dev/sda1 is mounted as the system disk, and /dev/sdb is attached, bu has not been mounted yet.
  4. Create a single-partition data disk and execute the following commands in sequence:
    1. Run fdisk [DISK_NAME] to partition the data disk.

      [DISK_NAME] is the data disk name, for example, /dev/sdb.

    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@XXXXXXX:~# fdisk /dev/sdb
    Welcome to fdisk (util-linux 2.27.1).
    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.
    Created a new DOS disklabel with disk identifier 0x778c4b4c.
    Command (m for help): n
    Partition type
       p   primary (0 primary, 0 extended, 4 free)
       e   extended (container for logical partitions)
    Select (default p): p
    Partition number (1-4, default 1): 
    First sector (2048-1048575999, default 2048): 
    Last sector, +sectors or +size{K,M,G,T,P} (2048-1048575999, default 1048575999): 
    Created a new partition 1 of type 'Linux' and of size 500 GiB.
    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/sdb1 is created.
    root@XXXXXXX:~# fdisk -l
    Disk /dev/sda: 10 GiB, 10737418240 bytes, 20971520 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 4096 bytes
    I/O size (minimum/optimal): 4096 bytes / 4096 bytes
    Disklabel type: dos
    Disk identifier: 0x55bca5c1
    Device     Boot Start      End  Sectors Size Id Type
    /dev/sda1  *     2048 20971486 20969439  10G 83 Linux
    Disk /dev/sdb: 500 GiB, 536870912000 bytes, 1048576000 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 4096 bytes
    I/O size (minimum/optimal): 4096 bytes / 4096 bytes
    Disklabel type: dos
    Disk identifier: 0x778c4b4c
    Device     Boot Start        End    Sectors  Size Id Type
    /dev/sdb1        2048 1048575999 1048573952  500G 83 Linux
  6. Run the command mkfs.ext4 /dev/sdb1 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/sdb1 /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@XXXXXXX:~# cat /etc/fstab
    LABEL=cloudimg-rootfs	/	 ext4	defaults	0 0
    /dev/sdb1 /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/sdb1 /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@XXXXXXX:~# df -h
    Filesystem      Size  Used Avail Use% Mounted on
    udev            986M     0  986M   0% /dev
    tmpfs           200M  3.1M  197M   2% /run
    /dev/sda1       9.7G  2.0G  7.7G  21% /
    tmpfs           997M     0  997M   0% /dev/shm
    tmpfs           5.0M     0  5.0M   0% /run/lock
    tmpfs           997M     0  997M   0% /sys/fs/cgroup
    tmpfs           200M     0  200M   0% /run/user/1002
    /dev/sdb1       493G   70M  467G   1% /mnt/autorecording