Skip to content

Commit 7ecc62d

Browse files
authored
Merge pull request #96682 from arvindshmicrosoft/master
Include steps on using parted instead of fdisk
2 parents fb8e3a8 + 2db6737 commit 7ecc62d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

articles/virtual-machines/linux/attach-disk-portal.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,15 @@ Writing inode tables: done
180180
Creating journal (32768 blocks): done
181181
Writing superblocks and filesystem accounting information: done
182182
```
183+
184+
#### Alternate method using parted
185+
The fdisk utility needs interactive input and hence is not ideal for use within automation scripts. However, the [parted](https://www.gnu.org/software/parted/) utility can be scripted and hence lends itself better in automation scenarios. The parted utility can be used to partition and to format a data disk. For the walkthrough below, we use a new data disk /dev/sdc and format it using the [XFS](https://xfs.wiki.kernel.org/) filesystem.
186+
```bash
187+
sudo parted /dev/sdc --script mklabel gpt mkpart xfspart xfs 0% 100%
188+
partprobe /dev/sdc1
189+
```
190+
As seen above, we use the [partprobe](https://linux.die.net/man/8/partprobe) utility to make sure the kernel is immediately aware of the new partition and filesystem. Failure to use partprobe can cause the blkid or lslbk commands to not return the UUID for the new filesystem immediately.
191+
183192
### Mount the disk
184193
Create a directory to mount the file system using `mkdir`. The following example creates a directory at */datadrive*:
185194

0 commit comments

Comments
 (0)