Tutorial: Adding Additional Hard Drives in Linux - page 2
The Theory Behind Hard Drive ManagementFor example, your friend gave you a hard drive which was formatted in MS Windows system or even Linux, and there are some important files on this drive you want to keep.
First of all, obviously, we need to connect the hard drive physically to our PC, which for this example will be Master on Secondary interface. In this case, the disk name in the system will be hdc. After starting Linux, it is necessary to check whether Linux found the new device. For this, you can use the following command:
# ls /proc/ide
drivers hda@ hdc@ ide0/ ide1/ piix
So, we have found device hdc in our list. Everything seems to be okay. If you did not see the device in this list, you would need to check again all steps of physically connecting the hard drive to the PC.
Let's now take a look at what partitions we have available on the drive:
# fdisk -l /dev/hdc Disk /dev/hdc: 64 heads, 63 sectors, 787 cylinders Units = cylinders of 4032 * 512 bytes Device Boot Start End Blocks Id System /dev/hdc1 * 1 610 1229728+ 83 Linux /dev/hdc2 611 787 356832 5 Extended /dev/hdc5 611 787 356800+ c Win95 FAT32 (LBA)
It's easy to understand that in this example we have three partitions on our hard drive, and two of them (the first and fifth) are filled with some sort of data. Also, the first partition is a primary partition of the Linux system, and the fifth is a logical disk of Windows FAT32. The first partition is a bootable (as shown be the '*' symbol in the Boot column).
Now we need to attach these partitions to our file system. Such an operation of connecting partitions (to be more exact - connecting file systems) in Linux is called mounting and, as such, we use the command 'mount' to handle this. There is also a reverse operation known as unmounting, which we can start with the command 'umount'.
When you mount a partition in Linux, you need to associate it with a directory somethere in the file system. This is called creating a mount point. Usually you will want to create these mount point directories for each partition, such as:
# mkdir /mnt/hdc1 # mkdir /mnt/hdc5
Of course, you can use pre-existing directories. We just need to remember a couple of rules:
- In the Linux system, it is a usual (though not necessary) practice to group all mount points in one place, except in the cases when mounting system partitions (like /usr, /home, /var, etc.);
- The directory used as the mount point should be empty, or else its contents will be unavailable until the partition is unmounted.
Now, let's use the command 'mount' and attach some partitions:
# mount /dev/hdc1 /mnt/hdc1 # mount /dev/hdc5 /mnt/hdc5
Here /dev/hdc1 and /dev/hdc5 are the device names, and /mnt/hdc1 and /mnt/hdc5 are the mount points. (It goes without saying, that the directory names for the mount points don't have to mirror the partition names exactly.
Now, when changing to the directory to either /mnt/hdc1 or /mnt/hdc5, we can see contents of partitions.
If you are mounting a partition that uses a different filesystem than the one you're working in, it's necessary to mention the type of file system using the key -t of the mount command. If you have already mounted the partition, do not forget to unmount the partition with the command 'umount' before using the -t key to establish the type of filesytem used on the "foreign" partition:
# umount /mnt/hdc5 # mount -t vfat /dev/hdc5 /mnt/hdc5
The most common values of key -t are:
- msdos - FAT12 and FAT16
- vfat - FAT16 with long file name support, FAT32
- ext2 - primary Linux file system;
- ext3 - compataible with ext2 file system with log support
- reiserfs - new Linux file system with log support
A full list of supported file systems (more than 30) can be found in the man pages of the mount command.
Some readers, after following all of the above operations, may note that instead of certain lagnage symbols appearing in the file names of a FAT file-system partition, all they get are question marks. A prime example of this are f.e. Russian symbols within filenames on a FAT file system.
This doesn't mean that Linux won't support the Russian language in file names. Actually, Linux supports a lot of national code pages--we just need to establish exactly which one we want to use. This is done with the key -o.
After unmounting the partition in question, use these commands. For FAT partitions created with Windows 98 and/or Windows NT:
# mount -t vfat -o iocharset=koi8-r,codepage=866 /dev/hdc5 /mnt/hdc5
For FAT partitions, created with Windows ME and/or Windows 2000/XP:
# mount -t vfat -o iocharset=koi8-r,codepage=866,uni_xlate=1 /dev/hdc5 /mnt/hdc5
The difference here is in the additional argument uni_xlate. We need that argument because Windows ME/2000/XP uses Unicode in file names.
So, now we have everything set up for Russian file names. You can use the iocharset variable for your own language needs with the preceeding commands.
For FAT partitions it is also nice to use the arguments uid and quiet. This is very important because FAT doesn't have any services to separate or deny access to files.
The argument uid=user defines the owner of a mounted file system (user) who will have all rights to write/create new files on disk. The argument quiet hides all error messages, which will occur because it's impossible to change file owner and file access rights once a file is copied onto a FAT partition.
Solid state disks (SSDs) made a splash in consumer technology, and now the technology has its eyes on the enterprise storage market. Download this eBook to see what SSDs can do for your infrastructure and review the pros and cons of this potentially game-changing storage technology.
- 1Linux Top 3: GNOME 3.12 and New Betas for Ubuntu 14.04 and OpenMandriva Lx 2014.0
- 2Linux Top 3: Linux 3.10 Goes Long, Linux 3.11 Advances as LXDE Merges
- 3Linux Top 3: Linus Lashes out, Linux 3.14 Gets PIE and Ubuntu One is Done.
- 4Linux Top 3: Ubuntu 14.04, Debian Gives Squeeze More Life and Red Hat Goes Atomic
- 5Linux Top 3: Linux 3.11, Kubuntu Goes Commercial