My favourite tool to create disk partitions on Linux is c[fg]disk. cfdisk used to create MBR based partition, and cgdisk is for GPT one.

Today, I want to learn to use another tool called GNU Parted.

After plugging an external disk, we can use udiskctl command to identify the disk device.

# udisksctl status
MODEL                     REVISION  SERIAL               DEVICE
Samsung SSD 850 EVO 250GB EMT01B6Q  S21MNXAG919308T      sda
ST2000DM001-1ER164        HP51      Z4Z46TMA             sdb
ST2000DM001-1ER164        HP51      Z4Z46W3E             sdc
Samsung SSD 850 EVO 250GB EMT01B6Q  S21MNXAG919312Y      sdd
Samsung SSD 840 EVO 250G  0309      533144424E4541443837343335324120 sde

The last Samsung SSD 840 (/dev/sde) is the one that I’m going to work with.

Let’s create a primary partition, (to be formatted as) xfs file system, and use the full 250GB space. With parted, though we specify the file-system, it doesn’t format the partition.

# parted /dev/sde
GNU Parted 3.3
Using /dev/sde
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel
New disk label type? gpt
Warning: The existing disk label on /dev/sde will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? Yes
(parted) mkpart primary xfs 0% 100%
(parted) quit

Let’s check the partition layout of the /dev/sde:

# parted /dev/sde print
Model: Samsung SSD 840 EVO 250G (scsi)
Disk /dev/sde: 250GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start   End    Size   File system  Name     Flags
 1      1049kB  250GB  250GB               primary

My initial plan was to create a (gpt) partition, and that’s done. However, I want to format this newly created partition and label it as isodepot., (I’m going to used it store all iso files.)

# mkfs.xfs /dev/sde1 
meta-data=/dev/sde1              isize=512    agcount=4, agsize=15262336 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=1, rmapbt=0
         =                       reflink=1
data     =                       bsize=4096   blocks=61049344, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
log      =internal log           bsize=4096   blocks=29809, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none

A while back, I created a post on how to label an XFS formatted partition, which has proven to very helpful to me personally.

Before setting the label on the /dev/sde1 partition, let’s check what the current label is.

# xfs_admin -l /dev/sde1
label = ""

Use xfs_admin -L LABEL command to set new label on the XFS partition.

# xfs_admin -L isodepot /dev/sde1
writing all SBs
new label = "isodepot"
[root@watamem ~]# xfs_admin -l /dev/sde1
label = "isodepot"

Well, hope you learn a few new things today.