# Lab Answer Key: Module 4: Virtual Machines
Lab 2: Configuring Linux Azure Virtual Machine Storage
To do this lab you'll need the following:
- Microsoft Azure Subscription: http://azure.microsoft.com/en-us/pricing/free-trial/
- Client computer with Internet connectivity.
- An existing Linux Ubuntu Azure virtual machine (created in previous lab)
Lab Exercises
- Add virtual disks to an Azure VM
- Configure newly added disks in a RAID stripe set within an Azure Linux VM
Exercise 1: Add virtual disks to an Linux VM
In this exercise you will add virtual disks to an Linux VM by using the Azure portal
The main tasks for this exercise are as follows:
- Log in to the Azure portal
- Add virtual disks to an Azure
Task 1: Log in to the Azure portal
- Start Internet Explorer and browse to Start Internet Explorer and browse to https://portal.azure.com
- If prompted, sign in with your Microsoft account that is either the Service Admin or a Co-Administrator of your Azure subscription.
Task 2: Add virtual disks to an Azure
- In the Azure portal, browse to Virtual machines.
- In the list of virtual machines, click LABLinuxVM.
- On the LABLinuxVM blade, click Disks.
- On the LABLinuxVM – Disks blade, click Attach new.
- On the Attach new disk blade, make sure that the type of the disk is set to HDD, accept all remaining default settings, and click Location.
- On the Storage accounts blade, click + Storage account.
- On the Create storage account blade, specify the following settings and click OK:
- Name: any unique name between 3 and 24 characters in length, consisting of a combination of lower case letters and digits
- Performance: Standard
- Replication: Locally-redundant storage (LRS)
- Back on the Storage accounts blade, click the newly created storage account.
- On the Containers blade, click + Container.
- On the New container blade, specify the following and click Create:
- Name: vhds
- Access type: Private
- Back on the Containers blade, ensure that vhds is selected and click Select.
- Back on the Attach new disk blade, click OK. Wait until you receive a confirmation that the disk was created. This should take less than a minute.
- On the LABLinuxVM – Disks blade, click Attach new.
- On the Attach new disk blade, make sure that the type of the disk is set to HDD, accept all remaining default settings.
- If the newly created storage account does not appear in the Location section, click Location and, on the Storage accounts blade, click the newly created storage account, then, on the Containers blade, click vhds and click Select.
- Back on the Attach new disk blade, click OK. Wait until you receive a confirmation that the disk was created. This should take less than a minute.
Exercise 2: Create a RAID stripe set within an Azure Linux VM
In this exercise you will configure newly added disks in a RAID stripe set within an Azure Linux VM.
The main tasks for this exercise are as follows:
- Connect to the Azure Linux VM by using PuTTY
- Configure RAID stripe set within the Azure Linux VM
Task 1: Connect to the Azure Linux VM by using PuTTY
Note: If you are already connected to the Linux VM (continuing from the previous lab), skip this task.
- In the Azure portal, in the Overview section of the LABLinuxVM blade, note the Public IP address assigned to the VM
- Start putty.exe you downloaded in the previous lab.
- In the PuTTY Configuration window, type the IP address you noted in step 1 in the Host Name (or IP address) text box.
- In the Category section of the PuTTY Configuration window, expand the Connection->SSH nodes and click Auth.
- Click Browse next to the Private key file for authentication text box.
- In the Select private key file dialog box, navigate to the C:\Users_username directory (where username is your Windows user name), select myPrivateKey_rsa.ppk and click Open.
- If prompted by the PuTTY Security Alert, click Yes.
- In the PuTTY window, when prompted for the username, type Student and verify that you have successfully authenticated.
Task 2: Configure a RAID stripe set within the Azure Linux VM
- In the PuTTY window, run the following to elevate your privileges to root:
sudo su -
- Next, run the following to ensure that the latest version of the mdadm utility necessary to manage RAID configuration is available:
apt-get update
apt-get install mdadm
- Next, run the following to examine SCSI disk operations:
grep SCSI /var/log/syslog
- Examine the results and locate the entries representing the disks you added in the previous exercise. They should resemble the following:
Dec 3 11:04:33 LABLinuxVM kernel: [ 1268.731453] sd 5:0:0:0: [sdc] Attached SCSI disk
Dec 3 11:06:58 LABLinuxVM kernel: [ 1414.415135] sd 5:0:0:1: [sdd] Attached SCSI disk
- Create disk partitions for the first disk by running the following:
fdisk /dev/sdc
- When prompted, use the following sequence of steps:
type n
type p
type 1
press <Enter>
press <Enter>
type t
type fd
type w
- The output should resemble the following:
root@LABLinuxVM:~# fdisk /dev/sdc
Welcome to fdisk (util-linux 2.27.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x59132ebb.
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-2145386495, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-2145386495, default 2145386495):
Created a new partition 1 of type 'Linux' and of size 1023 GiB.
Command (m for help): t
Selected partition 1
Partition type (type L to list all types): fd
Changed type of partition 'Linux' to 'Linux raid autodetect'.
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
root@LABLinuxVM:~#
- Now repeat the same sequence of steps for the second disk. Create disk partitions for the second disk by running the following:
fdisk /dev/sdd
- When prompted, use the following sequence of steps:
type n
type p
type 1
press <Enter>
press <Enter>
type t
type fd
type w
- The output should resemble the following:
root@LABLinuxVM:~# fdisk /dev/sdd
Welcome to fdisk (util-linux 2.27.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0xbbd08528.
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-2145386495, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-2145386495, default 2145386495):
Created a new partition 1 of type 'Linux' and of size 1023 GiB.
Command (m for help): t
Selected partition 1
Partition type (type L to list all types): fd
Changed type of partition 'Linux' to 'Linux raid autodetect'.
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
root@LABLinuxVM:~#
- Create a RAID stripe set consisting of the two disk partitions by running the following:
mdadm --create /dev/md127 --level 0 --raid-devices 2 /dev/sdc /dev/sdd
- When prompted whether to continue creating array, type
y - Create the file system on the new RAID stripe set by running the following:
mkfs -t ext4 /dev/md127
- To add the new file system, start by creating a mount point called data. To accomplish this run the following:
mkdir /data
- To mount the new RAID stripe set, you also need to identify the UUID of the file system you created. To accomplish this run the following:
/sbin/blkid
- Examine the output and identify the UUID value of the /dev/md127 entry. It should resemble the following:
root@LABLinuxVM:~# /sbin/blkid
/dev/sda1: LABEL="cloudimg-rootfs" UUID="e990f8b3-1d6b-4615-8280-8ead4ed2fe7c" TYPE="ext4" PARTUUID="2865a230-01"
/dev/sdb1: LABEL="Temporary Storage" UUID="00C40FB2C40FA94C" TYPE="ntfs" PARTUUID="e08453a8-01"
/dev/sdc1: PARTUUID="59132ebb-01"
/dev/sdd1: PARTUUID="bbd08528-01"
/dev/md127: UUID="b6b3c061-06e4-48ed-86a9-cd87e0a6f59e" TYPE="ext4"
Note: The UUID value in your case will be different. Make sure to use that value in the next step.
- To mount the new file system, add an entry referencing this UUID to the /etc/fstab file. To accomplish this, run the following:
echo UUID=b6b3c061-06e4-48ed-86a9-cd87e0a6f59e /data ext4 defaults 0 2 >> /etc/fstab
- To verify that the new entry in /etc/fstab file is correct, run the following and make sure that no error messages being displayed:
mount -a
- To verify the outcome, run
dfand ensure that the output resembles the following:
root@LABLinuxVM:/data# df
Filesystem 1K-blocks Used Available Use% Mounted on
udev 964696 0 964696 0% /dev
tmpfs 197236 5900 191336 3% /run
/dev/sda1 29595200 1514084 28064732 6% /
tmpfs 986168 0 986168 0% /dev/shm
tmpfs 5120 0 5120 0% /run/lock
tmpfs 986168 0 986168 0% /sys/fs/cgroup
/dev/sda15 106858 3607 103251 4% /boot/efi
/dev/sdb1 4061824 16380 3819400 1% /mnt
tmpfs 197232 0 197232 0% /run/user/1000
/dev/md127 2110406720 81948 2003052172 1% /data
- Finally, to make the RAID array configuration persistent, run the following:
mdadm --detail --scan >> /etc/mdadm/mdadm.conf
Note: After completing the lab, stop the Azure VM from the Azure portal to avoid compute charges.
No comments:
Post a Comment