OpenSUSE Linux Rants

OpenSUSE Linux Tips, tricks, how-tos, opinions, and news

My Resume  -  My LinkedIn Profile

April 3, 2009

Linux Commands to Create NTFS Filesystem on USB Stick

by @ 9:26 am. Filed under bash, command-line, How-To, Linux tips

First, the stick should be in, but not mounted. If it is mounted, find the partition represented by your usb stick, as such:

[0959][scott@laptop:~]$ mount
/dev/sda2 on / type ext3 (rw,acl,user_xattr)
/proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
debugfs on /sys/kernel/debug type debugfs (rw)
udev on /dev type tmpfs (rw)
devpts on /dev/pts type devpts (rw,mode=0620,gid=5)
/dev/sda1 on /windows/C type fuseblk (rw,allow_other,blksize=4096)
fusectl on /sys/fs/fuse/connections type fusectl (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
gvfs-fuse-daemon on /home/scott/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,user=scott)
/dev/sdc1 on /media/disk-1 type vfat (rw,nosuid,nodev,shortname=winnt,uid=1000)
/dev/sdb1 on /media/disk-2 type fuseblk (rw,nosuid,nodev,allow_other,default_permissions,blksize=1024)

It will likely be a /dev/sdxx type device. In this case, the one I’m looking for is sdb1.

We need to unmount it as root (‘su’):

laptop:/home/scott # umount /dev/sdb1
laptop:/home/scott #

Now, fdisk the usb stick, and not the partition. In other words, leave off the trailing digit:

laptop:/home/scott # fdisk /dev/sdb

Command (m for help):

Press ‘p’ to view the partitions on the drive. Delete all partitions. Create a new one with ‘n’. It will be a primary partition, and it will be partition 1. Now, we need to set the filesystem type. Press ‘t’, and then if you’d like to see all the filesystem types, press ‘L’, but I’ll just tell you that NTFS is 7. Press ‘7’, and then ‘w’ to write the partition table, and exit:

Command (m for help): p

Disk /dev/sdb: 1027 MB, 1027604480 bytes
64 heads, 32 sectors/track, 980 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Disk identifier: 0x610fbfb2

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1         980     1003504    c  W95 FAT32 (LBA)

Command (m for help): d
Selected partition 1

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
Partition number (1-4): 1
First cylinder (1-980, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-980, default 980):
Using default value 980

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 7
Changed system type of partition 1 to 7 (HPFS/NTFS)

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

Calling ioctl() to re-read partition table.
Syncing disks.
laptop:/home/scott #

Now, we need to actually format the new partition. Include the partition number at the end. It should be 1. You will do this as root (‘su’), like so:

laptop:/home/scott # mkntfs /dev/sdb1
Cluster size has been automatically set to 1024 bytes.
Initializing device with zeroes: 100% - Done.
Creating NTFS volume structures.
mkntfs completed successfully. Have a nice day.
laptop:/home/scott #

K, well, there you are. Mount it up any way you see fit, and you are all set.

OpenSUSE Linux Rants
Official OpenSUSE Linux Site

internal links:


SUSE Resources

search blog:


April 2009
« Mar   May »

57 queries. 0.182 seconds