Jump to content

Formatting a USB harddisk


momba

Recommended Posts

HiI have a 80G external usb hard disk which had been working very well for around a year now. This was used to backup my office files running on windows .One fine morning it started rebooting windows if I try to connect it. I had tried to connect the device to many laptops (all are XP in our office) and every machine had been rebooted.I try to connect the usb to the linux box (MEPIS) and it works fine, I can access the data from linux altho the device is on readonly mode. I wish to put things back to normal and I feel if I could format the USB HD from linux probably as ntfs and it might work in windows. But it does not let me make any changes. I selected permissions tab from the gui and tried to change it to Can view & modify content for owner, group and others or individually it tells me Could not change permissions for /media/sda1. But I know I am not root while I am doing it. I dont know may be I could change these permissions if I could start it as root.Also I notice that when I try to mount it as root and try these commandsmount sda1 or mount /mnt/sda1 or mount /dev/sda1 it sayscant find sda1 in /etc/fstab or /etc/mtab.But the device will come up in the desktop and if I right click on it and select Mount it happily mounts it even though I am just a user and not root. What could I be doing wrong when I try it from the terminal or how should I correctly do it so that I could mount is as root.Pls help me on how to change the permissions on this device so that I could format the disk.Thanks and regardsMomba

Link to comment
Share on other sites

Hi MombaThe fact is that if the external drive was formatted FAT and not NTFS you would be able to read/write to it. ( NTFS only allows reading )Now for the permission problem: please show us the /etc/fstab ( after you booted with the drive connected ):

# cat /etc/fstab

:'( BrunoPS: The usual format for mounting on the commandline is "# mount /dev/hda5 /mnt/hda5" it mounts the device /dev/hda5 on the moutpoint /mnt/hda5

Link to comment
Share on other sites

BrunoWell that explains the permissions issue. But should it not let me format it somehow so I can select FAT or atleast use it for storing linux files in the future.The command # mount /dev/sda1 /mnt/sda1 did not work, it saysmount point /mnt/sda1 does not existbut it does not have any problem to umount it once it is mounted from the desktopumount /dev/sda1 works perfect.When I tried to boot the system with the device connected it says Updating fstab and hung there. When I disconnected the HD it completed the booting and the system came up.fstab listing after booting the machine "without" USBHD and then connected later shows this.# cat /etc/fstab# Pluggable devices are handled by uDev, they are not in fstab/dev/hda2 / reiserfs defaults,noatime,notail 0 0/dev/hda5 swap swap sw,pri=1 0 0none /proc proc defaults 0 0none /proc/bus/usb usbfs devmode=0666 0 0none /dev/pts devpts mode=0622 0 0none /sys sysfs defaults 0 0/dev/hda6 /home auto defaults,noatime 1 2# Dynamic entries below, identified by 'users' option/dev/hda1 /mnt/hda1 auto noauto,users,exec 0 0/dev/hda3 /mnt/hda3 auto noauto,users,exec 0 0

Edited by momba
Link to comment
Share on other sites

BrunoLast time when I shutdown the system to boot it the usb HD was connected so I assumed it would umount it, I guess I was wrong.So I gave a fsck on the disk as requested and this time again rebooted the machine after safely unmounting the USB HD. This time the system came up as expected and here is the fstab file.Looks like its the same as beforecat /etc/fstab# Pluggable devices are handled by uDev, they are not in fstab/dev/hda2 / reiserfs defaults,noatime,notail 0 0/dev/hda5 swap swap sw,pri=1 0 0none /proc proc defaults 0 0none /proc/bus/usb usbfs devmode=0666 0 0none /dev/pts devpts mode=0622 0 0none /sys sysfs defaults 0 0/dev/hda6 /home auto defaults,noatime 1 2# Dynamic entries below, identified by 'users' option/dev/hda1 /mnt/hda1 auto noauto,users,exec 0 0/dev/hda3 /mnt/hda3 auto noauto,users,exec 0 0any ideas on where I should move now

Link to comment
Share on other sites

BrunoMy friend tells me that I could unmount the disk and do a raw format, altho he does not tell me how to do that.Any idea on how I could do that.:whistling:

Link to comment
Share on other sites

BrunoMy friend tells me that I could unmount the disk and do a raw format, altho he does not tell me how to do that.
You can run the "mkfs" command to format a device. Assuming the USB hard disk is recognized as /dev/sda1 and you want to format it in FAT, the command should look like this:
# mkfs -t vfat /dev/sda1

