Richard Freeman on 15 Aug 2009 04:57:17 -0700

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] stick drive that mounts as /dev/sda (or sdb....)

Michael Lazin wrote:
> I don't think you can have a drive without a partition table.  

Sure you can - as somebody else pointed out floppy disks don't typically 
have them.  A partition table is just data stored in a few designated 
clusters - just like anything else stored on a hard drive.

 > Most thumb drives have 1 or 2 partitions on it by default.

True, but if you just ran mkfs on the raw device it would be 
overwritten.  Now, if your thumb drive has some kind of logic on it the 
drive might interfere with trying to modify that partition table, but if 
it just reads and writes heads/cylinders/clusters upon request there 
won't be any issues.

Now, one thing that hasn't been mentioned is that if you attempt to 
partition the drive you'll almost certainly hose the data that is 
currently stored on it.  Your filesystem spans the ENTIRE drive - which 
would include the cylinder that is normally reserved for containing the 
partition table/etc.  So, that cylinder contains actual data (or likely 
filesystem metadata) - if you create a partition table now you'll 
overwrite whatever happens to be there.  The output of fdisk -l is 
actually interpreting your data as a partition table.

Also - note that many nondestructive hard drive diagnostics utilities 
make use of the drive's diagnostic cylinder.  If you don't have a 
partitioned hard drive there is a good chance that this cylinder 
contains actual data.  So, many of these utilities could destroy your 
filesystem.  Typically these utilities work by using that cylinder to 
record checkpointing information as well as a copy of any data that is 
going to be destructively overwritten elsewhere on the disk - so that at 
any time the drive can be restored to normal if the process is interrupted.

I'd generally say that it is bad practice to use a usb drive in a raw 
mode like this.  However, that doesn't make it automatically "the wrong 
way" to do things - if you're using the drive for some exotic purpose it 
might make sense to do it this way.  However, if you're using your thumb 
drive the way that 99.999% of people use it, I'd copy the data off, 
partition it, and then lay down a new filesystem on the first partition.

There were some comments about how a drive can work without formatting. 
  Formatting is an overloaded term which applies to several things. 
There is physical low-level formatting which generally means laying down 
tracks that are properly spaced on a disk or tape such that the drive 
mechanics can seek to it later.  There is setting up partitioning. 
Then, there is creating filesystems within individual partitions.

Of course, you can define arbitrarily complex less-common scenarios as 
well (box contains 10 hard drives, which are assembled into one physical 
device with RAID, and the box presents a single device via iSCSI, and 
then a downstream device takes 10 of those boxes and assembles them into 
a single RAID that ultimately contains 100 boxes, and then you can run 
LVM on top of that (and even run RAID on top of the LVM and LVM on top 
of that RAID).

Most drives with embedded controllers come preformatted at the physical 
level or they manage that on their own (and for flash drives low-level 
formatting probably is meaningless anyway since the chips are accessed 
by gates that respond to an address bus, not by steering a head to the 
right physical location on a piece of magnetic media).

Since for the most part the linux kernel can mix and match the various 
layers in any way, you can come up with any number of storage approaches 
that work just fine.  However, if you don't want some utility to hose 
your data it is best to stick with the traditional approach for 
something like a thumb drive.  Who knows what the kiosk at the store 
would do to your data if you plugged in something non-standard.
Philadelphia Linux Users Group         --
Announcements -
General Discussion  --