Storage

Format NTFS partition on external hard drive from CentOS / RHEL linux

linux ntfs After writing about mounting NTFS filesystems on CentOS / RHEL, I wanted to share another technique: Linux can format a hard disk with an NTFS filesystem without relying on Windows. The procedure is straightforward. Let us get started with formatting NTFS on Linux. This article uses CentOS 6 or RHEL 6 to explain the process. Other CentOS or RHEL versions can follow these steps without much difficulty. On other Linux distributions, look for a package named ntfsprogs. Formatting an NTFS filesystem on CentOS 6 or RHEL 6 Linux Assume we already have CentOS Linux on a SATA/SAS/SCSI hard disk, and will add a USB external hard drive containing one partition. First, if you do not have the epel repository, install it. The example below installs epel for RHEL 6 and CentOS 6. For other CentOS and RHEL versions, find the download URL at RPM repository for RHEL and CentOS.

[root@ezylinux ~]# rpm -ivh http://download.fedora.redhat.com/pub/epel/6/x86_64/epel-release-6-5.noarch.rpm
Retrieving http://download.fedora.redhat.com/pub/epel/6/x86_64/epel-release-6-5.noarch.rpm
warning: /var/tmp/rpm-tmp.GCQQ4D: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Preparing...                #################################### [100%]
   1:epel-release           #################################### [100%]

Next, install ntfsprogs with yum as shown below.

[root@ezylinux ~]# yum install ntfsprogs
Loaded plugins: refresh-packagekit, rhnplugin
This system is not registered with RHN.
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package ntfsprogs.x86_64 2:2011.4.12-3.el6 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

=======================================================================
 Package        Arch             Version        Repository       Size
=======================================================================
Installing:
 ntfsprogs     x86_64       2:2011.4.12-3.el6     epel          225 k

Transaction Summary
=======================================================================
Install       1 Package(s)
Upgrade       0 Package(s)

Total download size: 225 k
Installed size: 728 k
Is this ok [y/N]: y
ntfsprogs-2011.4.12-3.el6.x86_64.rpm                 | 225 kB     00:01
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : ntfsprogs-2011.4.12-3.el6.x86_64                 1/1

Installed:
  ntfsprogs.x86_64 2:2011.4.12-3.el6

Complete!

After installing ntfsprogs, inspect the partitions on the disk you intend to format as NTFS to avoid mistakes. Use fdisk as shown below. Under the assumptions above, there are two disks: sda and sdb. sda is the system disk, and sdb is the newly added disk.

[root@ezylinux ~]# fdisk -l 


Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00067d44

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1           7       51200   83  Linux
/dev/sda2               7         517     4096000   83  Linux
/dev/sda3             517         774     2064384   82  Linux swap / Solaris
/dev/sda4             774        1306     4273152    5  Extended
/dev/sda5             774        1306     4272128   83  Linux

Disk /dev/sdb: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x6c3f5e75

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         652     5237158+   7  HPFS/NTFS

The output shows sdb1, the first partition on sdb, which is the newly added hard disk. Format sdb1 as NTFS using mkfs.ntfs, as shown below.

[root@ezylinux ~]# mkfs.ntfs /dev/sdb1
Cluster size has been automatically set to 4096 bytes.
Initializing device with zeroes: 100% - Done.
Creating NTFS volume structures.
mkntfs completed successfully. Have a nice day.

To mount it for use, run mount.ntfs-3g. See Mount NTFS filesystems on CentOS / RHEL Linux for more details.

EOF.← Back to articles