You can run "man mkfs" to learn more details about the mkfs command.

Link to comment
Share on other sites

Hi There are a few remarks I have to make:

Last time when I shutdown the system to boot it the usb HD was connected so I assumed it would umount it, I guess I was wrong.
At shutdown or reboot ALL devices are umounted by default . . also your USB drive will be.
The command # mount /dev/sda1 /mnt/sda1 did not work, it saysmount point /mnt/sda1 does not exist
I would like to see "ls -al /mnt" and "cat /etc/mtab" to see where the mount point is supposed to be . . . . . . maybe "ls -al /media" shows us the place ;)Next, Daihard is correct with his command . . . but only if the partition is "set to type" FAT . . . if the "type" is NTFS or Ext3 you should change the "type" first before formatting it with the command Daihard posted.You can see what "type" the partition on the drive(s) is with "fdisk -l":whistling: Bruno
Link to comment
Share on other sites

Next, Daihard is correct with his command . . . but only if the partition is "set to type" FAT . . . if the "type" is NTFS or Ext3 you should change the "type" first before formatting it with the command Daihard posted.You can see what "type" the partition on the drive(s) is with "fdisk -l"
Good info! I didn't know that... I thought "-t <filesystem>" would be enough to format a device using that file system no matter what the device had before. Now, would you mind telling me how to "change the type"? I assume there's a command for it?Thanks!Dai
Link to comment
Share on other sites

burninbush
... Now, would you mind telling me how to "change the type"? I assume there's a command for it?
I'd just use cfdisk for that -- #cfdisk /dev/sdX, then arrow-down to highlight the partition you want to change, and then arrow-right to Type -- and choose which you like. Arrow-right to the Write item, confirm that, and then reboot the puter; when it comes back up, you'll find the type has changed, and then it would be OK to format it with the appropriate mkfs tool.
Link to comment
Share on other sites

Hi Brunols -al /mnt - shows thistotal 0drwxr-xr-x 6 root root 168 2006-06-03 13:26 .drwxr-xr-x 19 root root 432 2006-03-11 20:50 ..drwxr-xr-x 2 root root 48 2006-03-11 20:53 hda1drwxr-xr-x 2 root root 48 2006-03-11 20:53 hda3lrwxrwxrwx 1 root root 13 2006-03-11 20:43 ipod -> ../media/ipoddrwxr-xr-x 2 root root 48 2001-05-30 19:58 tempdrwxr-xr-x 2 root root 48 2006-03-16 12:31 temp2cat /etc/mtab - shows this/dev/hda2 / reiserfs rw,noatime,notail 0 0none /dev/pts devpts rw,mode=0622 0 0/dev/hda6 /home ext3 rw,noatime 0 0proc /proc proc rw 0 0sysfs /sys sysfs rw 0 0tmpfs /dev/shm tmpfs rw 0 0usbfs /proc/bus/usb usbfs rw,devmode=0666 0 0tmpfs /dev tmpfs rw,size=10M,mode=0755 0 0binfmt_misc /proc/sys/fs/binfmt_misc binfmt_misc rw 0 0ls -al /media - shows where it is presenttotal 0drwxr-xr-x 3 root root 72 2006-06-03 10:55 .drwxr-xr-x 19 root root 432 2006-03-11 20:50 ..drwxr-xr-x 2 root root 88 2006-06-03 10:55 sda1fdisk -l /dev/sda1 - shows thisDisk /dev/sda1: 80.0 GB, 80023716864 bytes255 heads, 63 sectors/track, 9728 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesThis doesn't look like a partition tableProbably you selected the wrong device. Device Boot Start End Blocks Id System/dev/sda1p1 ? 13578 119522 850995205 72 UnknownPartition 1 does not end on cylinder boundary./dev/sda1p2 ? 45382 79243 271987362 74 UnknownPartition 2 does not end on cylinder boundary./dev/sda1p3 ? 10499 10499 0 65 Novell Netware 386Partition 3 does not end on cylinder boundary./dev/sda1p4 167628 167631 25817+ 0 EmptyPartition 4 does not end on cylinder boundary.Partition table entries are not in disk orderSo can I go ahead with formatting this.Guys thank you all for the helpThanks and regardsMomba

Link to comment
Share on other sites

Hi DaihardPretty simple, I use the mother of all partition tools, fdisk:

