After creating a virtual machine on azure, in some cases we will need to add more data disks to store persisted data, this article describes how to quickly add data disks and initialize on Azure Linux virtual machines:
Log in to Azure's management interface and create virtual machines, this article uses CentOS 6.5 as a sample operating system, similar to other Linux operating systems
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6D/22/wKioL1VddP3i8x_fAAPyWXvcLz4231.jpg "title=" vm.png "alt=" Wkiol1vddp3i8x_faapywxvclz4231.jpg "/>
We first use SSH to log on to the Linux operating system, check the current system's disk status:
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6D/22/wKioL1VddeOTOVZ5AANx2jdUR8c868.jpg "title=" Disk1.png "alt=" wkiol1vddeotovz5aanx2jdur8c868.jpg "/> We can see that there are only/SDA and/SDB devices under the current Linux system, where/DEV/SDB1 is a temporary disk that is automatically assigned by the system , do not store important data on top of it, and important data needs to be stored in the newly persisted storage.
On the Azure Management portal, select the virtual machine you want to add the disk to, select "Dashboard", and at the bottom of the menu bar select "Attach"-"Append empty Disk" To add a new data disk:
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6D/22/wKioL1Vdd5HgonUCAAdkHoG34fo899.jpg "title=" Addnewdisk.png "alt=" Wkiol1vdd5hgonucaadkhog34fo899.jpg "/>
In the pop-up dialog box, select the size of the disk you want to add, the maximum size of a single disk is not more than 1T, depending on the virtual machine sizes, the maximum number of disk books can be added, refer to the official documentation (https://msdn.microsoft.com/zh-cn/library/ dn197896.aspx), the department is set to 50G for testing purposes:
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/6D/28/wKiom1VdeBTjjVMAAAIbFvKcWwg755.jpg "title=" Size.png "alt=" Wkiom1vdebtjjvmaaaibfvkcwwg755.jpg "/>
After the interface has been added to the disk, you can see the following information, the system more than one data disk:
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6D/28/wKiom1VdexbCQ5yaAAQW0AleyWE077.jpg "title=" Adddisksucc.png "alt=" Wkiom1vdexbcq5yaaaqw0aleywe077.jpg "/>
Using SSH to log on to a Linux virtual machine, the rest of the steps are done through the Linux command line. First check the current system hardware changes and current device changes, using the following command to check:
[email protected] ~]$ sudo tail-f/var/log/messages
[Email protected] ~]$ ls-l/dev/sd*
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/6D/28/wKiom1VdfADSr4sRAApRmElkP1E581.jpg "title=" Checklinuxpar.png "alt=" Wkiom1vdfadsr4sraaprmelkp1e581.jpg "/>
You can see that the system has actually added a SDC device, the new system disk is added, but no partition is not formatted, just as you hang a hard disk to a server is the same, so the first step we use FDISK to partition:
$ sudo fdisk/dev/sdc
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6D/2F/wKioL1Vd5S7xO3iHAApMNgpKp9E456.jpg "title=" Format.png "alt=" Wkiol1vd5s7xo3ihaapmngpkp9e456.jpg "/>
Enter n at its prompt, create a new partition, p Select primary partition,w to write the relevant results to the partition table.
8. After partitioning the newly loaded hard drive, we need to format the newly created partition into a file system that the city system can recognize:
$ sudo mkfs-t ext4/dev/sdc1
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/6D/2F/wKioL1Vd5l-hitt9AAcChHllqz8378.jpg "title=" Formatext4.png "alt=" Wkiol1vd5l-hitt9aacchhllqz8378.jpg "/>
9. Create a new directory to mount the new partition, use/data in this example, and then mount the new partition to the directory:
$ sudo mkdir/data
$ sudo mount/dev/sdc1/data
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6D/34/wKiom1Vd5h7wcHjnAAPUo2qrLes067.jpg "title=" Mount.png "alt=" Wkiom1vd5h7wchjnaapuo2qrles067.jpg "/>
10. So far, you can normally use the newly loaded data disk, loading directory in/data, however, there is a problem is that the temporary loading of the hard disk, once the system restarts, the loading information will be lost, under Linux, the disk loading information will be saved in the Fstab file, The system automatically loads the partitions in the file, and when we load the disk, we generally use the UUID as the identifier:
$ sudo-i Blkid
$ sudo vi/etc/fstab
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6D/34/wKiom1Vd58ugHN6uAANoxlxrrf0459.jpg "style=" float: none; "title=" Fstab.png "alt=" Wkiom1vd58ughn6uaanoxlxrrf0459.jpg "/>
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6D/2F/wKioL1Vd6UWyhvG-AAQGLXBZM-k987.jpg "style=" float: none; "title=" Fstab_file.png "alt=" Wkiol1vd6uwyhvg-aaqglxbzm-k987.jpg "/>
11. The last thing, the currently created/data, belongs to the root user, which means that the directory cannot be used by other users, what if the default user Azureuser want to read and write the directory? You can create a subdirectory under this directory, modify the Owner property using the Linux command, and then use the following:
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6D/2F/wKioL1Vd6eDwTJAMAAWIsdR_sZU377.jpg "title=" Subdir.png "alt=" Wkiol1vd6edwtjamaawisdr_szu377.jpg "/>
This article is from the "cloud Big Data Life" blog, make sure to keep this source http://cloudapps.blog.51cto.com/3136598/1653673
How to mount a data disk under Linux on Azure