LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Linux Answers > Hardware
User Name
Password

Notices

By Steel_J at 2004-10-16 02:41
Let's start with a few pre-statements:

1) I am using Mandrake 10.1 Community, this guide is based on that but should work on any distro.

2) I am using an external drive enclosure that is pretty generic and uses both a Firewire and a USB 2.0 interface. The choice is left to the user. I tried both and they work the same. In this enclosure I installed a 80GB Maxtor IDE 7200rpm IDE drive.

3) The guide is based both on my personal ''hair ripping' acquired experience and also from me reading extensively on the subject around the Web.

Now here we go:

Fact: Linux partitioning tools, Command line or graphical, like DiskDrake are wonderful but THEY DO NOT LIKE EXTERNAL DRIVES OF ANY KIND when it comes to formating. Just remember that.

So... that means do not try to partition your external drive with them. It most probably won't work and you'll get errors.

First thing first...we need to get around that problem and partition our drive from somewhere else. I personally keep a Windows XP on dual boot to play games and give support to my Microsoft user friends and family members, so I booted into XP, my disk was connected with its Firewire cable and was detected on boot. I then used Partition Magic 8.0 to format my external drive in 2 separate partitions, one primary and one logical. I formated both in fat32 and chose not to assign any drive letters. (any good partitioning software will do, you can even use the partitioning tool of Windows XP/2K located in administrative tools)

Fact: Fat32 filesystem instead of ext3 or ReiserFs or any other makes your drive portable and compatible with any operating system because both Linux and Windows read and write fat32. (Linux only reads NTFS reliably and the writing is shaky at best. As for Windows, it doesn't read or write any unix filesystem)

If you don't dual boot Windows, the only alternative I see if you have an enclosure like me with an IDE drive is to take out the drive, plug it in one of your internal IDE ports, boot Linux, mount it and format it with DiskDrake or the command line. After , put it back in it's enclosure and go on with this guide.

Next step...

If all is well and it should, when you boot Linux , you should see with the disk utility of your distro, in my case DiskDrake, that your external drive as been detected. It will most likely show up with your other harddisks as SDA. In my case on SDA I found 2 partitions named SDA1 and SDA5.

We want to mount these partitions so before we do, we create directories for each partitions. I created /bak1 and /bak2 in my /home directory, but anywhere will do. I used my /home directory because everything in it can be modified by me,the user. Use simple and short names without spaces.

Now the next step is the one that many user miss or don't do properly that makes all the difference between your external drive working or mot.

Log in as root and open the file 'fstab' that is located in /ETC with an editor like Kwrite.
Here we are going to setup the mounting properties of our external drive and fstab is the config file that does that. (a great simple guide to learn about fstab here: http://www.tuxfiles.org/linuxhelp/fstab.html#what )

Fstab is a simple text file.

Her is a copy of my fstab and the lines that have to be added:

/dev/hda5 / ext3 defaults 1 1

Here are the 2 lines in my case: (the spaces are just to outline them)
/dev/sda1 /bak1 vfat noauto,user,rw,exec,sync 0 0
/dev/sda5 /bak2 vfat noauto,user,rw,exec,sync 0 0

none /dev/pts devpts mode=0620 0 0
/dev/hdc3 /home ext3 defaults 1 2
/dev/hdb /mnt/cdrom auto umask=0,user,iocharset=iso8859-1,codepage=850,noauto,ro,exec,users 0 0
/dev/hde /mnt/cdrom2 auto umask=0,user,iocharset=iso8859-1,codepage=850,noauto,ro,exec,users 0 0
none /mnt/floppy supermount dev=/dev/fd0,fs=ext2:vfat,--,umask=0,iocharset=iso8859-1,sync,codepage=850 0 0
/dev/hda1 /mnt/win_c ntfs umask=0,nls=iso8859-1,ro 0 0
/dev/hdc5 /mnt/win_c2 ntfs umask=0,nls=iso8859-1,ro 0 0
/dev/hdc6 /mnt/win_d ntfs umask=0,nls=iso8859-1,ro 0 0
none /proc proc defaults 0 0
/dev/hdd1 /shared ext3 defaults 1 2
none /tmp tmpfs defaults 0 0
/dev/hda6 /video_1 ext3 defaults 1 2
/dev/hdc4 /video_2 ext3 defaults 1 2
/dev/hdc2 swap swap defaults 0 0


If we take apart one of those lines (they are both almost identical) :

/dev/sda1 /bak1 vfat noauto,user,rw,exec,sync 0 0

It means mount /dev/sda1 to directory /bak1 witch is formated as fat32 (vfat), do not automount it on boot (noauto), allow users to mount it (user), allow read and write (rw), allow programs to be executed on it (exec), allow operations on the media to be without delay (sync) . the 2 numbers at the end I won't get into, leave them like they are. They are related to filesystem check and integrity. (I suggest you read the guide I suggested above, it will make you understand a lot, trust me!)

After this, save the file and reboot. One or more icons should then be on your desk after reboot, links to your external drive. Right click on the icon(s) and choose' mount' . After that you will be able to read and write to them.

Notes : I don't suggest that you automount your external drive, because automounting USB2.0 and Firewire, in my opinion is not stable enough. I could then keep your system from booting. If that ever happens you will have to boot in failsafe mode to console and edit the fstab file with an console editor like VI or VIM or the like and remove the line related to your ext. drive before you reboot. Another reason for not automounting is that usually an external drive, as in my case, is used for backup purposes and you want to keep your backups away from snoops, viruses , trojans or malicious users, even if those are pretty rare in Linux, ;-). It should be noted that I have never experienced a boot problem related to this myself.

Also I have read that some external drives (not enclosures) may not be compatible with Linux, but I don't see this as being true because USB and Firewire are both standard protocols supported by the newer Linux kernels.


Recap of all this:

1) Use Windows to partition your drive as you see fit in fat32.

2) Boot Linux and go check if your external drive as been detected, it will mostly be called SDA.

