LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   partiton a USB pendrive.. (https://www.linuxquestions.org/questions/linux-software-2/partiton-a-usb-pendrive-639425/)

Dandy1 05-02-2008 02:01 PM

partiton a USB pendrive..
 
Can you partiton a USB pendrive from linux or windows..? & what is the syntax to do it..??

Tanks, :)Dandy1

Okie 05-02-2008 03:16 PM

i use cfdisk to partition usb memory sticks, NEVER use a disk tool to partition or format anything that is mounted always umount it first!, if you want to share the data with windows PCs then FAT32 (vfat) (0B in cfdisk) will be necessary, but if you intend to only use it with linux then ext2 will do fine (journaling not necessary)...

phr33k 05-02-2008 03:38 PM

Well, for a USB pendrive, a standard FAT format is perfect for those sizes of drives. The only time that would change is if your drive is larger than 4GB.

exvor 05-02-2008 04:02 PM

You can do this in Linux just fine and mount the partition like normal but in windows it will only ever see the first partition on the drive. The windows partition software will also not let you create multiple ones.

The reason is windows classifies it as a removable device or flash media.

newtovanilla 05-02-2008 09:14 PM

"& what is the syntax to do it..??"

I would like to know how to do this too. Does someone know the command syntax to format with Linux native for a 1GB and 4GB USB pen drive? I an new to Linux and I have messed up so much already trying to get things to work.

newtovanilla 05-02-2008 09:16 PM

I found this on the web:

http://sathyasays.com/2007/06/13/for...sing-terminal/

Quote:

Insert your USB pen drive. Let it get detected and mounted. Open Terminal. Type The Following commands
1. dmesg |tail –> here the ‘|’ key is the pipe, ie, the key before the backspace key(the upper one, so press shift)
You’ll get something like

sathya@shaman:~$ dmesg |tail
[ 9921.681164] sda: Write Protect is off
[ 9921.681174] sda: Mode Sense: 23 00 00 00
[ 9921.681178] sda: assuming drive cache: write through
[ 9921.709138] SCSI device sda: 4030464 512-byte hdwr sectors (2064 MB)
[ 9921.720951] sda: Write Protect is off
[ 9921.720963] sda: Mode Sense: 23 00 00 00
[ 9921.720967] sda: assuming drive cache: write through
[ 9921.721225] sda:
[ 9921.727896] sd 0:0:0:0: Attached scsi removable disk sda
[ 9921.744187] sd 0:0:0:0: Attached scsi generic sg0 type 0
Note the terms in bold. In your system it will be different, maybe sdb or something. Whatever it may be, make sure to substitute it in the commands below, else your hard disk may get formatted.

2. Unmount your pen drive by using
sudo umount /dev/sda (In your case, please substitute sda with the appropriate device, listed above.

3. use the mkfs.vfat command to format to FAT32 filesystem, or mkfs.ext3 to format to ext3 filesystem
sudo mkfs.vfat -n ‘Label’ -I /dev/sda Replace Label with the name you want the pen drive to have.

4. That’s it! When done formatting, you’ll be returned to the prompt
sathya@shaman:~$ mkfs.vfat -n ’sathya’ -I /dev/sda
mkfs.vfat 2.11 (12 Mar 2005)
sathya@shaman:~$

Remove and insert the pen drive to have mounted again!

exvor 05-06-2008 04:30 PM

Quote:

Originally Posted by newtovanilla (Post 3140628)
"& what is the syntax to do it..??"

I would like to know how to do this too. Does someone know the command syntax to format with Linux native for a 1GB and 4GB USB pen drive? I an new to Linux and I have messed up so much already trying to get things to work.

It depends on the file system you wish to use. Normally as long as you have everything built into the kernel that you need ( most distros do ) you will get a new device aka /dev/sda unless of course you are using a serial ata drive then /dev/sda would be the internal drive.


lets break down that shal we.

/dev ( this is where all our devices should live )
sda ( hmmm ok s in there stands for serial and d stands for drive )
( the last letter indicates the number of the disks in the system)

so /dev/sdc would indicate this is the 3rd serial device in the system.

now we cannot mount a whole disk but rather need to mount a partition well thats easy because we just add the number of the partition we want to mount on the disk thus /dev/sda1 is the first partition on the first serial device on the system.


if you create two partitions on a thumb drive the commands would be easy enough.

say the pen drive is /dev/sda

use cfdisk to create the 2 partitions ( if you dont know how google it )
so we should have /dev/sda1 and /dev/sda2

format using mkfs.vfat like this

mkfs.vfat /dev/sda1
mkfs.vfat /dev/sda2


after that you can mount them

mount /dev/sda1 /media/usbdrive1
mount /dev/sda2 /media/usbdrive2

of course if you want to mount it somewhere other then /media/usbdrive then you can i just used that as an example. I hope this answers any questions you have.


All times are GMT -5. The time now is 10:33 PM.