Saturday, April 11, 2009
Formatting new internal hard drive
It is painfully apparent that latest software still lags behind latest hardware.
I had to add another internal drive to my Linux system, and though this is by far not the first time I had to do something like that, I keep forgetting the right sequence of commands, especially since these command do differ somewhat between Linix and BSD-based systems.
That's why following suggestion from somewhere I installed and tried to use new Ubuntu front-end utility for disk management, "GParted".
Indeed, this utility does conveniently show list of available disks, mounted or not, and allows you to create "disk label" (which is a first step before new file system cam be created). The only thing is, there are different "types" of "disk label", and default type "msdos" seems a bit strange, and there is no help or any explanation what other types are for, but still, this was indeed a correct default, in my case (but see below).
Unfortunately, the program only goes this far. An attempt to create actual file system hit me with error message "A partition cannot have a length of -1 sectors". Quick Internet search revealed the following:
- This error only happens with disk sizes > 1TB (mine is 1.5TB);
- No one has a clue as to why;
- "msdos" disk label only supports disks < 2TB. There should be no problem with 1.5TB size though;
- Nevertheless, some suggest to use disk label type GPT, which is supposed to handle any disks.
OK, I tried using GPT as disk label type, but it didn't make any difference.
Therefore, I followed advice from this blog post and use these commands to create filesystem:
sudo cfdisk /dev/sdc sudo mke2fs -j /dev/sdc1 sudo vol_id /dev/sdc1
Some comments:
- "cfdisk" is ncurses-based utility which is more or less equivalent to "GParted", but it does seem to work. However, it refuses to do anything if you already created GPT disk label, seems like it only works with "msdos". You can always use "GParted" to create another disk label.
- Option "-j" ("journaling") essentially means "ext3" file system;
- vol_id prints volume "ID" which can then be used in fstab (it is considered to be more stable than device names like "/dev/sdc1"). Entry in /etc/fstab could then look like that:
UUID=c49f9c07-1025-4e6b-988a-276ac67a1b6e /ext ext3 defaults 0 0
However, in order for "mount /ext" to succeed, there must be a sym link (automatically) created in /dev/disk/by-uuid/ , and apparently opinions differ as to what should trigger creation of new link after a new drive has been installed and formatted. For me, this command
sudo /etc/init.d/udev restart
worked.