Tech C**P
15 subscribers
161 photos
9 videos
59 files
304 links
مدرس و برنامه نویس پایتون و لینوکس @alirezastack
Download Telegram
Format a volume as XFS in Debian


First of all install xfsprogs:

apt-get install xfsprogs


Make sure your formatting a right drive! Use ls to list drives:

root@debian:~# ls /dev/sd*
/dev/sda /dev/sda1 /dev/sda2 /dev/sda5 /dev/sdb /dev/sdb1 /dev/sdc

In this installation I will format the drive /sdc, I know this because this is a blank drive with no partitions.

Now we partition the drive with the help of fdisk. fdisk can be scary if you have never used it before, in order to partition the drive use the commands below. Note: this will create one big partition, use the values inside the brackets [] as a guide.

root@debian:~# fdisk /dev/sdb

Command (m for help): [n]
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): [p]
Partition number (1-4, default 1): [1]
First sector (2048-335544319, default 2048): [press Enter]
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-335544319, default 335544319): [press Enter]
Using default value 335544319

Command (m for help): [w]
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.


Because we installed xfsprogs we can make use of mkfs.xfs to format the partition we created in the step above. -L will label the drive as media:

root@debian:~# mkfs.xfs -L media /dev/sdc1


Create a mount point:

root@debian:/dev# mkdir /mnt/dat1


Mount the drive:

root@debian:~# mount -t xfs /dev/sdc1 /mnt/dat1


Let’s check the newly mounted volume, visible at the bottom:

root@debian:/dev# df -h

Filesystem Size Used Avail Use% Mounted on
/dev/sda1 50G 1.9G 46G 4% /
udev 80M 4.0K 80M 1% /dev
tmpfs 36M 272K 35M 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 88M 0 88M 0% /run/shm
/dev/sdc1 160G 33M 160G 1% /mnt/dat1


To permanently mount the new volume every time the system boots you will need to edit and add a new entry to /etc/ fstab. You can use the echo command to easily add the new entry:

root@debian:# echo '/dev/sdc1 /mnt/dat1 xfs defaults 0 0' >> /etc/fstab


Or manually add the entry below to fstab with the text editor of your choice:

/dev/sdc1 /mnt/dat1 xfs defaults 0 0

XFS is a good file system for those of us working with large files. This is a recommended filesystem for those working with MongoDB wiredTiger too.

#linux #filesystem #xfs #fdisk #mount #df #fstab #xfsprogs #mkfs_xfs