LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 05-08-2009, 08:56 AM   #1
topheraholic
Member
 
Registered: Aug 2008
Location: shanghai
Distribution: ubuntu
Posts: 128

Rep: Reputation: 15
how to format a usb device?


what is the command of formating a usb device? thanks
 
Old 05-08-2009, 09:13 AM   #2
linus72
Guru
 
Registered: Jan 2009
Location: Gordonsville-AKA Mayberry-Virginia
Distribution: PocketWriter/MinimalX
Posts: 5,057

Rep: Reputation: 328Reputation: 328Reputation: 328Reputation: 328
That would matter what filesystem you want on the usb-fat32.ext2, etc

I use Gparted to partition/format the USB, or cfdisk/fdisk,etc

The terminal commands are found here-

( http://linux.die.net/man/8/mkfs )

check the links at "see also"
 
Old 05-08-2009, 10:57 PM   #3
Moqtada
LQ Newbie
 
Registered: May 2009
Posts: 3

Rep: Reputation: 0
Hi, I used a windows program called Unetbootin.

It was extremely easy to use, it will grab almost any distro off the net for you, or you can choose to have it install an .iso.

Very handy tool, and not complicated. Get it here:

http://unetbootin.sourceforge.net/
 
Old 05-08-2009, 11:42 PM   #4
vibinlakshman
Member
 
Registered: Dec 2008
Location: Kerala, India
Distribution: Ubuntu 11.10
Posts: 334

Rep: Reputation: 33
Cool

Quote:
Originally Posted by Moqtada View Post
Hi, I used a windows program called Unetbootin.

It was extremely easy to use, it will grab almost any distro off the net for you, or you can choose to have it install an .iso.

Very handy tool, and not complicated. Get it here:

http://unetbootin.sourceforge.net/
man mkfs , u will get lot of info
for eg : if u need to format an usb do this

#mkfs.vfat /location_of_ur_usb_ drive

vfat is the fat file sys , u can have ntfs ,ext2/3 in replace if that
 
Old 05-09-2009, 11:15 PM   #5
topheraholic
Member
 
Registered: Aug 2008
Location: shanghai
Distribution: ubuntu
Posts: 128

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by vibinlakshman View Post
man mkfs , u will get lot of info
for eg : if u need to format an usb do this

#mkfs.vfat /location_of_ur_usb_ drive

vfat is the fat file sys , u can have ntfs ,ext2/3 in replace if that
thanks. but when i run it i get this:

jf@jf:~$ mkfs.fat32 /x-nautilus-desktop:///4.2%20GB%20Media.volume
bash: mkfs.fat32: command not found

what should i do next?
 
Old 05-10-2009, 07:45 AM   #6
mpiekarski
LQ Newbie
 
Registered: May 2009
Location: Newark, DE
Distribution: Gentoo,ubuntu,rhel
Posts: 25

Rep: Reputation: 16
Hi,

You can use fdisk to see which disk it is. I don't believe you are using the correct disk. You can try the following:

1. Unplug your USB Drive
2. Run 'sudo fdisk -l'

Code:
mpiekarski@doakes:~$ sudo fdisk -l

Disk /dev/sda: 100.0 GB, 100030242816 bytes
255 heads, 63 sectors/track, 12161 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x6a6a6a6a

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        4462    35840983+   7  HPFS/NTFS
/dev/sda2            4463        4525      506047+  83  Linux
/dev/sda3            4526        4775     2008125   82  Linux swap / Solaris
/dev/sda4            4776       12161    59328045   83  Linux
The above is an example output from my laptop.

3. Plug the USB drive:

Code:
mpiekarski@doakes:~$ sudo fdisk -l

Disk /dev/sda: 100.0 GB, 100030242816 bytes
255 heads, 63 sectors/track, 12161 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x6a6a6a6a

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        4462    35840983+   7  HPFS/NTFS
/dev/sda2            4463        4525      506047+  83  Linux
/dev/sda3            4526        4775     2008125   82  Linux swap / Solaris
/dev/sda4            4776       12161    59328045   83  Linux

Disk /dev/sdb: 16.0 GB, 16039018496 bytes
75 heads, 40 sectors/track, 10442 cylinders
Units = cylinders of 3000 * 512 = 1536000 bytes
Disk identifier: 0x3625ddec

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1       10442    15662980   83  Linux
The above is an example after I plugged in a usb drive i had lying around.

If you have automount enabled, you will have to umount . Check what is mount with the following:

Code:
mpiekarski@doakes:~$ sudo mount
/dev/sda4 on / type ext3 (rw,relatime,errors=remount-ro)
tmpfs on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
varrun on /var/run type tmpfs (rw,nosuid,mode=0755)
varlock on /var/lock type tmpfs (rw,noexec,nosuid,nodev,mode=1777)
udev on /dev type tmpfs (rw,mode=0755)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620)
fusectl on /sys/fs/fuse/connections type fusectl (rw)
lrm on /lib/modules/2.6.28-12-generic/volatile type tmpfs (rw,mode=755)
/dev/sda2 on /boot type ext2 (rw,relatime)
securityfs on /sys/kernel/security type securityfs (rw)
gvfs-fuse-daemon on /home/mpiekarski/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,user=mpiekarski)
/dev/sdb1 on /media/disk type ext3 (rw,nosuid,nodev,uhelper=hal)
You can see /dev/sdb1 is mounted on /media/disk. Before formatting, you have to umount. To do so, run the following:

