LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   format memory stick (https://www.linuxquestions.org/questions/linux-newbie-8/format-memory-stick-619520/)

Tapasi 02-08-2008 01:02 AM

format memory stick
 
Dear All,
I want to format memory stick(pen drive).
So, what is the command ?
Suggestions needed.
Thanks in advance.
Regards.
Tapasi

ZAMO 02-08-2008 01:49 AM

Once you plugged your pen drive, make sure it is mounted or not.

use "fdisk -l" which will show the list of disk in your linux box.
Your USB may be there as a " sda/sdb/sdc/sdd" (either one). You can verify yourself with the size in MB .

The you need to mount it to a directory.
mkdir /ZAMO
mount /dev/sda1 /ZAMO (am considering my USB as sda)
cd ZAMO
ls
.....Verify your data is here. If ok continue
cd ..
mkdosfs /dev/sda1 (if you want a dos FS)
mke2fs -j /dev/sda1 (if you want ext3 FS)

All the best. This is for Fedora or redhat.

Matir 02-08-2008 07:26 AM

Do not mount the disk before formatting. Especially, do not have the disk mounted during the formatting.

Also, keep in mind that on newer kernels, many devices appear on /dev/sd*, so double-check which device you are formatting -- it would be bad to do that to your hard drive.

onebuck 02-08-2008 07:34 AM

Hi,

Quote:

Originally Posted by Tapasi (Post 3049897)
Dear All,
I want to format memory stick(pen drive).
So, what is the command ?
Suggestions needed.
Thanks in advance.
Regards.
Tapasi

You don't mount the flash to format/partition it.

You first would partition the device using 'fdisk /dev/sdx' (where x is the device a,b,c,d). Partition as you desire, make sure to select the partition type for the device partitions.

You can then run 'mkfs ' on the device (note the underlined portion);
Quote:

excerpt from 'man mkfs';
MKFS(8)

NAME
mkfs - build a Linux file system

SYNOPSIS
mkfs [ -V ] [ -t fstype ] [ fs-options ] filesys [ blocks ]

DESCRIPTION
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 sys-
tem. 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.
You should 'man commands' when in question.


All times are GMT -5. The time now is 01:50 PM.