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)

No comments:

Post a Comment

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 ...