# fdisk /dev/sda

This will open fdisk for sda. Next type "L", this will list the possible codes for the different "types" ( IDs ) for the partition.Next type "T", this will ask you for the number of the partition you want to change the "type" of and after that it will ask you for the (hex)code ( b will change it to FAT32 )Next type "W" to write the changes to disk.And now you can use the mkfs command to format the partition.:hysterical: BrunoNOTE: Typing the letter "M" while in fdisk will show you all the options the fdisk tool has

Link to comment
Share on other sites

ls -al /mediatotal 0drwxr-xr-x 3 root root 72 2006-06-03 10:55 .drwxr-xr-x 19 root root 432 2006-03-11 20:50 ..drwxr-xr-x 2 root root 88 2006-06-03 10:55 sda1
Hi Momba . . . yep, let's get back to your initial problem :)First, the mount command you should have used according to above info was:
# mount /dev/sda1 /media/sda1

But I see there are strange things going on regarding your sda

Disk /dev/sda1: 80.0 GB, 80023716864 bytes255 heads, 63 sectors/track, 9728 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesThis doesn't look like a partition tableProbably you selected the wrong device. Device Boot Start End Blocks Id System/dev/sda1p1 ? 13578 119522 850995205 72 UnknownPartition 1 does not end on cylinder boundary./dev/sda1p2 ? 45382 79243 271987362 74 UnknownPartition 2 does not end on cylinder boundary./dev/sda1p3 ? 10499 10499 0 65 Novell Netware 386Partition 3 does not end on cylinder boundary./dev/sda1p4 167628 167631 25817+ 0 EmptyPartition 4 does not end on cylinder boundary.
. . . so I would open fdisk ( the mother of all partition tools in Linux ) on that drive, delete all partitions and make new ones, ( you can also use any other Linux partition tool to do this though )Read here http://forums.scotsnewsletter.com/index.ph...14&t=503&st=244 how to use fdisk to delete the present partitions on /dev/sda . . . after that use the "N" to make new partitions . . . and do not forget to set the "type" ( the Id value you saw in fdisk -l ) with the "T":hysterical: Bruno
Link to comment
Share on other sites

I'd just use cfdisk for that -- #cfdisk /dev/sdX, then arrow-down to highlight the partition you want to change, and then arrow-right to Type -- and choose which you like. Arrow-right to the Write item, confirm that, and then reboot the puter; when it comes back up, you'll find the type has changed, and then it would be OK to format it with the appropriate mkfs tool.
Thanks for the info. Now, I can't seem to locate cfdisk on my FC installation. Is this sequence of calling cfdisk and mkfs particular to any specific distribution? Come to thnk about it, I don't recall having to do anything like that when formatting any of my hard disks for Fedora Core.
Link to comment
Share on other sites

Thanks for the info. Now, I can't seem to locate cfdisk on my FC installation. Is this sequence of calling cfdisk and mkfs particular to any specific distribution? Come to thnk about it, I don't recall having to do anything like that when formatting any of my hard disks for Fedora Core.
Usually the installer does those things for you . . . . :hysterical: . . . and have a look what /sbin/fdisk ( or /sbin/cfdisk ) does ;):thumbsup: Bruno
Link to comment
Share on other sites

Usually the installer does those things for you . . . . :icon8: . . . and have a look what /sbin/fdisk ( or /sbin/cfdisk ) does :thumbsup:
I've done some disk formatting after the installation using the mkfs command in order to convert my old Windows drives to ext3. All I had to do was run "mkds -t ext3 /dev/xxx". :hysterical: fdisk is under /sbin, but cfdisk is nowhere to be found. Could you or someone else please run "rpm -q --whatprovides /sbin/cfdisk" to see what package cfdisk is included in?Thanks!
Link to comment
Share on other sites

Hi Momba . . . yep, let's get back to your initial problem :hysterical:

ls -al /mediatotal 0drwxr-xr-x 3 root root 72 2006-06-03 10:55 .drwxr-xr-x 19 root root 432 2006-03-11 20:50 ..drwxr-xr-x 2 root root 88 2006-06-03 10:55 sda1
First a side-note, the mount command you should have used according to above info was:
# mount /dev/sda1 /media/sda1

But . . . . I see there are strange things going on regarding your sda

