Formating A Thumb Drive


Recommended Posts

I'm running OpenSUSE 10.1 (love it BTW - check it out if you get a chance).

Anyway, I spent half an hour trying to find a way to format my USB thumb drive in the GUI

(KDE 3.5.1) with no success. Finally figured a way to format in a command line:

# mkdosfs -c -F 16 -n "volume name" /dev/sda1

This worked fine, but there has to be an easier way to do this.

I was wondering how you format a USB drive in whatever distro/Desktop Environment you use.

ty

Link to post
Share on other sites
# mkdosfs -c -F 16 -n "volume name" /dev/sda1

This worked fine, but there has to be an easier way to do this.

that seems pretty darn easy. The cool thing is you can use that command in any distro. You do not even need a gui to do it.

Link to post
Share on other sites
I'm running OpenSUSE 10.1 (love it BTW - check it out if you get a chance).

Anyway, I spent half an hour trying to find a way to format my USB thumb drive in the GUI

(KDE 3.5.1) with no success. Finally figured a way to format in a command line:

# mkdosfs -c -F 16 -n "volume name" /dev/sda1

This worked fine, but there has to be an easier way to do this.

I was wondering how you format a USB drive in whatever distro/Desktop Environment you use.

ty

formating is a admin function so very few gui tools have been made as its too easy to mess up (opps I ment sda not hda.. well there goes root) since most people are used to windows and "drives"

but with that said, qtparted is a gui tool kind of like partition magic I am not sure if it is apart of suse or you may need to install it using yast let me know if its not there and I'll show you how to install it.

gparted is another tool, you need the gtk libs, but if it is in yast it will install what you need. (should be in yast as its an offical gnome project)

Link to post
Share on other sites

Umm, I guess I'll just stick with the command line.

Seems easy enough, and has the least chance of screwing something up.

(I don't like the thought of using partitioning software just to format, if I don't need to)

If there's a general lack of GUI tools for this - that's fine,

Just wanted to see if I was missing something obvious.

Thanks for the info.

Link to post
Share on other sites
Umm, I guess I'll just stick with the command line.

Seems easy enough, and has the least chance of screwing something up.

(I don't like the thought of using partitioning software just to format, if I don't need to)

If there's a general lack of GUI tools for this - that's fine,

Just wanted to see if I was missing something obvious.

Thanks for the info.

I do understand not everyone wants to go to command line, but for us old timers.. we just think why not??

I am not sure about your position on partiitoner as in Windows you go to drive manager which is a partitioner (or maybe you can do it in my computer right click format, but that would be stupid.. sorry you just formated C drive.. windows will try to reboot :)

if you think its a good Ideal to have one , it should be easy to build (a front end to the command you already did) maybe I'll do one in mono or python..

here is one such front end Shanenin (think of it as a project) might be able to fix up for scsi (usb) drives..

http://www.pcbypaul.com/software/linHDD.html

if this is a need, it can be done and then pushed to sources so its added to other distrobutions.. we could even let Novell release it and it will be in YAST..

Edited by iccaros
Link to post
Share on other sites

KFloppy can format a flash drive, you need to manually add the device in the "Floppy Drive" combo box.

It should be possible to add/edit a service menu to add format usb as an option(you can add services in control center > storage media). My plan was to add a format service with

sudo /usr/sbin/mkfs.vfat %u

the problem I am having getting this to work is the specifying of the device. What I mean by this is, the default command when adding a service is konqeror %u (%u repressenting a single URL more variables here) this seems to only specify the mount point, not device file. Anyone have an idea to make this work if even possible?

Also I was looking at KFloppy's source, and there is a TODO comment for user specified devices. Maybe someone tha knows c++ would want to look at it.

EDIT:

I added a couple lines in kfloppy.cpp to add the device passed as an arg is input in the combo box. Now if kfloppy %u as a command for the service it works (shows correct device) but wont format (must be root or in disk group to write to the device (I believe this is the problem)). As a work around I can use kdesu kfloppy %u but %u doesn't work (combo box is blank).

As a side note kdesudo (or sudo) cant open kfloppy with this error

kfloppy: cannot connect to X server

Another aside, anyone have an idea why kdesudo would need aRts to build?

Edited by naraku9333
Link to post
Share on other sites

I guess that I needto upgrade from 10 to 10.1. I really like SuSe now that I am finally learning to do some things. Thanks for the info on the thumb drive, hadn't even tried to figure that out yet

Link to post
Share on other sites

Ok, I got a working method to add format to right click action menu and as an action for connected usb devices (KDE3.5.x). I used kfloppy basicaly since being a kde app has the look n' feel. But having the correct device in the combo box in kfloppy requires editing the source (adding about 3 lines, not a hard process). If you don't already have the source download kdeutils-3.5.2.tar.bz2 (DIRECT LINK). Unpack the archive and

cd kdeutils-3.5.2/kfloppy/

In your favorite text editor open floppy.cpp (back it up first if you like) and go down to line 416, the section will look like:

// ### TODO user given devices
  bool ok = (drive>=0);  if (ok)	deviceComboBox->setCurrentItem(drive);

Add an else to the if statement changing the code block to:

// ### TODO user given devices
  bool ok = (drive>=0);  if (ok)	deviceComboBox->setCurrentItem(drive);  else{	deviceComboBox->setEditText(newDevice);	densityComboBox->setCurrentItem(0);  }

Save the file and exit. Change to the parent directory and configure the source

cd .../configure --without-arts  #####I needed this option, you may need otherscd kfloppy/makesu -c cp kfloppy /usr/kde/3.5/bin   ##### KDE path on my system yours may differ, some distros install in /opt.

