usb sticks linux

Notes on formatting USB sticks on Linux.

Connect the USB stick and type use the following command to figure which on which /dev/sd* is it.
# dmesg |grep -i scsi -A 2


To list all USB devices
# lsusb


If you are not seeing the USB stick see if the usb_storage module is loaded
# lsmod |grep usb_storage 


If the usb_storage is not loaded, load it
# modprobe usb_storage


Usually a USB drive automounts, check if is with df eg:
# df -h


If the USB stick is mounted, unmout it
# umount /dev/sdc


Format the USB stick with NTFS
# fdisk /dev/sdc
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-30532, default 1): 
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-30532, default 30532): 30532

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.

# mkfs.ntfs -L 'stick' /dev/sdc1 -f -v -I
Cluster size has been automatically set to 4096 bytes.
Creating NTFS volume structures.
Creating root directory (mft record 5)
Creating $MFT (mft record 0)
Creating $MFTMirr (mft record 1)
Creating $LogFile (mft record 2)
Creating $AttrDef (mft record 4)
Creating $Bitmap (mft record 6)
Creating $Boot (mft record 7)
Creating backup boot sector.
Creating $Volume (mft record 3)
Creating $BadClus (mft record 8)
Creating $Secure (mft record 9)
Creating $UpCase (mft record 0xa)
Creating $Extend (mft record 11)
Creating system file (mft record 0xc)
Creating system file (mft record 0xd)
Creating system file (mft record 0xe)
Creating system file (mft record 0xf)
Creating $Quota (mft record 24)
Creating $ObjId (mft record 25)
Creating $Reparse (mft record 26)
Syncing root directory index record.
Syncing $Bitmap.
Syncing $MFT.
Updating $MFTMirr.
Syncing device.
mkntfs completed successfully. Have a nice day.


Format it with FAT32
# mkdosfs -n 'stickaki' -F 32 -I /dev/sdc
stickaki is the name-label of the USB stick

You may want to format your USB stick with other file systems
# mkfs.
mkfs.bfs      mkfs.cramfs   mkfs.ext2     mkfs.ext3     mkfs.ext4     mkfs.ext4dev  mkfs.minix    mkfs.msdos    mkfs.ntfs     mkfs.vfat


Mount the USB stick
# mkdir /mnt/blah
# mount /dev/sdc /mnt/blah




http://alog.ipduh.com/2013/02/usb-sticks-linux.html