Skip to content

Commit 0618b5f

Browse files
Merge pull request #232485 from msLinuxNinja/main
[Doc-a-thon] Update document with consistency and commands
2 parents 98534d0 + 12fa370 commit 0618b5f

File tree

1 file changed

+29
-12
lines changed

1 file changed

+29
-12
lines changed

articles/virtual-machines/linux/add-disk.md

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ lsblk -o NAME,HCTL,SIZE,MOUNTPOINT | grep -i "sd"
6363

6464
The output is similar to the following example:
6565

66-
```bash
66+
```output
6767
sda 0:0:0:0 30G
6868
├─sda1 29.9G /
6969
├─sda14 4M
@@ -73,7 +73,17 @@ sdb 1:0:1:0 14G
7373
sdc 3:0:0:0 50G
7474
```
7575

76-
Here, `sdc` is the disk that we want, because it's 50G. If you add multiple disks, and aren't sure which disk it's based on size alone, you can go to the VM page in the portal, select **Disks**, and check the LUN number for the disk under **Data disks**. Compare the LUN number from the portal to the last number of the **HTCL** portion of the output, which is the LUN.
76+
Here, `sdc` is the disk that we want, because it's 50G. If you add multiple disks, and aren't sure which disk it's based on size alone, you can go to the VM page in the portal, select **Disks**, and check the LUN number for the disk under **Data disks**. Compare the LUN number from the portal to the last number of the **HTCL** portion of the output, which is the LUN. Another option is to list the contents of the `/dev/disk/azure/scsi1` directory:
77+
78+
```bash
79+
ls -l /dev/disk/azure/scsi1
80+
```
81+
82+
The output should be similar to the following example:
83+
84+
```output
85+
lrwxrwxrwx 1 root root 12 Mar 28 19:41 lun0 -> ../../../sdc
86+
```
7787

7888

7989
### Format the disk
@@ -89,8 +99,8 @@ The following example uses `parted` on `/dev/sdc`, which is where the first data
8999

90100
```bash
91101
sudo parted /dev/sdc --script mklabel gpt mkpart xfspart xfs 0% 100%
92-
sudo mkfs.xfs /dev/sdc1
93102
sudo partprobe /dev/sdc1
103+
sudo mkfs.xfs /dev/sdc1
94104
```
95105

96106
Use the [`partprobe`](https://linux.die.net/man/8/partprobe) utility to make sure the kernel is aware of the new partition and filesystem. Failure to use `partprobe` can cause the blkid or lsblk commands to not return the UUID for the new filesystem immediately.
@@ -112,15 +122,15 @@ sudo mount /dev/sdc1 /datadrive
112122

113123
### Persist the mount
114124

115-
To ensure that the drive is remounted automatically after a reboot, it must be added to the */etc/fstab* file. It's also highly recommended that the UUID (Universally Unique Identifier) is used in */etc/fstab* to refer to the drive rather than just the device name (such as, */dev/sdc1*). If the OS detects a disk error during boot, using the UUID avoids the incorrect disk being mounted to a given location. Remaining data disks would then be assigned those same device IDs. To find the UUID of the new drive, use the `blkid` utility:
125+
To ensure that the drive is remounted automatically after a reboot, it must be added to the `/etc/fstab` file. It's also highly recommended that the UUID (Universally Unique Identifier) is used in `/etc/fstab` to refer to the drive rather than just the device name (such as, */dev/sdc1*). If the OS detects a disk error during boot, using the UUID avoids the incorrect disk being mounted to a given location. Remaining data disks would then be assigned those same device IDs. To find the UUID of the new drive, use the `blkid` utility:
116126

117127
```bash
118128
sudo blkid
119129
```
120130

121131
The output looks similar to the following example:
122132

123-
```bash
133+
```output
124134
/dev/sda1: LABEL="cloudimg-rootfs" UUID="11111111-1b1b-1c1c-1d1d-1e1e1e1e1e1e" TYPE="ext4" PARTUUID="1a1b1c1d-11aa-1234-1a1a1a1a1a1a"
125135
/dev/sda15: LABEL="UEFI" UUID="BCD7-96A6" TYPE="vfat" PARTUUID="1e1g1cg1h-11aa-1234-1u1u1a1a1u1u"
126136
/dev/sdb1: UUID="22222222-2b2b-2c2c-2d2d-2e2e2e2e2e2e" TYPE="ext4" TYPE="ext4" PARTUUID="1a2b3c4d-01"
@@ -129,16 +139,22 @@ The output looks similar to the following example:
129139
```
130140

131141
> [!NOTE]
132-
> 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.
142+
> 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.
133143
134-
Next, open the **/etc/fstab** file in a text editor. Add a line to the end of the file, using the UUID value for the `/dev/sdc1` device that was created in the previous steps, and the mountpoint of `/datadrive`. Using the example from this article, the new line would look like the following:
144+
Next, open the `/etc/fstab` file in a text editor. Add a line to the end of the file, using the UUID value for the `/dev/sdc1` device that was created in the previous steps, and the mountpoint of `/datadrive`. Using the example from this article, the new line would look like the following:
135145

136-
```bash
146+
```output
137147
UUID=33333333-3b3b-3c3c-3d3d-3e3e3e3e3e3e /datadrive xfs defaults,nofail 1 2
138148
```
139149

140150
When you're done editing the file, save and close the editor.
141151

152+
Alternatively, you can run the following command to add the disk to the `/etc/fstab` file:
153+
154+
```bash
155+
echo "UUID=33333333-3b3b-3c3c-3d3d-3e3e3e3e3e3e /datadrive xfs defaults,nofail 1 2" >> /etc/fstab
156+
```
157+
142158
> [!NOTE]
143159
> 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.
144160
>
@@ -152,9 +168,9 @@ Some Linux kernels support TRIM/UNMAP operations to discard unused blocks on the
152168

153169
There are two ways to enable TRIM support in your Linux VM. As usual, consult your distribution for the recommended approach:
154170

155-
- Use the `discard` mount option in */etc/fstab*, for example:
171+
- Use the `discard` mount option in `/etc/fstab`, for example:
156172

157-
```bash
173+
```output
158174
UUID=33333333-3b3b-3c3c-3d3d-3e3e3e3e3e3e /datadrive xfs defaults,discard 1 2
159175
```
160176
@@ -163,7 +179,7 @@ There are two ways to enable TRIM support in your Linux VM. As usual, consult yo
163179
# [Ubuntu](#tab/ubuntu)
164180
165181
```bash
166-
sudo apt-get install util-linux
182+
sudo apt install util-linux
167183
sudo fstrim /datadrive
168184
```
169185

@@ -174,9 +190,10 @@ sudo yum install util-linux
174190
sudo fstrim /datadrive
175191
```
176192

177-
# [SUSE](#tab/suse)
193+
# [SLES](#tab/suse)
178194

179195
```bash
196+
sudo zypper in util-linux
180197
sudo fstrim /datadrive
181198
```
182199
---

0 commit comments

Comments
 (0)