You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Once connected to your VM, you need to find the disk. In this example, we are using `lsblk` to list the disks.
58
+
Once you connect to your VM, find the disk. In this example, we're using `lsblk` to list the disks.
59
59
60
60
```bash
61
61
lsblk -o NAME,HCTL,SIZE,MOUNTPOINT | grep -i "sd"
@@ -73,19 +73,19 @@ sdb 1:0:1:0 14G
73
73
sdc 3:0:0:0 50G
74
74
```
75
75
76
-
Here, `sdc` is the disk that we want, because it is 50G. If you add multiple disks, and aren't sure which disk it is 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.
77
77
78
78
79
79
### Format the disk
80
80
81
-
Format the disk with `parted`, if the disk size is 2 tebibytes (TiB) or larger then you must use GPT partitioning, if it is under 2TiB, then you can use either MBR or GPT partitioning.
81
+
Format the disk with `parted`, if the disk size is two tebibytes (TiB) or larger then you must use GPT partitioning, if it is under 2TiB, then you can use either MBR or GPT partitioning.
82
82
83
83
> [!NOTE]
84
84
> It is recommended that you use the latest version `parted` that is available for your distro.
85
85
> If the disk size is 2 tebibytes (TiB) or larger, you must use GPT partitioning. If disk size is under 2 TiB, then you can use either MBR or GPT partitioning.
86
86
87
87
88
-
The following example uses `parted` on `/dev/sdc`, which is where the first data disk will typically be on most VMs. Replace `sdc` with the correct option for your disk. We are also formatting it using the [XFS](https://xfs.wiki.kernel.org/) filesystem.
88
+
The following example uses `parted` on `/dev/sdc`, which is where the first data disk will typically be on most VMs. Replace `sdc` with the correct option for your disk. We're also formatting it using the [XFS](https://xfs.wiki.kernel.org/) filesystem.
@@ -112,7 +112,7 @@ sudo mount /dev/sdc1 /datadrive
112
112
113
113
### Persist the mount
114
114
115
-
To ensure that the drive is remounted automatically after a reboot, it must be added to the */etc/fstab* file. It is 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:
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:
116
116
117
117
```bash
118
118
sudo blkid
@@ -131,19 +131,13 @@ The output looks similar to the following example:
131
131
> [!NOTE]
132
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.
133
133
134
-
Next, open the */etc/fstab* file in a text editor as follows:
135
-
136
-
```bash
137
-
sudo nano /etc/fstab
138
-
```
139
-
140
-
In this example, use the UUID value for the `/dev/sdc1` device that was created in the previous steps, and the mountpoint of `/datadrive`. Add the following line to the end of the `/etc/fstab` file:
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:
In this example, we are using the nano editor, so when you are done editing the file, use `Ctrl+O` to write the file and `Ctrl+X` to exit the editor.
140
+
When you're done editing the file, save and close the editor.
147
141
148
142
> [!NOTE]
149
143
> 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.
@@ -166,19 +160,26 @@ There are two ways to enable TRIM support in your Linux VM. As usual, consult yo
166
160
167
161
- In some cases, the `discard` option may have performance implications. Alternatively, you can run the `fstrim`command manually from the command line, or add it to your crontab to run regularly:
168
162
169
-
**Ubuntu**
163
+
# [Ubuntu](#tab/ubuntu)
170
164
171
-
```bash
172
-
sudo apt-get install util-linux
173
-
sudo fstrim /datadrive
174
-
```
165
+
```bash
166
+
sudo apt-get install util-linux
167
+
sudo fstrim /datadrive
168
+
```
175
169
176
-
**RHEL/CentOS**
170
+
# [RHEL](#tab/rhel)
177
171
178
-
```bash
179
-
sudo yum install util-linux
180
-
sudo fstrim /datadrive
181
-
```
172
+
```bash
173
+
sudo yum install util-linux
174
+
sudo fstrim /datadrive
175
+
```
176
+
177
+
# [SUSE](#tab/suse)
178
+
179
+
```bash
180
+
sudo fstrim /datadrive
181
+
```
182
+
---
182
183
183
184
## Troubleshooting
184
185
@@ -187,4 +188,4 @@ There are two ways to enable TRIM support in your Linux VM. As usual, consult yo
187
188
## Next steps
188
189
189
190
* To ensure your Linux VM is configured correctly, review the [Optimize your Linux machine performance](/previous-versions/azure/virtual-machines/linux/optimization) recommendations.
190
-
* Expand your storage capacity by adding additional disks and [configure RAID](/previous-versions/azure/virtual-machines/linux/configure-raid) foradditional performance.
191
+
* Expand your storage capacity by adding more disks and [configure RAID](/previous-versions/azure/virtual-machines/linux/configure-raid) forextra performance.
Once connected to your VM, you need to find the disk. In this example, we are using `lsblk` to list the disks.
60
+
Once connected to your VM, you need to find the disk. In this example, we're using `lsblk` to list the disks.
61
61
62
62
```bash
63
63
lsblk -o NAME,HCTL,SIZE,MOUNTPOINT | grep -i "sd"
@@ -75,15 +75,15 @@ sdb 1:0:1:0 14G
75
75
sdc 3:0:0:0 4G
76
76
```
77
77
78
-
In this example, the disk that I added is`sdc`. It is a LUN 0 and is 4GB.
78
+
In this example, the disk that was added was`sdc`. It's a LUN 0 and is 4GB.
79
79
80
-
For a more complex example, here is what multiple data disks look like in the portal:
80
+
For a more complex example, here's what multiple data disks look like in the portal:
81
81
82
82
:::image type="content" source="./media/attach-disk-portal/find-disk.png" alt-text="Screenshot of multiple disks shown in the portal.":::
83
83
84
84
In the image, you can see that there are 3 data disks: 4 GB on LUN 0, 16GB at LUN 1, and 32G at LUN 2.
85
85
86
-
Here is what that might look like using `lsblk`:
86
+
Here's what that might look like using `lsblk`:
87
87
88
88
```bash
89
89
sda 0:0:0:0 30G
@@ -103,16 +103,16 @@ From the output of `lsblk` you can see that the 4GB disk at LUN 0 is `sdc`, the
103
103
104
104
> [!IMPORTANT]
105
105
> If you are using an existing disk that contains data, skip to [mounting the disk](#mount-the-disk).
106
-
> The following instuctions will delete data on the disk.
106
+
> The following instructions will delete data on the disk.
107
107
108
-
If you are attaching a new disk, you need to partition the disk.
108
+
If you're attaching a new disk, you need to partition the disk.
109
109
110
110
The `parted` utility can be used to partition and to format a data disk.
111
-
-It is recommended that you use the latest version `parted` that is available for your distro.
111
+
-Use the latest version `parted` that is available for your distro.
112
112
- If the disk size is 2 tebibytes (TiB) or larger, you must use GPT partitioning. If disk size is under 2 TiB, then you can use either MBR or GPT partitioning.
113
113
114
114
115
-
The following example uses `parted` on `/dev/sdc`, which is where the first data disk will typically be on most VMs. Replace `sdc` with the correct option for your disk. We are also formatting it using the [XFS](https://xfs.wiki.kernel.org/) filesystem.
115
+
The following example uses `parted` on `/dev/sdc`, which is where the first data disk will typically be on most VMs. Replace `sdc` with the correct option for your disk. We're also formatting it using the [XFS](https://xfs.wiki.kernel.org/) filesystem.
@@ -136,7 +136,7 @@ Use `mount` to then mount the filesystem. The following example mounts the */dev
136
136
sudo mount /dev/sdc1 /datadrive
137
137
```
138
138
139
-
To ensure that the drive is remounted automatically after a reboot, it must be added to the */etc/fstab* file. It is 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:
139
+
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:
140
140
141
141
```bash
142
142
sudo blkid
@@ -153,21 +153,15 @@ The output looks similar to the following example:
153
153
```
154
154
155
155
> [!NOTE]
156
-
> 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.
156
+
> 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. You should create a backup of the **/etc/fstab** file is created before editing.
157
157
158
-
Next, open the */etc/fstab* file in a text editor as follows:
159
-
160
-
```bash
161
-
sudo nano /etc/fstab
162
-
```
163
-
164
-
In this example, use the UUID value for the `/dev/sdc1` device that was created in the previous steps, and the mountpoint of `/datadrive`. Add the following line to the end of the `/etc/fstab` file:
158
+
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:
We used the nano editor, so when you are done editing the file, use `Ctrl+O` to write the file and `Ctrl+X` to exit the editor.
164
+
When you're done editing the file, save and close the editor.
171
165
172
166
> [!NOTE]
173
167
> 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.
@@ -200,7 +194,7 @@ You can see that `sdc` is now mounted at `/datadrive`.
200
194
201
195
### TRIM/UNMAP support for Linux in Azure
202
196
203
-
Some Linux kernels support TRIM/UNMAP operations to discard unused blocks on the disk. This feature is primarily useful in standard storage to inform Azure that deleted pages are no longer valid and can be discarded, and can save money if you create large files and then delete them.
197
+
Some Linux kernels support TRIM/UNMAP operations to discard unused blocks on the disk. This feature is primarily useful to inform Azure that deleted pages are no longer valid and can be discarded. This feature can save money on disks that are billed based on the amount of consumed storage, such as unmanaged standard disks and disk snapshots.
204
198
205
199
There are two ways to enable TRIM support in your Linux VM. As usual, consult your distribution for the recommended approach:
206
200
@@ -211,19 +205,26 @@ There are two ways to enable TRIM support in your Linux VM. As usual, consult yo
211
205
```
212
206
* In some cases, the `discard` option may have performance implications. Alternatively, you can run the `fstrim`command manually from the command line, or add it to your crontab to run regularly:
Copy file name to clipboardExpand all lines: articles/virtual-machines/linux/detach-disk.md
+5-9Lines changed: 5 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ author: roygara
5
5
ms.service: storage
6
6
ms.collection: linux
7
7
ms.topic: how-to
8
-
ms.date: 06/08/2022
8
+
ms.date: 01/09/2023
9
9
ms.author: rogarana
10
10
ms.subservice: disks
11
11
ms.custom: devx-track-azurecli
@@ -69,19 +69,15 @@ Edit the */etc/fstab* file to remove references to the disk.
69
69
> [!NOTE]
70
70
> 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.
71
71
72
-
Open the */etc/fstab* file in a text editor as follows:
73
-
74
-
```bash
75
-
sudo vi /etc/fstab
76
-
```
77
-
78
-
In this example, the following line needs to be deleted from the */etc/fstab* file:
72
+
Open the **/etc/fstab** file in a text editor and remove the line containing the UUID of your disk. Using the example values in this article, the line would look like the following:
0 commit comments