Disk /dev/sda1: 80.0 GB, 80023716864 bytes255 heads, 63 sectors/track, 9728 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesThis doesn't look like a partition tableProbably you selected the wrong device. Device Boot Start End Blocks Id System/dev/sda1p1 ? 13578 119522 850995205 72 UnknownPartition 1 does not end on cylinder boundary./dev/sda1p2 ? 45382 79243 271987362 74 UnknownPartition 2 does not end on cylinder boundary./dev/sda1p3 ? 10499 10499 0 65 Novell Netware 386Partition 3 does not end on cylinder boundary./dev/sda1p4 167628 167631 25817+ 0 EmptyPartition 4 does not end on cylinder boundary.
. . . so I would open fdisk ( the mother of all partition tools in Linux ) on that drive, delete all partitions and make new ones, ( you can also use any other Linux partition tool, you are more comfortable with, to do this )Read here http://forums.scotsnewsletter.com/index.ph...14&t=503&st=244 how to use fdisk to delete the present partitions on /dev/sda . . . after that use the "N" to make new partitions . . . and do not forget to set the "type" ( the Id value printed in fdisk -l ) with the "T"Typing the letter "M" while in fdisk will show you all the options the fdisk tool hasB) Bruno
Link to comment
Share on other sites

  • 3 weeks later...

Hi BrunoWell I am stuck again. I got a new USB Harddisk. The idea is to move the old usb data to hard disk and move it from hard disk to the new disk. I cannot move everything to the harddisk at once due to space issue. So I need to move them part my part.Now when I try to fomat the new drive from XP the only option is to format it as NTFS. Well I format it and plug it into linux. Now since it is NTFS it is read only, So I need to format it to FAT32 first - correct. So I tried fdisk command.fdisk /dev/sda1.I first delete all the partitions, then i verify that and it shows56296321 unallocated sectorsNow I create new primary partition. selected the default as 1 for first cylinder and default 9728 for last cylinder.i gave 't' tochange the type and selected 'b' for W95 FAT32.while i tried to write the changes it says this.

Command (m for help): wThe partition table has been altered!Calling ioctl() to re-read partition table.WARNING: Re-reading the partition table failed with error 22: Invalid argument.The kernel still uses the old table.The new table will be used at the next reboot.WARNING: If you have created or modified any DOS 6.xpartitions, please see the fdisk manual page for additionalinformation.Syncing disks.
now when i remove the hard disk and put it back to XP it still shows it as NTFS obviously it failed th make changes to the usb harddisk.Can you help here and also while I am here wanted to check this. fdisk command will not format the drive right it will only create the partitions.Thanks for all the support Momba
Link to comment
Share on other sites

Hi Momba . . . you were almost on the right way up to here:

now when i remove the hard disk and put it back to XP
You should not have done that . . . . . :DAfter the message "Syncing disks" you do:
# umount /dev/sda1# mkfs -t vfat /dev/sda1# reboot

Reboot into Linux and "fdisk -l" to see if all is okayBUT . . . I see that there is a tiny little mistake you made earlier:

fdisk /dev/sda1
This should have been "fdisk /dev/sda" ( without the "1" . . . . . So let us try again from scratch:
# fdisk /dev/sdad ( delete partition )n ( create new partition )p ( primary )1 ( partition no 1 )1 ( start at 1 )9728 ( end at 9728 )t ( type of partition )b ( type )p ( print partition table, and check if all is okay )w ( write table to disk and exit )# umount /dev/sda1 ( yep now it's sda1 that's mounted due to last action )# mkfs -t vfat /dev/sda1 ( format sda1 as FAT )# reboot
Reboot into Linux and "fdisk -l" to see if all is okayB) BrunoPS: Alternative for "mkfs -t vfat /dev/sda1" is "mkfs.vfat /dev/sda1" :)
Link to comment
Share on other sites

