Linux format and Mount data disks

Source: Internet
Author: User
Tags uicontrol jboss

If you have a data disk for your ECS instance, you will need to format the data disk and mount the file system before you can use the data disk properly.

This article describes how to create a single partition data disk with a new data disk and mount the file system. This article applies only to fdisk partition operations on a data disk that is less than 2 TiB using a command. If you need to partition a data disk larger than 2 TIB, refer to partition format larger than 2 Tib cloud disk.

You can also configure the data disk in multiple partitions, depending on your business needs. It is recommended to use the tool that comes with the system for partitioning operations.

Warning
  • Disk partitioning and formatting are high-risk behaviors, please be careful. This document describes how to process a newly purchased data disk, and if you have data on your data disk, make sure to create a snapshot of the data disk to avoid possible data loss.

  • Cloud server ECS only supports partitioning the data disk, not the system disk. If you forcibly use a third-party tool to partition the system disk, you may raise unknown risks, such as system crashes, data loss, and so on.

Operation Notice

The data disks that are purchased separately need to be mounted before they can be formatted.

The data disks purchased with the instance are not mounted and are formatted directly.

You need to know the device name of the data disk that is mounted to the instance: you can Find the device name of the data disk via the ECS Management Console > Disk details > Disk mount Information . The device name of the data disk is assigned by the system by default, starting from/dev/xvdb and sequentially, the distribution range includes /dev/xvdb? /dev/xvdz.

Operation Steps

In this example, we create a single partition data disk with a new GiB data disk (device name/dev/xvdb) and mount a ext3 file system. The instance used is an I/O optimization instance, and the operating system is CentOS 6.8.

  1. Remote Connection instance.
  2. Run the fdisk -l command to see if the instance has a data disk. If you do not see the/DEV/VDB after executing the command, it means that your instance does not have a data disk, and you do not need to format the data disk, please ignore the following article.
    • If your data disk displays DEV/XVD, it indicates that you are using a non-I/O optimized instance.

    • Which is any of the letters of A?Z.

  3. Create a single partition data disk and execute the following command in turn:
    1. Run fdisk /dev/vdb : Partition the data disk.
    2. Enter n and press ENTER: Create a new partition.
    3. Enter p and press ENTER: Select Primary partition. Because a single partition data disk is created, only the primary partition needs to be created.
      Description
      If you want to create more than 4 partitions, you should create at least one extended partition, which is selected e .
    4. Enter the partition number and press ENTER. Because only one partition is created here, you can enter it 1 .
    5. Enter the first available sector number: Press ENTER to take the default value of 1.
    6. Enter the last sector number: Because only one partition is created here, press ENTER to take the default value.
    7. Inputwqand press ENTER to start the partition.
      [[Email protected] ~]# Fdisk/dev/vdbdevice contains neither a valid DOS partition table, nor Sun, SGIor OSF disklabelbuilding aNew DOS DisklabelWith disk identifier0x5f46a8a2. Changes'll remainIn memory only,Until you decideTo write them. AfterThat,Of course, the previous content won' t be recoverable. Warning:invalid flag 0x0000 of partition Table 4 would be a corrected by W (rite) warning:dos-compatible mode is deprecated. It ' s strongly recommendedToSwitchOff the mode command' C ')and change display unitsTosectors (Command' U '). Command (MFor help): Ncommand actione EXTENDEDP Primary partition (1-4) ppartition number (1-4): 1First Cylinder (1-41610, default 1): 1Last Cylinder, +cylinders or +size{k,m,g} (1-41610, default 41610): Using Default Value  41610Command (M for help ): Wqthe partition table have been altered! Calling IOCTL () to re-read partition table. Syncing disks.                  
  4. To view a new partition: Run a commandfdisk -l。 If the following information appears, the new partition/DEV/VDB1 has been successfully created.
    [[Email protected] ~]# fdisk-ldisk/dev/vda:42.9 GB,42949672960 bytes255 Heads,Sectors/track,5221 cylindersunits = Cylinders of16065 *512 =8225280 bytessector Size (logical/physical):Bytes/BYTESI/O size (Minimum/optimal): bytes/ Bytesdisk identifier:0x00053156device Boot Start End Blocks Id system/dev/vda1 * 1 5222 41942016-linuxdisk/dev/ vdb:21.5 gb, 21474836480 bytes16 heads, Sectors/track, 41610 cylindersunits = cylinders Of 1008 * = 516096 bytessector size (logical/physical):  bytes/ BYTESI/O size (minimum/optimal):  bytes/  Bytesdisk identifier:0x5f46a8a2device Boot Start End Blocks Id System/dev/vdb1 1 41610 20971408+ Linux       
  5. Create a file system on a new partition: Run commandmkfs.ext3 /dev/vdb1
    • This example creates a Ext3 file system. You can also choose to create additional file systems based on your needs, for example, if you need to share files between Linux, Windows, and MAC systems, you can use the mkfs.vfat create VFAT file system.
    • The time it takes to create the file system depends on the data disk size.
      [Email protected] ~]# mkfs.ext3/dev/vdb1mke2fs 1.41.12 (17-may-2010) Filesystem Label=os Type:linuxblocksize=4096 (log=2) Fragmentsize=4096 (log=2)Stride=0 blocks, StripeWidth=0 blocks1310720 inodes, 5242852 blocks262142 blocks (5.00%) reservedfor the Super Userfirst data  Block=0maximum filesystem blocks=4294967296160 block groups32768 blocks per group, 32768 Fragments Per group8192 inodes per Groupsuperblock backups Stored on blocks:32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,4096000writing inode Tables:donec Reating Journal (32768 blocks): donewriting superblocks and filesystem Accounting information:donethis filesystem would be automatically checked every Notoginseng mounts or180 days, whichever comes first. Use tune2fs-c or-i to override.     
  6. (recommended) Backup etc/fstab: Run the command cp /etc/fstab /etc/fstab.bak .
  7. Write new partition information to/etc/fstab: Run command echo /dev/vdb1 /data ext3 defaults 0 0 >> /etc/fstab .
    Description
    Ubuntu 12.04 does not support barrier, so the correct command for the system is: echo ‘/dev/vdb1 /mnt ext3 barrier=0 0 0‘ >> /etc/fstab .

    If you need to attach the data disk to a folder individually, such as for a separate page, replace the above command /data with the desired mount point path.

  8. Viewnew partition information in/etc/fstab: Run command cat /etc/fstab .
    [[email protected] ~]# cat/etc/fstab##/etc/fstab# Created by Anaconda on Thu Feb 23 07:28:22 2017## Accessible filesystems, by reference, is Maintained under '/dev/disk ' # See Mans Pages Fstab (5), Findfs (8), mount (8) and/or Blkid (8) for M Ore info #UUID =3d083579-f5d9-4df5-9347-8d27925805d4/ext4 defaults 1 1tmpfs /dev/shm tmpfs defaults 0 0devpts /dev/pts devpts gid=5,mode=620 0 0sysfs /sys sysfs defaults 0 0proc /proc proc defaults 0 0 /dev/vdb1 /data ext3 defaults 0 0      
  9. Mount file system: Run command mount /dev/vdb1 /data .
  10. View Current disk space and usage: Run the command df -h . If the information for the new file system appears, the mount is successful and the new file system can be used.

    After the mount operation is complete, you do not need to restart the instance to start using the new file system.

    40G 6.6G 31G 18% /tmpfs 499M 0 499M 0% /dev/shm/dev/vdb1 20G 173M 19G 1% /data

Linux format and Mount data disks

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.