Showing posts with label Partitions. Show all posts
Showing posts with label Partitions. Show all posts

Friday, August 19, 2011

How to partition a hard disk using parted

parted command is used for
  • View the existing partition table
  • Change the size of existing partitions
  • Add partitions from free space or additional hard drives
Listing Details of the Hard Disks
[root@RHEL01 ~]# parted -l Model: SMC Array 0 (scsi) Disk /dev/sda: 1000GB Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type File system Flags 1 32.3kB 526MB 526MB primary ext3 boot 2 526MB 105GB 105GB primary ext3 3 105GB 158GB 52.4GB primary linux-swap 4 158GB 1000GB 842GB extended 5 158GB 210GB 52.4GB logical ext3 6 210GB 1000GB 789GB logical ext3 Model: SMC Array1 (scsi) Disk /dev/sdb: 1000GB Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type File system Flags 1 32.3kB 1000GB 1000GB primary ext3

Once can be compared this with fdisk -l.
First we need to look all option parted carry.
[root@RHEL01i ~]# parted /dev/sdc GNU Parted 2.1 Using /dev/sdc Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) help align-check TYPE N check partition N for TYPE(min|opt) alignment check NUMBER do a simple check on the file system cp [FROM-DEVICE] FROM-NUMBER TO-NUMBER copy file system to another partition help [COMMAND] print general help, or help on COMMAND mklabel,mktable LABEL-TYPE create a new disklabel (partition table) mkfs NUMBER FS-TYPE make a FS-TYPE file system on partition NUMBER mkpart PART-TYPE [FS-TYPE] START END make a partition mkpartfs PART-TYPE FS-TYPE START END make a partition with a file system move NUMBER START END move partition NUMBER name NUMBER NAME name partition NUMBER as NAME print [devices|free|list,all|NUMBER] display the partition table, available devices, free space, all found partitions, or a particular partition quit exit program rescue START END rescue a lost partition near START and END resize NUMBER START END resize partition NUMBER and its file system rm NUMBER delete partition NUMBER select DEVICE choose the device to edit set NUMBER FLAG STATE change the FLAG on partition NUMBER toggle [NUMBER [FLAG]] toggle the state of FLAG on partition NUMBER unit UNIT set the default unit to UNIT version display the version number and copyright information of GNU Parted (parted)

Creating a Partition

Here we will make 4 partitions, 2 primary which have 4GB and 512MB, and 2 logical partitions inside an extended partition (3.5 GB). As a default unit in parted is megabytes (MB).
[root@RHEL01 ~]# parted /dev/sdc GNU Parted 2.1 Using /dev/sdc Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) mkpart Partition type? primary/extended? primary File system type? [ext2]? ext3 Start? 0 End? 4096 Warning: The resulting partition is not properly aligned for best performance. Ignore/Cancel? Ignore (parted) p Model: ATA VBOX HARDDISK (scsi) Disk /dev/sdc: 8590MB Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type File system Flags 1 512B 4096MB 4096MB primary (parted) mkpart Partition type? primary/extended? primary File system type? [ext2]? ext3 Start? 4096 End? 4608 (parted) p Model: ATA VBOX HARDDISK (scsi) Disk /dev/sdc: 8590MB Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type File system Flags 1 512B 4096MB 4096MB primary 2 4097MB 4608MB 512MB primary (parted) mkpart Partition type? primary/extended? extended Start? 4608 End? 8590 (parted) p Model: ATA VBOX HARDDISK (scsi) Disk /dev/sdc: 8590MB Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type File system Flags 1 512B 4096MB 4096MB primary 2 4097MB 4608MB 512MB primary 3 4608MB 8590MB 3981MB extended lba (parted) mkpart Partition type? primary/logical? logical File system type? [ext2]? ext3 Start? 4608 End? 6656 Warning: The resulting partition is not properly aligned for best performance. Ignore/Cancel? Ignore (parted) p Model: ATA VBOX HARDDISK (scsi) Disk /dev/sdc: 8590MB Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type File system Flags 1 512B 4096MB 4096MB primary 2 4097MB 4608MB 512MB primary 3 4608MB 8590MB 3981MB extended lba 5 4608MB 6656MB 2048MB logical (parted) mkpart Partition type? primary/logical? logical File system type? [ext2]? ext3 Start? 6656 End? 8590 (parted) p Model: ATA VBOX HARDDISK (scsi) Disk /dev/sdc: 8590MB Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type File system Flags 1 512B 4096MB 4096MB primary 2 4097MB 4608MB 512MB primary 3 4608MB 8590MB 3981MB extended lba 5 4608MB 6656MB 2048MB logical 6 6656MB 8590MB 1934MB logical (parted)

Thursday, August 18, 2011

How to partitions in a hard disk using fdisk

Listing Details of the Hard Disks

