Fdisk can only be used for less than 2T disks, larger than 2T disks need to use the parted tool partition
First, enter the parted
1, Parted/dev/sdb
2. (parted) Print free
Model:lsi megaraid 8708ELP (SCSI)
Disk/dev/sdb:7438gb
Sector size (logical/physical): 512b/512b
Partition TABLE:GPT
Number Start End Size File system Name Flags
17.4kB 7438GB 7438GB Free Space
3, (parted) Mklabel GPT
4, (parted) Mkpart
Partition name? []? Data
File system type? [Ext2]? Ext3
Start? 0kB
End? 7438GB
Warning:you requested a partition from 0.00kB to 7438GB.
The closest location we can manage are 17.4kB to 7438GB. Is this still acceptable?
Yes/no? Yes
5, (parted) quit
Second, format the disk
Mkfs.ext3/dev/sdb
EXT3 cannot format a hard disk more than 8T
Mkfs.ext3-f/dev/sdb ext3 formatted hard drive with more than 8T
Three, mount the hard disk
Four: Command line mode
Parted-s/dev/sd$i RM 1
Parted-s/dev/sd "$i" Mklabel GPT
Parted-s/dev/sd$i Mkpart Primary ext3 1 3001G or parted-s/dev/sd$i Mkpart primary ext3 0% 100%
Parted-s/dev/sd$i Print
The GNU parted directive says
Parted is a very useful program, can be used to cut the disk, you can also change the size of the partition, it is very useful, especially the change partition size of the function super easy to use, as I learned parted reason, is to my/USR expansion (because at the beginning of the split, the USR cut too small). But the internet does not seem to be a complete point of the parted instructions, so I was based on official document, to do the collation, because the younger brother's English is not very good, so I am afraid that some places will be wrong, or someone would like to increase the content of this document, all welcome advice, Thank you!!
GNU parted
The special words in this article say:
Minor (I do not turn, meaning is the partition in parted)
Disk label (disk tag)
Flag (Flags)
Instructions to explain
Check
Usage: Check minor
Stating: Check partition there is no mistake
Cp
Usage: CP [source device] source minor purpose minor
Note: Adding [] can have no parameters.
Explain: Copy the source partition file system to the goal partition, note that after this command, will be the purpose of partition the original material content to clear oh .... Be careful. And that optional source of choice is used in the "cross-device" copy of the system, it is very convenient.
Example:
(parted) Cp/dev/hdb 2 3
It means to copy/DEV/HDB2 's file system to minor 3.
The supported file systems are:
EXT2,EXT3 (The capacity of the purpose partition is greater than the source partition)
Fat16,fat32
Linux-swap
Reiserfs
Help
Usage: Help Instructions
To show a general help, or a help for an instruction
Mklabel
Usage: Mklabel label type
There are some of these types:
Bsd,loop (Raw disk access), GPT, Mac, Msdos, PC98, Sun
Explain: To create a new disk label for the entire disk, this disk does not have any partition when creating a new disk label. , so it is not yet available and must be returned to partition using other programs such as Gpart.
Mkfs
Usage: Mkfs Minor file system type
Say: To create a file system type for a partition, this action will destroy all the information of this partition.
Supported file system types are:
Ext2,mips,fat16,fat32,linux-swap,reiserfs
Example:
(parted) MKFS 2 FAT32
For minor 2, this partition was established as a FAT32 file system type.
Mkpart
Usage: Mkpart partition type [file system type] start end
Say: Mkpart used to build a new partition, the division type has primary,extended,
Logical
Example:
(parted) Mkpart logical 0.0 692.1
Create a logically partition with a capacity of 692.1MB. Note that, because of the different reasons for the magnetic area calculation, perhaps you will produce a slight deviation value when you build the capacity range, but this does not affect the partition.
Mkpartfs
Usage: MKPARTFS partition type file system type starting end
Say: Mkpartfs used to build a new partition and file system.
Example:
(parted) Mkpartfs logical ext2 440 670
Create a ext2 logically partition, starting at 440MB, and ending with 670MB, this partition is 230MB in total.
Move
Usage: Move minor start [end bundle]
Say: You can move the whole partition position. If you give only the starting position, without giving the end position, you will maintain the size of this partition.
Example:
(parted) Move 2 150
Move the minor to 150MB where the partition start position is 2.
Name
Usage: Name minor
SAY: Name for partition (only Mac and PC98 are available).
Example:
(parted) Name 2 ' abc '
Name Partition 2 ABC.
Print
Usage: Print
Stating: Show out the partition table of the disk that parted is working on.
Example:
(parted) Print
Disk Geometry for/dev/hda:0.000-2445.679 Megabytes
Disk label Type:msdos
Minor Start End Type Filesystem Flags
1 0.031 945.000 primary FAT boot, LBA
2 945.000 2358.562 Primary ext2
3 2358.562 2445.187 Primary Linux-swap
Quit
Usage: Quit
Say: Leave parted.
Rescue
Usage: Rescue start end
Explain: Use to save partition that you have accidentally deleted with the RM command.
Example:
(parted) Print
Disk Geometry for/dev/hdc:0.000-8063.507 Megabytes
Disk label Type:msdos
Minor Start End Type Filesystem Flags
1 0.031 8056.032 Primary ext3
(parted) RM
Partition number? 1
(parted) Print
Disk Geometry for/dev/hdc:0.000-8063.507 Megabytes
Disk label Type:msdos
Minor Start End Type Filesystem Flags
Oh my god~~ accidentally cut Ext3 's partition, and this time rescue will be sent to use the field
(parted) Rescue
Start? 0
End? 8056
INFORMATION:A EXT3 Primary partition is found at 0.031Mb
8056.030Mb. Does want to add it to the partition table?
Yes/no/cancel? Y
(parted) Print
Disk Geometry for/dev/hdc:0.000-8063.507 Megabytes
Disk label Type:msdos
Minor Start End Type Filesystem Flags
1 0.031 8056.032 Primary ext3
Hey, come on, save it!!
Resize
Usage: Resize Minor initial end bundle
Explain: Adjust the size of the partion, to note that resize can only change partition size, and can not change the minor, in addition, when you change the size of EXT2,EXT3, the new starting position must be and old one, that is, can only move the tail can not be moved!!
Example:
(parted) Resize 3 200 850
Adjust the 3rd partition from 200MB to 850MB.
Rm
Usage: RM minor
Clear: Remove partition, except if you accidentally lost a partition with the RM command, you can return it with Mkpart. Note that if you now have the number 1~8,8 minor, when you put minor
6 When you cut down, the original minor7 and MINOR8 will move forward to Minor6 and minor7, so when you do remove partition, remember to modify the settings in the/etc/fstab.
Example:
(parted) RM 3
Remove Minor3 this partion.
Select
Usage: Select Device name
SAY: Use it to switch the device directly in the parted.
Example:
(parted) Select/dev/hdb
Swap the processor to the/DEV/HDB
Set
Usage: Set minor flag State (On,off)
To say: Change to a more Partiton flag, state that linked fields is to take to set flag to open or close. Flag has the following kinds: Boot, LBA, root, swap, hidden, RAID, LVM.
Example:
(parted) Set 1 boot on
Set the PARTITION1 flag to boot and open it.
So much so, let's do a few examples to see it!!
Example 1: Increase the size of the partition
If our/DEV/HDA partition is the following:
(parted) Print
Disk Geometry for/dev/hda:0.000-1000.000 Megabytes
Disk label Type:msdos
Minor Start End Type Filesystem Flags
1 0.063 500.000 Primary ext2
2 500.000 625.000 Primary Linux-swap
It can be seen from the above that we have 1000MB of space, Partition1 with 500mb,partition2 to 125MB, and 375MB space can be used, if you want to leave the remaining 375MB space all to partition1 use, Just follow the steps below!!
#parted/dev/hda
Enter parted and select HDA as the operating disk
(parted) RM 2
Remove Partition2. Note: In the general case of adding partition space, there is no need to do the delete action, because the delete activity will destroy the information in the partition. In this case, Partiton2 is Linux-swap,swap and does not save the information, so partiton2 Delete does not affect, we will later build a LINUX-SWAP partition on it.
(parted) Resize 1 0.063 874.9
Adjust the Partition1 position from 0.063 to 874.999, a total of 875MB.
(parted) Print
Disk Geometry for/dev/hda:0.000-1000.000 Megabytes
Disk label Type:msdos
Minor Start End Type Filesystem Flags
1 0.063 874.999 Primary ext2
(parted) Mkpartfs primary Linux-swap 875 999.9
Establish a new Linux-swap partition.
(parted) Print
Disk Geometry for/dev/hda:0.000-1000.000 Megabytes
Disk label Type:msdos
Minor Start End Type Filesystem Flags
1 0.063 874.999 Primary ext2
2 875.000 1000.000 Primary Linux-swap
That's it.
Example 2: Add a partition space that will not be available
Let's pretend our/dev/hda are as follows:
(parted) Print
Disk Geometry for/dev/hda:0-8063.5 Megabytes
Disk label Type:msdos
Minor Start End Type Filesystem Flags
1 0.0 23.5 Primary ext2 Boot
2 23.5 8056.0 Extended
5 23.6 3545.6 Logical ext2
6 3545.6 7067.7 Logical ext2
7 7067.7 7326.5 Logical ext2
8 7326.5 7585.4 Logical ext2
9 7585.4 7844.2 Logical Linux-swap
$ df-h
Filesystem Size used Avail use% mounted on
/dev/hda8 251M 31M 207M 13%/
/DEV/HDA1 23M 2.4M 19M 11%/boot
/dev/hda5 3.4G 577M 2.7G 18%/usr
/dev/hda6 3.4G 289M 2.9G 9%/Home
/dev/hda7 251M 12M 226M 5%/var
If we want to increase the/Var space to 1GB, and where does this want to increase the space?? I got it from/home. Follow the steps below!!
(parted) Resize 6 3545.6 6200
Shrink/home space to 500MB
(parted) Mkpartfs Logicai ext2 6200 7067.7
To build a new partition, this partition will be numbered 10.
(parted) CP 7 10
Copy the contents of partition7 (/var) to the newly created partition10.
(parted) RM 7
Delete Partition 7, to this place, since partition 7 was deleted, so the original Partition8, 9, 10 code moved forward to Partiton 7, 8, 9.
(parted) Resize 9 6200 7326.5
Adjust the Partition9 (new/Var) size to 1G. In this case, the whole partition-sized motion is only half done!! Because we have added partition also have deleted partition, even the parition location of/var has changed, so the last move is to change/etc/fstab!!
The original/etc/fstab content is as follows:
/DEV/HDA8/EXT2 Defaults 1 1
/dev/hda1/boot ext2 Defaults 1 2
/dev/hda6/home ext2 Grpquota,usrquota 0 2
/dev/cdrom/mnt/cdrom iso9660 Noauto,owner,ro 0 0
/DEV/HDA5/USR ext2 Defaults 1 2
/dev/hda7/var ext2 Grpquota,usrquota 0 2
/dev/fd0/mnt/floppy Auto Noauto,owner 0 0
NONE/PROC proc Defaults 0 0
None/dev/pts devpts gid=5,mode=620 0 0
/DEV/HDA9 swap swap defaults 0 0
After the parted, the following changes are done:
/var becomes/dev/hda9.
/Becomes a/DEV/HDA7
Swap becomes/dev/hda8.
So the modified/etc/fstab are as follows:
/DEV/HDA7/EXT2 Defaults 1 1
/dev/hda1/boot ext2 Defaults 1 2
/dev/hda6/home ext2 Grpquota,usrquota 0 2
/dev/cdrom/mnt/cdrom iso9660 Noauto,owner,ro 0 0
/DEV/HDA5/USR ext2 Defaults 1 2
/dev/hda9/var ext2 Grpquota,usrquota 0 2
/dev/fd0/mnt/floppy Auto Noauto,owner 0 0
NONE/PROC proc Defaults 0 0
None/dev/pts devpts gid=5,mode=620 0 0
/DEV/HDA8 swap swap defaults 0 0
More than 2T of disk formatting