Attaching data disks to centos 7

Source: Internet
Author: User

Attaching data disks to centos 7

  1. Use the remote connection tool and enter the user name root and password to log on to the instance.

  2. Run the fdisk-l command to view the data disk. Note: Before you partition or format a data disk, you cannot use the df-h command to view the data disk. In the following example, a 5 GB Data disk needs to be mounted.
    If/dev/xvdb is not found after the fdisk-l command is executed, it indicates that your instance does not have a data disk and therefore does not need to be mounted. You can ignore this chapter.

     [root@xxxx ~]# fdisk -l Disk /dev/xvda: 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: 0x00078f9c Device Boot      Start         End      Blocks   Id  System /dev/xvda1   *           1        5222    41940992   83  Linux Disk /dev/xvdb: 5368 MB, 5368709120 bytes 255 heads, 63 sectors/track, 652 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: 0x00000000
  3. Run the following command to partition the data disk.
     fdisk /dev/xvdb
  4. Enter n, p, 1, and press enter, wq, And the partition starts.

     [root@xxx ~]# fdisk /dev/xvdb Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklab            el Building a new DOS disklabel with disk identifier 0x33eb5059. 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-652, default 1):  Using default value 1 Last cylinder, +cylinders or +size{K,M,G} (1-652, default 652): Using default value 652 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. The new partition xvdb1 has been created. For example,/dev/xvdb1 in the following example.

     [root@xxx ~]# fdisk -l Disk /dev/xvda: 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: 0x00078f9c Device Boot      Start         End      Blocks   Id  System /dev/xvda1   *           1        5222    41940992   83  Linux Disk /dev/xvdb: 5368 MB, 5368709120 bytes 255 heads, 63 sectors/track, 652 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: 0x33eb5059 Device Boot      Start         End      Blocks   Id  System /dev/xvdb1               1         652     5237158+  83  Linux
  6. Run the following command to format the new partition. The time required for formatting depends on the size of the data disk. You can also choose other file formats, such as ext14.

     mkfs.ext3 /dev/xvdb1
  7. Run the following command to write new partition information.

     echo '/dev/xvdb1 /mnt ext3 defaults 0 0'>> /etc/fstab


    After that, you can run the cat/etc/fstab command.
    Note: Ubuntu 12.04 does not support barrier, so the correct command for this system is:

     echo '/dev/xvdb1 /mnt ext3 barrier=0 0 0'>>/etc/fstab


    If you need to mount the data disk to a folder separately, for example, to store webpages separately, you can modify the/mnt part of the preceding command.

  8. Run mount/dev/xvdb1/mnt to mount the new partition, and then run df-h to view the partition. If the data disk information appears, it indicates that the mounting is successful. You can use the new partition.

     [root@xxx ~]# mount /dev/xvdb1 /mnt [root@xxx ~]# df -h Filesystem      Size  Used Avail Use% Mounted on /dev/xvda1       40G  1.5G   36G   4% / tmpfs           498M     0  498M   0% /dev/shm /dev/xvdb1      5.0G  139M  4.6G   3% /mnt

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.