阿里云格式化和挂载数据盘
当你在阿里云买了服务器,随着业务量越来越大。数据盘的容量也就会不够用。所以我们就会新增一块云盘。下面讲新增云盘之后,然后挂载上去。 这是新手的教程,也是我的笔记。
第一步: 使用远程连接工具,输入用户名 root 和密码登录到实例。
第二步:运行 fdisk -l 命令查看数据盘。注意:在没有分区和格式化数据盘之前,使用 df -h 命令是无法看到数据盘的。在下面的示例中,有一个 5 GB 的数据盘需要挂载。 [root@xxxx ~]# fdisk -l<br>
<br>
Disk /dev/xvda: 42.9 GB, 42949672960 bytes<br>
255 heads, 63 sectors/track, 5221 cylinders<br>
Units = cylinders of 16065 * 512 = 8225280 bytes<br>
Sector size (logical/physical): 512 bytes / 512 bytes<br>
I/O size (minimum/optimal): 512 bytes / 512 bytes<br>
Disk identifier: 0x00078f9c<br>
<br>
Device Boot Start End Blocks Id System<br>
/dev/xvda1 * 1 5222 41940992 83 Linux<br>
<br>
Disk /dev/xvdb: 5368 MB, 5368709120 bytes<br>
255 heads, 63 sectors/track, 652 cylinders<br>
Units = cylinders of 16065 * 512 = 8225280 bytes<br>
Sector size (logical/physical): 512 bytes / 512 bytes<br>
I/O size (minimum/optimal): 512 bytes / 512 bytes<br>
Disk identifier: 0x00000000
第三步:执行下列命令,对数据盘进行分区。 fdisk /dev/xvdb
第四步:根据提示,依次输入 n,p,1,两次回车,wq,分区就开始了。 [root@xxx ~]# fdisk /dev/xvdb<br>
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklab el<br>
Building a new DOS disklabel with disk identifier 0x33eb5059.<br>
Changes will remain in memory only, until you decide to write them.<br>
After that, of course, the previous content won't be recoverable.<br>
<br>
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)<br>
<br>
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to<br>
switch off the mode (command 'c') and change display units to<br>
sectors (command 'u').<br>
<br>
Command (m for help): n<br>
Command action<br>
e extended<br>
p primary partition (1-4)<br>
p<br>
Partition number (1-4): 1<br>
First cylinder (1-652, default 1): <br>
Using default value 1<br>
Last cylinder, +cylinders or +size{K,M,G} (1-652, default 652):<br>
Using default value 652<br>
<br>
Command (m for help): wq<br>
The partition table has been altered!<br>
<br>
Calling ioctl() to re-read partition table.<br>
Syncing disks.
第五步:执行 fdisk -l 命令,查看新的分区。新分区 xvdb1 已经创建好。如下面示例中的/dev/xvdb1。 [root@xxx ~]# fdisk -l<br>
<br>
Disk /dev/xvda: 42.9 GB, 42949672960 bytes<br>
255 heads, 63 sectors/track, 5221 cylinders<br>
Units = cylinders of 16065 * 512 = 8225280 bytes<br>
Sector size (logical/physical): 512 bytes / 512 bytes<br>
I/O size (minimum/optimal): 512 bytes / 512 bytes<br>
Disk identifier: 0x00078f9c<br>
<br>
Device Boot Start End Blocks Id System<br>
/dev/xvda1 * 1 5222 41940992 83 Linux<br>
<br>
Disk /dev/xvdb: 5368 MB, 5368709120 bytes<br>
255 heads, 63 sectors/track, 652 cylinders<br>
Units = cylinders of 16065 * 512 = 8225280 bytes<br>
Sector size (logical/physical): 512 bytes / 512 bytes<br>
I/O size (minimum/optimal): 512 bytes / 512 bytes<br>
Disk identifier: 0x33eb5059<br>
<br>
Device Boot Start End Blocks Id System<br>
/dev/xvdb1 1 652 5237158+ 83 Linux
第六步:执行下列命令,对新分区进行格式化。格式化所需时间取决于数据盘大小。您也可自主决定选用其他文件格式,如 ext14 等。mkfs.ext3 /dev/xvdb1
第七步:执行下列命令写入新分区信息。 echo '/dev/xvdb1 /mnt ext3 defaults 0 0'>> /etc/fstab
完成后,可以使用 cat /etc/fstab 命令查看。
注意: Ubuntu 12.04 不支持 barrier,所以对该系统正确的命令是:echo '/dev/xvdb1 /mnt ext3 barrier=0 0 0'>>/etc/fstab
如果需要把数据盘单独挂载到某个文件夹,比如单独用来存放网页,可以修改以上命令中的 /mnt 部分。
第八步:执行 mount /dev/xvdb1 /mnt 挂载新分区,然后执行 df -h 查看分区。如果出现数据盘信息,说明挂载成功,可以使用新分区了。 [root@xxx ~]# mount /dev/xvdb1 /mnt<br>
[root@xxx ~]# df -h<br>
Filesystem Size Used Avail Use% Mounted on<br>
/dev/xvda1 40G 1.5G 36G 4% /<br>
tmpfs 498M 0 498M 0% /dev/shm<br>
/dev/xvdb1 5.0G 139M 4.6G 3% /mnt
总结: 全部按照命令来的话,基本上是没有什么问题的。 可能比较疑惑的是挂载的路径问题。当前我以为挂载到某一个路径,然后就会把那个文件夹的容量增大。谁知道不是。而这只是一个链接指向而已。
也就是说。你的挂载路径,只是将路径重新指向到新的云盘。而且这个路径之前的数据就会看不见了。除非你umount ,才会看到原来的数据。
如果你们还有哪里不明白的地方,欢迎提问 或者加我QQ 164418960
AD:真正免费,域名+虚机+企业邮箱=0元

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Learn about Python programming with introductory code examples Python is an easy-to-learn, yet powerful programming language. For beginners, it is very important to understand the introductory code examples of Python programming. This article will provide you with some concrete code examples to help you get started quickly. Print HelloWorldprint("HelloWorld") This is the simplest code example in Python. The print() function is used to output the specified content

