A Simple Hard Disk Partitions Overview
Total Page:16
File Type:pdf, Size:1020Kb
Before creating partition you must chose in which way you want to manage your partition. Way 1: You can create one or more primary partition and one extended partition on a disk . And now create as much as logical partition on that extended partition. All you need to do is format those logical partition and mount it to a file system. You can add multiple primary/logical partition (i.e. sdb1,sdb2 etc) on to a filesystem and by this way you can increase sie of filesystem (i.e /mydisk) . Way 2: a. create a pv for whole disk. b. Now create vg on it with appropriate requirement (use man for vgcreate). c. Create LV on it with appropriate requirement (use man for lvcreate). d. Format that lv e. Mount it to a filesystem ***The way 2 is better for partition management. Here you can extend/reduce/split your VG and LV. A Simple Hard Disk Partitions Overview A hard disk can be divided into several partitions. Each partition functions as if it were a separate hard disk. The idea is that if you have one hard disk, and want to have, say, two operating systems on it, you can divide the disk into two partitions. Each operating system uses its partition as it wishes and doesn't touch the other ones. This way the two operating systems can co‐exist peacefully on the same hard disk. Without partitions one would have to buy a hard disk for each operating system. Different type of Partitions 1.Primary 2.Extended and 3.Logical Partitions There can be maximum 4 primary partition. That mean 4 OS can be reside on a hard disk at time. To overcome the limit we can use extended partition which can contain up to 24 partition. Each partition can be use as one logical viloume (i.e. c,d drive for windows or lv (i.e. sda1,sdb1) for linux or aix). The partition structure of a hard disk might look like that in Figure 5‐2. The disk is divided into three primary partitions, the second of which is divided into two logical partitions. Part of the disk is not partitioned at all. The disk as a whole and each primary partition has a boot sector. Figure 5-2. A sample hard disk partitioning. Difference between primary and a logical partition There are only two main differences between a primary and a logical partition or volume. The first is that a primary partition can be set as bootable (active) while a logical cannot. The second is that DOS assigns drive letters (C:, D: etc.) differently to primary and logical volumes. Here's an example to hopefully make all of this a bit more clear. Let's suppose you are setting up a new system and starting with an empty 60 GB hard disk. You could create a single 60 GB partition, which would be a primary DOS partition. However, in many cases dividing up such a large disk will make it easier to manage the space, will reduce lost disk space due to slack, and will reduce defragmentation time on partitions containing more actively‐used data. (See here for much more on the issues involved in partitioning.) So instead, let's say you want to split up this drive as follows: One 8 GB primary partition for Windows and other operating system and program files. One 12 GB partition for data. One 16 GB partition for games. The rest of the disk in a 24 GB partition for large multimedia files, short‐term backups and "future expansion". I'm assuming no complicating factors here, just a simple example. To do this, you will first set up a primary DOS partition 8 GB in size. This is the first of your four partitions. You will then create an extended DOS partition that is 52 GB in size. This is the second partition on the hard disk. Within the extended DOS partition you will create three logical volumes: one 12 GB, one 16 GB and one 24 GB. These are your second, third and fourth volumes (logical partitions). The first partition will be your C: drive from which you boot the machine, and DOS will (normally) assign D:, E: and F: to the other three logical partitions. Your hard disk will have one primary DOS partition, and one extended DOS partition containing three logical DOS volumes. Graphical depiction of the partitioning of a 60 GB hard disk, as described in the example above. Each square represents 1 GB of space on the hard disk. The blue squares are the 8 GB primary partition; the green, red and purple squares are the 12 GB, 16 GB and 24 GB partitions respectively. The latter three partitions are logical partitions contained within an extended DOS partition, indicated by the larger, gray‐shaded rectangle. Some useful linux command How do I add a new hard drive in Linux and create a primary partition? Important Notes: • This guide is for customers who have purchased an additional hard drive and need help configuring it to work with their Linux Server. Getting Started: 1. Check to see how many drives are installed: You can do this using the fdisk command. [root@default]# fdisk -l | grep '^Disk' You should output similar to the following: Disk /dev/sda: 251.0 GB, 251000193024 bytes Disk /dev/sdb: 251.0 GB, 251000193024 bytes A device name refers to the entire hard disk. For more information see Linux partition naming convention and IDE drive mappings . 2. To partition the disk fdisk /dev/sdb, enter: [root@default root]# fdisk /dev/sdb • For help using the partitioner, use the “m” command: Command (m for help): m Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only) Command (m for help): • partitions using the command “p”: Command (m for help): p Disk /dev/sdb: 50.0 GB, 50019202560 bytes 255 heads, 63 sectors/track, 6081 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System Command (m for help): • • To create a new partition, issue the command “n” and then select “p” for primary and 1-4 depending on which partition on the drive this is (first, second, third, or fourth): n(creates a new partition) p(creates a primary partition) 1(the number 1 denotes the partition will be /dev/sdb1) Command (m for help): Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-6081, default 1): 1 Last cylinder or +size or +sizeM or +sizeK (1-6081, default 6081): 6081 • To save the partition, use the “w” command: Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. [root@default root]# 3. Format the new disk using mkfs.ext3 command: To format Linux partions using ext2fs on the new disk, issue the following command: [root@default]#mkfs.ext3 /dev/sdb1 4. Mount the new disk using the mount command: First, you'll need to create a mount point. We'll use /disk1. This is where we'll mount /dev/sdb1. Enter the following commands: [root@default]# mkdir /disk1 [root@default]# mount /dev/sdb1 /disk1 [root@default]# df -H 5. Edit /etc/fstab so the new drive will automatically mount to /disk1 on reboot How do I create a extended partition and create multiple logical partition? Important Notes: • This guide is for customers who have purchased an additional hard drive from us, and need help configuring it to work with their Linux Server. Getting Started: 2. Check to see how many drives are installed: You can do this using the fdisk command. [root@default]# fdisk -l | grep '^Disk' You should output similar to the following: Disk /dev/sda: 251.0 GB, 251000193024 bytes Disk /dev/sdb: 251.0 GB, 251000193024 bytes A device name refers to the entire hard disk. For more information see Linux partition naming convention and IDE drive mappings . 3. To partition the disk fdisk /dev/sdb, enter: [root@default root]# fdisk /dev/sdb • For help using the partitioner, use the “m” command: Command (m for help): m Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only) Command (m for help): • partitions using the command “p”: Command (m for help): p Disk /dev/sdb: 50.0 GB, 50019202560 bytes 255 heads, 63 sectors/track, 6081 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System Command (m for help): • • To create a new partition, issue the command “n” and then select “p” for primary and 1-4 depending on which partition on the drive this is (first, second, third, or fourth): n(creates a new partition) e(creates a extended partition) 1(the number 1 denotes the partition will be /dev/sdb1) Command (m for help): Command (m for help): n Command action e extended p primary partition (1-4) e Partition number (1-4): 2 First cylinder (1-6081, default 1): 1 Last cylinder or +size or +sizeM or +sizeK (1-6081, default 6081): 6081 To create logical partition on newly created extended partion n(creates a new partition) e(creates a extended partition) 1(the number 1 denotes the partition will be /dev/sdb1) Command (m for help): Command (m for help): n Command action l logical (5 or over) p primary partition (1-4) l Partition number (1-4): 5 First cylinder (1-6081, default 1): 1 Last cylinder or +size or +sizeM or +sizeK (1-6081, default 6081): +4G • To save the partition, use the “w” command: Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table.