Code:
mpiekarski@doakes:~$ sudo umount /media/disk
Now that its unmounted, you can format as you typically would. To format with the device name "/dev/sdb1"
Code:
 mkfs.vfat -F32 /dev/sdb1
for FAT32 or
Code:
 mkfs /dev/sdb1
for ext2.

------------------------------------
Michael Piekarski
Network Engineer
mpiekarski@hostmysite.com
www.hostmysite.com
 
Old 05-10-2009, 08:16 AM   #7
onebuck
Moderator
 
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: SlackwareŽ
Posts: 11,052
Blog Entries: 1

Rep: Reputation: 1373Reputation: 1373Reputation: 1373Reputation: 1373Reputation: 1373Reputation: 1373Reputation: 1373Reputation: 1373Reputation: 1373Reputation: 1373
Hi,

As stated before, it will depend on the filesystem you want plus if you should need to partition the device. If you need to re-partition or change the partition scheme then you can use 'parted', 'cfdisk' or 'fdisk' to accomplish the task(s).

Quote:
excerpt from 'man mkfs';

mkfs is used to build a Linux file system on a device, usually a hard disk partition. filesys is either the device name (e.g. /dev/hda1, /dev/sdb2) or the mount point (e.g. /, /usr, /home) for the file system. blocks is the number of blocks to be used for the file system.

The exit code returned by mkfs is 0 on success and 1 on failure.

In actuality, mkfs is simply a front-end for the various file system builders (mkfs.fstype) available under Linux. The file system-specific builder is searched for in a number of directories like perhaps /sbin, /sbin/fs, /sbin/fs.d, /etc/fs, /etc (the precise list is defined at compile time but at least contains /sbin and /sbin/fs), and finally in the directories listed in the PATH enviroment variable. Please see the file system-specific builder manual pages for further details
If you decide to use 'mkfs' then I hope that the filesystem you choose is supported by your install.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
USB drive not working properly, read only device? (USB key storage device) Arodef Linux - Hardware 14 01-01-2010 07:32 AM
How to force kernel to use a USB 2.0-compatible device (ehci_hcd) as a USB 1.1 device eze Linux - Hardware 0 05-16-2006 05:24 AM
Failed to open device /dev/usb/ttyUSB0: No such device efm Linux - Newbie 2 04-04-2005 08:46 PM
HP Deskjet (USB) & CUPS & Slackware 9.1: Unable to open USB device "usb:/dev/usb/lp0&qu arnostienen Slackware 2 01-29-2004 03:22 PM
Format a device in Linux? subnet Linux - General 8 09-17-2003 04:40 AM


All times are GMT -5. The time now is 09:51 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration