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
In MongoDB it is suggested to turn
To run off
Add
Yours may be a little bit different. Now reboot your server using
Now you can check it by
In the next post we test this using
#mongodb #mongo #noatime #atime #xfs #linux #fstab #mount
atime
to off. atime
is set by Linux
on each file accessed by applications. It is reported repeatedly that turning it off will improve disk performance on that partition.To run off
atime
you need to set noatime
on the partition you are placing mongoDB database files. Open /etc/fstab
and look for your desired partition (mine is `/var`):/dev/mapper/mongo--vg-var /var xfs defaults 0 2
Add
noatime
after defaults
:/dev/mapper/mongo--vg-var /var xfs defaults,noatime 0 2
Yours may be a little bit different. Now reboot your server using
reboot --reboot
. Now you can check it by
mount -l
whether noatime
is set or not:/dev/mapper/mongo--vg-var on /var type xfs (rw,noatime,attr2,inode64,logbsize=256k,sunit=512,swidth=1024,noquota)
In the next post we test this using
touch
command in Linux
.#mongodb #mongo #noatime #atime #xfs #linux #fstab #mount