Skip to content

Commit f60a320

Browse files
authored
Added file system creation to parted method
The file system has to be created after the partitioning is created using `parted`. After the `parted` command, there is no file system: ```bash $ sudo parted /dev/sdc --script mklabel gpt mkpart xfspart xfs 0% 100% $ sudo parted /dev/sdc print Model: Msft Virtual Disk (scsi) Disk /dev/sdc: 68.7GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 1049kB 68.7GB 68.7GB xfspart ``` Then a partition is created: ```bash $ sudo mkfs.xfs /dev/sdc1 meta-data=/dev/sdc1 isize=512 agcount=4, agsize=4194176 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0, sparse=0 data = bsize=4096 blocks=16776704, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=1 log =internal log bsize=4096 blocks=8191, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 $ sudo parted /dev/sdc print Model: Msft Virtual Disk (scsi) Disk /dev/sdc: 68.7GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 1049kB 68.7GB 68.7GB xfs xfspart ```
1 parent 917cf5e commit f60a320

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ Writing superblocks and filesystem accounting information: done
174174
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.
175175
```bash
176176
sudo parted /dev/sdc --script mklabel gpt mkpart xfspart xfs 0% 100%
177+
sudo mkfs.xfs /dev/sdc1
177178
partprobe /dev/sdc1
178179
```
179180
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.

0 commit comments

Comments
 (0)