Follow the Australian Telecommunications scene NEWSLETTER- FREE TRIAL
The Linux distillery
Bringing the world of Linux to you, David cuts through the tech and shows you how it works and how to use it, in terms that apply to any distro. RSS
Technology news and Jobs arrow The Linux distillery arrow Adding a new hard disk to Linux, and why the Linux filesystem trounces Windows' butt
Adding a new hard disk to Linux, and why the Linux filesystem trounces Windows' butt E-mail
by David M Williams   
Thursday, 02 October 2008
Kicking off with a previously-used hard disk, you may find it has already been picked up by Linux. The best way to check is with the command df –k which we used above and lists all the connected hard drives in use – specifically, the hard disk partitions which have been mounted. You will be able to identify any new disks in place.

The mount terminology comes from the days of large (in size, not necessarily space!) disks and tapes which were literally mounted and unmounted onto the computer by operators. The last column in the output from df –k shows where on the Linux filesystem each partition has been mounted. You might find that, say, the new hard drive hdc1 has been automatically mounted to directory /mnt/hdc1. If you traverse into that directory you can see any of the files and folders that exist on it.

If your disk has not been automatically mounted there’s nothing to worry about. The command fdisk –l will list all the partitions on any named hard drive. If you know you have added the second SATA disk to the computer then you can use the command fdisk –l /dev/sdb to list all available partitions on that device. If the disk has only one partition then /dev/sdb1 will be the only item listed, but more will show if the disk has been partitioned into multiple segments.

To mount a disk you need to choose where you wish to mount it on the file system. You can make a new folder specifically for the purpose or use an existing one. If the folder already exists do keep in mind that anything already existing in that folder will effectively disappear when you mount the new drive. It is still there and will show again when (if) the new disk is unmounted but for the most part you’re better off ensuring the folder is empty.

Mounting is nothing more complex than using the mount command with two parameters, namely the disk partition to mount, and the folder where it ought to be mounted, like so:

mkdir /mnt/MyDisk
mount /dev/sdb1 /mnt/MyDisk


If you wish the disk can be mounted as read-only by adding the flag –r to the command. It can be inspected but not modified in any way. Either way, the command df –k will verify the disk is now in use and available.

You can later unmount the hard drive if you wish to via the command umount, eg umount /dev/sdb1. This causes Linux to stop working with it and it is no longer accessible. Again, this can be verified by df –k.

Whether you unmount or not, if you reboot the computer at this point you will need to re-mount it again. That’s because the mount command above lasts just the current session. To make the disk mount every time you boot you must add an entry to the file /etc/fstab which essentially stands for “file system table.” There are graphical tools like Kfstab which will edit this file for you, or you can use vi or other editors.

The columns in /etc/fstab are, in order, the device to mount (eg /dev/sdb1), the mount point (eg /mnt/MyDisk), the type of file system (eg ntfs, ext3), any options (eg ro to mount as read only) then two numbers which are used by the specific tools dump and fsck.

If you add an appropriate line in /etc/fstab then the disk partition will be automatically mounted on each boot.

CONTINUED







 
< Next story in category   Previous story in the category >
iTWire user statistics Visitors last 30 days
694,279
Subscribers 15,210
#1 independent technology news advertise here
  •   *  
  • Search
  • AdvSeach
  • Login
  • Events
  • FreeStuff

- Advertisement -

Featured Whitepapers

Follow iTWire on Twitter

About iTWire

iTWire is all about technology news, information, jobs and community for the IT and telecommunications industry professional. Subscribe to our free ICT daily newsletter