3) Create directories for each partitions you want to mount. Create them in /MNT or in /HOME. Use simple and short names without spaces.

4)Add the proper lines in your fstab config files

5) Reboot the system, (not just the session)

6) One or many icons of your external drive corresponding to each partition described in the fstab file should be on your desktop. Right click them and choose 'mount'. You will then be able to read and write to them.

Good luck to all of you open source maniacs out there!!!

Steel_J



by hari_seldon99 on Thu, 2004-11-04 03:36
A statement made in the article is not, strictly speaking, true. I'm nitpicking a bit, of course...


Statement:

Fact: Fat32 filesystem instead of ext3 or ReiserFs or any other makes your drive portable and compatible with any operating system because both Linux and Windows read and write fat32. (Linux only reads NTFS reliably and the writing is shaky at best. As for Windows, it doesn't read or write any unix filesystem)





Correction:

Fact: Fat32 filesystem instead of ext3 or ReiserFs or any other makes your drive portable and compatible with any operating system because both Linux and Windows read and write fat32. Bear in mind, that fat32 filesystems do not support 'chmod' for file permissions in linux. File permissions are set the same for all files using the umask variable in the file located at "/etc/fstab" (The file system table for linux). This means that fat32 fcan be shaky as linux root filesystems, although it is definitely possible thru a compressed cloop image file in a fat32 filesystem, like knoppix can do. (Linux reads NTFS reliably but the writing is shaky at best and disabled by default. However, the captive-ntfs tool at http://www.jankratochvil.net/project/captive/ has been reported to work well with NTFS . As for Windows, it doesn't NATIVELY read or write any unix filesystem. There are tools that read linux ext2/3 partitions, like extfs at http://uranus.it.swin.edu.au/~jn/linux/explore2fs.htm , and there are write drivers for ext fs's for windows as well like in http://winext2fsd.sourceforge.net/, but you have to download them. Writing ext fs's in windows is unreliable also, but reading works just fine).

by RRepster on Sun, 2004-11-14 13:33
Hope this thread isn't old and thus will never be seen.

Is external USB drives shareable? I've tried with both Xandros and Linspire and I get the "you don't have permission" error from my WinXP machine when I try to access it on the network.

by Y0jiMb0 on Wed, 2004-11-17 14:53
Quote:
Fact: Linux partitioning tools, Command line or graphical, like DiskDrake are wonderful but THEY DO NOT LIKE EXTERNAL DRIVES OF ANY KIND when it comes to formating. Just remember that.

So... that means do not try to partition your external drive with them. It most probably won't work and you'll get errors.

These are bad news!
I was considering buying an external hard disk; I need some extra space for data (a couple of partitions) and I'd like to backup my /home partition (preserving permisions, etc): another partition. And I need it EXTERNAL.
Does anyone know how to do this under linux?
I mean, is it absolutely impossible partitioning+making filesystems without errors in linux?
how true are the comments above quoted?
TIA, please give me hope...

Regards

by hanbin on Sat, 2004-11-20 11:45
this is really a good thread for linux newbies like me.
now i've get my USB drive mounted.

but i've a question here:
anything we can do so that when we plug in the USB drive, it is detected and automaticly mounted? (and its icon automatic appear on desktop)
just like what happen when we insert a CD in the CDrom.

thanks.

by bigrobot on Wed, 2005-01-26 07:02
I frequently need to back up BIG files, some as large as 20 Gb, and files that size won't go on a fat 32 drive. Is Partition Magic reliable for formatting external hard drives ext3?

by Caysho on Mon, 2005-01-31 06:55
I bought myself a 256 MB Astone USB2 key, and when I first plugged it into SuSE, it was presented as having four partitions.
I did a bit of research, and found this is pretty much standard ?
Anyway, I didn't see the point using four of them, so I partitioned it using the linux fdisk, and that worked fine.
During the partitioning process, I had it list the ones it could see, and apparently they where not only "out of order" (ie not 1,2,3,4), it said it the partition sizes didn't match their parameters.

I have used the key since, formated fat32, single partition, and it's quite happy so far

I'm curious as to why using a linux partition programme on a usb key is considered bad ?

by dangerboy on Mon, 2005-07-25 03:05
Not to play the devils advocate, but I have succesfully formatted my usb drive under Slackware 10.1 using mkfs. If you want fat32 use:

Code:
mkdosfs /dev/sdX -c -F 32 -I -v
The -c and -v can be left off (respectively) if you don't want it to check for bad blocks and be verbose during the entire process.

Granted you should edit the partition with cfdisk or fdisk first. Also, the big gotcha is that some users forget to unmount the drive before formatting. Just thought I'd throw my 2 cents out there.

Part of what brought me here is that I had to reformat the hardrive in my Rio Karma (DAP), and I got tired of Windoze hanging around 50% for an ungodly amount of time. At least in Linux I know the job will be done right and I don't have to worry once I tell it what to do.

by JZL240I-U on Fri, 2005-09-09 04:30
Just for the lazy ones here (like me )):

No need to reboot, just type
Code:
mount -a
that will reread /etc/fstab and mount any unmounted devices (though I don't know about the icons in the GUI)...

by digeratidave on Fri, 2005-09-09 07:12
I have an interesting situation in that I have a Linksys Network Storage Link which connects to two USB drives that I use for home storage. The linksys website stated that its OS was a linux derivative so I plugged the USB drives into my laptop when it was running Fedora and to my surprise both drives automounted and appeared on my desktop. I moved the drives back to my Linksys device and restarted it and went on my merry way copying, moving and deleting files. When I experienced a problem with timeouts while moving a 40Gig backup file it dawned on me to connect the drives back to my Fedora and just drag and drop them so I did but when I moved the drives back to the Linksys I no longer have the rights to r or w. I looked at the permissions via the Linksys and it displays that I have the correct permissions. I tried changing permissions and it acts like it is working but when I come back the permissions are back to what they were. So I moved the drives back to my Fedora and tried to change permissions and the error I get is 'Read Only Drive'. The really funny thing is that when connected to the Linksys I have permission to r+w the files I moved, it is the files I didn't move that I seem to have lost the permissions on. Any ideas on how to correct this short of letting the Linksys reformat the drives?

by popiet on Sun, 2005-10-02 11:33
Maybe I got lucky, but I succesfully partitioned two USB2 external HDD using sfdisk, and then formated them using mkfs :
- I plug the disk in an USB2 slot
- it is detected as /dev/sda
- # sfdisk /dev/sda
- you ready to roll

could it be because they aren't "true" external drives, but rather IDE drives in an external USB2 rack ? I thought it would change nothing. Or is my software simply more recent ?


  



All times are GMT -5. The time now is 07:02 PM.

Main Menu
Advertisement

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