Total Pageviews

Saturday 14 October 2017

Format a Volume as XFS in Debian and Ubuntu


To format a drive with the XFS file system make sure xfsprogs is installed, if not you can install xfsprogs from the repositories with the help of apt-get.
root@ubuntu:~# apt-get install xfsprogs
Before you start partitioning and formatting drives make sure you have the right drive. We can list all available drives in the system with the help of the ls command.
root@ubuntu:~# 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@ubuntu:~# 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@ubuntu:~# mkfs.xfs -L media /dev/sdc1
Create a mount point.
root@ubuntu:/dev# mkdir /mnt/dat1
Mount the drive.
root@ubuntu:~# mount -t xfs /dev/sdc1 /mnt/dat1
Let’s check the newly mounted volume, visible at the bottom.
root@ubuntu:/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@ubuntu:# 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

Conclusion

XFS is a good file system for those of us working with large files. If you have any questions leave a comment below.
from http://linhost.info/2012/08/format-a-volume-as-xfs-in-debian-and-ubuntu/

No comments:

Post a Comment