Thursday, January 28, 2016
Linux Disk Management
1. Create Partitions and File systems
- · A hard disk provies a single large storage space usually split into partitions. The information about partitions is stored in the partition table.
Partiotion tables in Linux are compatible with Microsoft Windows. In order to compatible with Windows, at most four primary partitions can be made. But these can be extended partitions, which can themselves be split into smaller logical partitions.
2. Disk naming
- · The device files for IDE hard drives are/dev/hda to/dev/hdd, where
Had and hdb are the drives on the first IDE bhannel, and hdc and hdd are the drin\ves on the second channel. The first drive on each channel is the IDE maste, and the second is the IDE slave.
- · Primary partitions are numbered from 1-4
- · Logical partitions are numbered from 5
- · The devices/dev/had, tec., refer to the whole hard disk, not just partitions.
You can reer to a specific partition by adding the partition number to that specific partition.
For example, /dev/hda1 is the first partition on the first IDE disk.
3. Using fdisk
· You can use the fdisk command to creat, delete and change the partitions on a disk
· The fdisk command takes the disk name as an argument, for example:
· fdisk reads one-letter commands from the user
type m to get a list of commands
Type p to list the partitions that currently exist
Type q to quit without altering anything
Type w to quit and write the changes
4. Making New partitions
· You can create new partitions by using the n command. You can select whether to make a primary, extended or logical partition, and a number to assign to the partition.
· Fdisk asks where to start and end the partition. You can decide the size of the partition according to requirement by assigning values. Appropriate size for partition can be specified in megabytes such as, 250 MB.
· Changes to the partition table can be made with the use of w command.
5. Changing Partition Types
· Each partition has a type code, wich is represented by a unique number.
· The fdisk command I shows a list of known types
· You can change the type of an exsiting partition by using the t command
Enter thetype code at the prompt
· Linux partitions are usually of type: Linux native (type 83)
· Other operating systems might use other typer of partition, may ofwhich can be understood by Linux
6. Making Files Sysytem with mkfs
· The mkfs command initializes a filesystem on a new partition that results in loss of previous data available on the partition. For example, to make an ext2 filesystem on /dev/hda2. The syntax is:
# mkfs –t ext2 –c /dev/hda2
Where, -t sets the filesystem tyjpe to make, and –c checks for bad clocks on the disk
· Mkfs uses other programs to make specific types of filesystem. Such as mke2fs and mkdosfs