BrunoMost of the part infact almost everything u said went fine.after reboot fdisk -l gave thisDisk /dev/hda: 60.0 GB, 60011642880 bytes240 heads, 63 sectors/track, 7752 cylindersUnits = cylinders of 15120 * 512 = 7741440 bytes Device Boot Start End Blocks Id System/dev/hda1 * 1 1292 9767488+ 83 Linux/dev/hda2 1293 2584 9767520 83 Linux/dev/hda3 2585 3876 9767520 83 Linux/dev/hda4 3877 7752 29302560 5 Extended/dev/hda5 3877 4523 4891288+ 82 Linux swap / Solaris/dev/hda6 4524 7752 24411208+ 83 LinuxDisk /dev/sda: 80.0 GB, 80026361856 bytes255 heads, 63 sectors/track, 9729 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System/dev/sda1 1 9729 78148161 b W95 FAT32But when i tried to mount it, it said# mount /media/sda1 /dev/sda1mount: /media/sda1 is not a block deviceBut the device was identified in the desktop as "80G Media". So i tried to select 'Mount' from the menu onright click. But that too failed with this errormount: wrong fs type, bad option, bad superblock on /dev/sda1,missing codepage or other errorIn some cases useful info is found in syslog - trydmesg | tail or soPlease check that the disk is entered correctly.And # dmesg |tailVFS: Can't find ext3 filesystem on dev sda1.VFS: Can't find an ext2 filesystem on dev sda1.FAT: invalid media value (0x62)VFS: Can't find a valid FAT filesystem on dev sda1.VFS: Can't find ext3 filesystem on dev sda1.VFS: Can't find an ext2 filesystem on dev sda1.FAT: invalid media value (0x62)VFS: Can't find a valid FAT filesystem on dev sda1.VFS: Can't find ext3 filesystem on dev sda1.VFS: Can't find an ext2 filesystem on dev sda1.tells me this.Any idea.

Link to comment
Share on other sites

BrunoI went ahead and repeated all the steps.Now things are working perfectly. I am extremely thankful to you.But what concerns me is the inconsitency. The same steps had failed once.Any comments on that. Now dont tell me that like a windows box, the reboot many times actually solved something here - :)Thanks for all ur sincere efforts Momba

Link to comment
Share on other sites

Hi MombaGlad it is fixed !! Congrats !!Here is where you made the mistake ( post #19 ):

But when i tried to mount it, it said# mount /media/sda1 /dev/sda1mount: /media/sda1 is not a block device
The command is not "mount /media/sda1 /dev/sda1" but "mount /dev/sda1 /media/sda1" ;)Additionally I would like to see your /etc/fstab . . . to be sure it mentions the correct file type:
# cat /etc/fstab

;) Bruno

Link to comment
Share on other sites

BrunoYou were perfectly right.But I dont know somehow it is imprinted into my mind that it ismount source target and i thought source was media/sda1.Now I dont know why it changed its mind but it did not like sda1 anymore so it told me when I tried to mount it from GUI that it is now sdc1. But I think something happened in between. Even though I know it was not possible to plug two external usb harddisks in windows, I thought I should give that a try in Linux. So I plugged in the faulty drive as well and mounted it as sdb1 from the GUI, and I guess sda1 got unmounted automatically, cause I could not access it anymore and also it vanished from GUI. So I had to remove the faulty one, then remove the new one and then reinsert the new one so that is showed up again and allowed me to mount it.so these are the results.# mount /dev/sdc1 /media/sdc1root@1[~]# cat /etc/fstab# Pluggable devices are handled by uDev, they are not in fstab/dev/hda2 / reiserfs defaults,noatime,notail 0 0/dev/hda5 swap swap sw,pri=1 0 0none /proc proc defaults 0 0none /proc/bus/usb usbfs devmode=0666 0 0none /dev/pts devpts mode=0622 0 0none /sys sysfs defaults 0 0/dev/hda6 /home auto defaults,noatime 1 2# Dynamic entries below, identified by 'users' option/dev/hda1 /mnt/hda1 auto noauto,users,exec 0 0/dev/hda3 /mnt/hda3 auto noauto,users,exec 0 0Now would u be kind enough to share what u r looking at so that I have a clue.;)

Link to comment
Share on other sites

Frank Golden
Even though I know it was not possible to plug two external usb harddisks in windows, I thought I should give that a try in Linux.
I do it all the time in XP and Ubuntu? As a matter of fact I have had 5-6 plugged in at one timejust to see if I could get away with it. Edited by Frank Golden
Link to comment
Share on other sites

Now would u be kind enough to share what u r looking at so that I have a clue.
Well I was looking if there was a line in there created dynamically and reflecting the USB drive . . . . but the line "# Pluggable devices are handled by uDev, they are not in fstab" tells us that we will not see them in the fstab B) so nothing to see there . . . . :)Indeed if you keep plugging unplugging quickly the one after the other it is possible that one time it will be called sda1 and the next time sdb1 ( or sdc1 ) . . . just because the software can't keep up with the changes.;) Bruno
Link to comment
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.

×
×
  • Create New...