PHP variables store values during program runtime and are crucial for building dynamic and interactive WEB applications. This article takes an in-depth look at PHP variables and shows them in action with 10 real-life examples. 1. Store user input $username=$_POST["username"];$passWord=$_POST["password"]; This example extracts the username and password from the form submission and stores them in variables for further processing. 2. Set the configuration value $database_host="localhost";$database_username="username";$database_pa

Title: From Beginner to Mastery: Code Implementation of Commonly Used Data Structures in Go Language Data structures play a vital role in programming and are the basis of programming. In the Go language, there are many commonly used data structures, and mastering the implementation of these data structures is crucial to becoming a good programmer. This article will introduce the commonly used data structures in the Go language and give corresponding code examples to help readers from getting started to becoming proficient in these data structures. 1. Array Array is a basic data structure, a group of the same type

The simplest code example of Java bubble sort Bubble sort is a common sorting algorithm. Its basic idea is to gradually adjust the sequence to be sorted into an ordered sequence through the comparison and exchange of adjacent elements. Here is a simple Java code example that demonstrates how to implement bubble sort: publicclassBubbleSort{publicstaticvoidbubbleSort(int[]arr){int

"Go Language Programming Examples: Code Examples in Web Development" With the rapid development of the Internet, Web development has become an indispensable part of various industries. As a programming language with powerful functions and superior performance, Go language is increasingly favored by developers in web development. This article will introduce how to use Go language for Web development through specific code examples, so that readers can better understand and use Go language to build their own Web applications. 1. Simple HTTP Server First, let’s start with a

Huawei Cloud Edge Computing Interconnection Guide: Java Code Samples to Quickly Implement Interfaces With the rapid development of IoT technology and the rise of edge computing, more and more enterprises are beginning to pay attention to the application of edge computing. Huawei Cloud provides edge computing services, providing enterprises with highly reliable computing resources and a convenient development environment, making edge computing applications easier to implement. This article will introduce how to quickly implement the Huawei Cloud edge computing interface through Java code. First, we need to prepare the development environment. Make sure you have the Java Development Kit installed (

Java Selection Sorting Method Code Writing Guide and Examples Selection sorting is a simple and intuitive sorting algorithm. The idea is to select the smallest (or largest) element from the unsorted elements each time and exchange it until all elements are sorted. This article will provide a code writing guide for selection sorting, and attach specific Java sample code. Algorithm Principle The basic principle of selection sort is to divide the array to be sorted into two parts, sorted and unsorted. Each time, the smallest (or largest) element is selected from the unsorted part and placed at the end of the sorted part. Repeat the above

How to use PHP to write the inventory management function code in the inventory management system. Inventory management is an indispensable part of many enterprises. For companies with multiple warehouses, the inventory management function is particularly important. By properly managing and tracking inventory, companies can allocate inventory between different warehouses, optimize operating costs, and improve collaboration efficiency. This article will introduce how to use PHP to write code for inventory warehouse management functions, and provide you with relevant code examples. 1. Establish the database before starting to write the code for the inventory warehouse management function.