[root@RHEL01 ~]# fdisk -l Disk /dev/sda: 999.6 GB, 999653638144 bytes 255 heads, 63 sectors/track, 121534 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 * 1 64 514048+ 83 Linux /dev/sda2 65 12812 102398310 83 Linux /dev/sda3 12813 19186 51199155 82 Linux swap / Solaris /dev/sda4 19187 121534 822110310 5 Extended /dev/sda5 19187 25560 51199123+ 83 Linux /dev/sda6 25561 121534 770911123+ 83 Linux Disk /dev/sdb: 999.6 GB, 999653638144 bytes 255 heads, 63 sectors/track, 121534 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sdb1 1 121534 976221823+ 83 Linux

Creating a Partition
For this purpose we need to find out which hard disk that we are going to partitioned. keep in mind that IDE hard disks can be seen as hda, hdb, hdc, etc., as well as SATA or SCSI can be seen as sda, sdb, sdc, etc,.

List your devices.
ll /dev/sd* brw-rw----. 1 root disk 8, 0 Aug 18 18:40 /dev/sda brw-rw----. 1 root disk 8, 1 Aug 18 18:40 /dev/sda1 brw-rw----. 1 root disk 8, 2 Aug 18 18:40 /dev/sda2 brw-rw----. 1 root disk 8, 16 Aug 18 18:40 /dev/sdb brw-rw----. 1 root disk 8, 32 Aug 18 18:40 /dev/sdc brw-rw----. 1 root disk 8, 48 Aug 18 18:40 /dev/sdd

Syntax:
fdisk <device>

# fdisk /dev/sdb WARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c') and change display units to sectors (command 'u'). 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):

The basic fdisk commands you need are:
p print the partition table
n create a new partition
d delete a partition
q quit without saving changes
t change a partition's system id
w write the new partition table and exit

Here we are going to make 4GB partition as first partition. Then 512MB swap space. Then extended partition of  3.5G which has 2GB and 1.5GB. at last we change the partition type (id) to 82 which is Linux swap. The write all to disk and exit.

There are some limitations when it comes to working with partitions. You can have only four partitions to a physical disk—with one exception. If you want to make more than the four, you need to create three primary partitions and one extended partition, although the primary partitions aren’t required for extended partition creation. The extended partition can then hold 11 logical partitions (5–16) on it.

[root@RHEL01 ~]# fdisk /dev/sdb WARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c') and change display units to sectors (command 'u'). Command (m for help): p Disk /dev/sdb: 8589 MB, 8589934592 bytes 255 heads, 63 sectors/track, 1044 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x000896f3 Device Boot Start End Blocks Id System Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-1044, default 1): Using default value 1 Last cylinder, +cylinders or +size{K,M,G} (1-1044, default 1044): +4G Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 2 First cylinder (524-1044, default 524): Using default value 524 Last cylinder, +cylinders or +size{K,M,G} (524-1044, default 1044): +512M Command (m for help): n Command action e extended p primary partition (1-4) e Partition number (1-4): 3 First cylinder (590-1044, default 590): Using default value 590 Last cylinder, +cylinders or +size{K,M,G} (590-1044, default 1044): Using default value 1044 Command (m for help): n Command action l logical (5 or over) p primary partition (1-4) l First cylinder (590-1044, default 590): Using default value 590 Last cylinder, +cylinders or +size{K,M,G} (590-1044, default 1044): +2G Command (m for help): n Command action l logical (5 or over) p primary partition (1-4) l First cylinder (852-1044, default 852): Using default value 852 Last cylinder, +cylinders or +size{K,M,G} (852-1044, default 1044): Using default value 1044 Command (m for help): t Partition number (1-6): 2 Hex code (type L to list codes): 82 Changed system type of partition 2 to 82 (Linux swap / Solaris) Command (m for help): p Disk /dev/sdb: 8589 MB, 8589934592 bytes 255 heads, 63 sectors/track, 1044 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x000896f3 Device Boot Start End Blocks Id System /dev/sdb1 1 523 4200966 83 Linux /dev/sdb2 524 589 530145 82 Linux swap / Solaris /dev/sdb3 590 1044 3654787+ 5 Extended /dev/sdb5 590 851 2104483+ 83 Linux /dev/sdb6 852 1044 1550241 83 Linux Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. [root@RHEL01i sahan]#

Now task is completed and it need to be informed to the OS correctly. The Linux command for this is partprobe (inform the OS and kernel of partition table changes).  man partprobe will give you more details.
 SYNOPSIS:
       partprobe [-d] [-s] [devices...]
partprobe /dev/hdb
You can not found any out put here, it just informed the new partition table to OS.

MABM

Demo: Create MBAM 2.5 users and groups in Active Directory Domain Services Configure MBAM 2.5 Roles for the instance of SQL Server ...