How to mount and detach data disks on a linux Server

Source: Internet
Author: User

How to mount and detach data disks on a linux Server

If you select a data disk when creating an instance, after logging on to the instance, the system needs to format the data disk and then mount the data disk.

In addition, you can configure multiple partitions for data disks based on business needs. We recommend that you use the built-in tools for partitioning.

Note: ECS only supports secondary partitioning of data disks, but does not support secondary partitioning of system disks (either Windows or Linux ). If you forcibly use a third-party tool to perform secondary partitioning on the system disk, unknown risks may occur, such as system crash and data loss.

This operation applies to non-I/O optimized + SSD cloud disk Linux (Redhat, CentOS, Debian, Ubuntu) instances.

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

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.

Run fdisk/dev/xvdb to partition the data disk. Enter n, p, 1, and press enter, wq, And the partition starts.

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.

Run mkfs. ext3/dev/xvdb1 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 ext4.

Run echo/dev/xvdb1/mnt ext3 defaults 0 0>/etc/fstab to write new partition information. After that, you can run the cat/etc/fstab command.

Note: Ubuntu 12.04 does not support barrier. Therefore, the correct command for this system is echo/dev/xvdb1/mnt ext3 defaults 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.

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.

Mount/dev/xvdb1/mnt

Df-h

FilesystemSizeUsedAvailUse % Mountedon

/Dev/xvda140G1.5G36G4 %/

Tmpfs498M0498M0 %/dev/shm

/Dev/xvdb15.0G139M4.6G3 %/mnt

Ii. Uninstall

Umount/dev/xvdb1

The system prompts that the device is busy and cannot be mounted.

Fuser-km/dev/xvdb1

Umount/dev/xvdb1

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.