This article shows you how to attach both new and existing
disks to a Linux virtual machine through the Azure portal.
Add a data disk
1. Sign in to
the Azure
portal.
2. Search for and
select Virtual machines.
3. Select a virtual
machine from the list.
4. On the Virtual
machine pane, select Disks.
5. On the Disks pane,
select Create and attach a new disk.
6. In the drop-downs
for the new disk, make the selections you want, and name the disk.
7. Select Save to
create and attach the new data disk to the VM.
Attach an existing
disk
1. On the Disks pane, under Data disks, select Attach existing disks.
2. Click the drop-down menu for Disk name and select a disk from the list of available managed disks.
3. Click Save to attach the existing managed disk and update the VM configuration:
Connect to the
Linux VM to mount the new disk
# df -h
# grep SCSI /var/log/messages
# lsblk -o NAME,HCTL,SIZE,MOUNTPOINT | grep -i "sd"
# lsblk
# parted /dev/sdc --script mklabel gpt mkpart xfspart xfs 0%
100%
# mkfs.xfs /dev/sdc1
# partprobe /dev/sdc1
# mkdir /datadrive
# mount /dev/sdc1 /datadrive
# blkid
# vi /etc/fstab
UUID=afd7eaf0-5e3f-40a1-93bd-31331a4a1720 /datadrive xfs
defaults,nofail 1 2
wq!
# lsblk -o NAME,HCTL,SIZE,MOUNTPOINT | grep -i "sd"
now you can use this disk as storage.
Note:
Improperly editing the /etc/fstab file could result in an unbootable system. If unsure, refer to the
distribution's documentation for information on how to properly edit this file.
It is also recommended that a backup of the /etc/fstab file is created before
editing.
Later removing a data disk without editing fstab could cause
the VM to fail to boot. Most distributions provide either the nofail and/or nobootwait fstab
options. These options allow a system to boot even if the disk fails to mount
at boot time. Consult your distribution's documentation for more information on
these parameters.
The nofail option
ensures that the VM starts even if the filesystem is corrupt or the disk does
not exist at boot time. Without this option, you may encounter behavior as
described in Cannot SSH to Linux VM due to FSTAB errors
Initialize a new data disk
1.
Connect to the VM.
2.
Select the Windows Start menu
inside the running VM and enter diskmgmt.msc in the search
box. The Disk Management console opens.
3.
Disk Management recognizes that you have a new,
uninitialized disk and the Initialize Disk window appears.
4.
Verify the new disk is selected and then select OK to
initialize it.
5.
The new disk appears as unallocated.
Right-click anywhere on the disk and select New simple volume. The New
Simple Volume Wizard window opens.
6.
Proceed through the wizard, keeping all of the
defaults, and when you're done select Finish.
7.
Close Disk Management.
8.
A pop-up window appears notifying you that you
need to format the new disk before you can use it. Select Format disk.
9.
In the Format new disk window,
check the settings, and then select Start.
10.
A warning appears notifying you that formatting
the disks erases all of the data. Select OK.
11.
When the formatting is complete, select OK.
Comments
Post a Comment