To be able to format a usb flash drive with kfloppy it must be run as root (acctually the tools (mkdosfs,etc...) require root) so I use sudo. If you have sudo installed open /etc/sudoers as root. Go to the end of the file and add

%plugdev		ALL=(ALL)	   NOPASSWD: /usr/kde/3.5/bin/kfloppy

the %plugdev means only members of the plugdev group can run the command, change it to any group you are a member of or to your user name omitting the %. As an alternitive to sudo you can use kdesu wich IMO is more secure but has a drawback discussed shortly.

In KDE 3.5 when a usb mass storage device (not limited to these) is connected a notification appears allowing a choice of services. To add the format service to this menu is very simple. Open Control Center from kicker menu, click peripherals then storage media and then add. Highlight "Unmounted Removable Media" in the left pane and move it to the right. Enter "sudo kfloppy -display :0.0 %u" in command box (excluding quotes). Ok apply and your done. You can obviously use this method to add services for other media ie:autoplaying or possibly autoripping dvd's, etc...

If you dont want to use sudo change the Exec line to Exec=kdesu kfloppy, this will require root password to continue. The drawback mentioned earlier is using kdesu the %u variable isn't passed to kfloppy requiring the device name to be manually entered. I also attempted to use kdesudo to require user passwd only but the -display :0.0 flag doesn't seem to work.

If you want this to be global (for all users) move the pertinent .desktop file from ~/.kde/share/apps/konqureror/servicemenus to <KDEDIR>/share/apps/konqureror/servicemenus.

I hope the OP or anyone for that matter finds this udeful, I for one have little use for formatting flash drives aside from an entire filesystem change (vfat to ext2).

WARNING!!!:

It is Important to note the "hack" of the kfloppy code does no checks what so ever, what I mean is an accidental click on format on a system drive(icon) could result in a wiped OS. A check for ATA(IDE) drives should be easy, SATA not so easy. Mind you I dont know c++ or Qt.

EDIT:

Removed redundent material.

Edited by naraku9333
Link to post
Share on other sites
nice job :-)

I love the fact with open source changes can be made so easily(reletively). Try doing that on your windows operating system.

Yes kde makes things pretty easy. Heres another little .desktop file that adds a compile action for .java files.

[Desktop Entry]
Encoding=UTF-8
ServiceTypes=text/x-java
Actions=CompileJava

[Desktop Action CompileJava]
Name=Compile Java File
Exec=javac %f
Icon=package_system

Link to post
Share on other sites

nice job :-)

I love the fact with open source changes can be made so easily(reletively). Try doing that on your windows operating system.

Yes kde makes things pretty easy. Heres another little .desktop file that adds a compile action for .java files.

[Desktop Entry]
Encoding=UTF-8
ServiceTypes=text/x-java
Actions=CompileJava

[Desktop Action CompileJava]
Name=Compile Java File
Exec=javac %f
Icon=package_system

did you dubmit the change to kfloppy.. This a great addition..

Link to post
Share on other sites

it should not allow you to format a mounted drive.. so you should be ok.. but wrap it in a try statment or if statment and check if mounted.. (I know.. sounds easy.. produce code) well since all two years of C++ in collage tought noting useful about devices or such,, I am not sure..

Link to post
Share on other sites

You can formate a thumb drive via YAST. Simply run yast, enter your root pass when prompted, then select "system" then "partitioner". Find the line representing your thumb drive and highlight it and click on "edit" then check the button for formate and select FAT or whatever file system you desire.

Link to post
Share on other sites

Thanks to all who responded.

I tried formatting the thumb drive in kfloppy (followed the directions in the documentation) and it hosed my drive.

Had to reformat by command line to fix it. I'm sure this will work in some future version of kfloppy.

I did assume that the partitioner in Yast could do it to - just seemed like overkill.

A command line really seems to be the "easiest" way to do this. (for me)

Thanks again.

Link to post
Share on other sites
I tried formatting the thumb drive in kfloppy (followed the directions in the documentation) and it hosed my drive.

Had to reformat by command line to fix it. I'm sure this will work in some future version of kfloppy.

What do you mean "hosed the drive", kfloppy uses the same command (mkdosfs) for quick formats which is all you can do with a flash drive. (kfloppy uses fdformat for "full format" which checks if it is a floppy drive)

Link to post
Share on other sites

It was likely my fault - I forgot to unmount /dev/sda1 before formating.

I put /dev/sda1 as the floppy drive, checked "Zero out and quick format", and provided a volume label.

A box popped up saying "drive must be unmounted" - click OK.

Then it asked for root password - which I gave.

Then kfloppy crashed, without any error messages, it just disappeared.

And the drive was unmountable - unreadable - "hosed".

A format from the command line brought it back.

Probably my bad. But I didn't try again.

Link to post
Share on other sites
It was likely my fault - I forgot to unmount /dev/sda1 before formating.

I put /dev/sda1 as the floppy drive, checked "Zero out and quick format", and provided a volume label.

A box popped up saying "drive must be unmounted" - click OK.

Then it asked for root password - which I gave.

Then kfloppy crashed, without any error messages, it just disappeared.

And the drive was unmountable - unreadable - "hosed".

A format from the command line brought it back.

Probably my bad. But I didn't try again.

More than likely it errored durring or after the zero out with dd. If so there wasn't (shouldn't have been) a problem with the drive, it was unmountable because it didn't have a filesystem (FS's are mounted, not drives). I do wonder why it crashed, I ran the zero out/quick format without any problems.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...