installation the first step in Linux is to create a disk system , and the creation of a system is divided into two main steps :
1. Create the partition , 2. creating a file system
To Create a partition :
Common three commands fdisk,parted
fdisk: It's the most common.
Limitations :
1. Fdisk does not support GPT disks , which means that it cannot partition partitions larger than 2T ( for example )
2. dividing up to a maximum of six partitions
# FDISK/DEV/SDB Warning:invalid flag 0x0000 of partition table 4 Willbe corrected by W (rite) warning:the size of this D ISK is 5.9 TB (5908688535552bytes). DOS partition table format can is used on drivesfor volumeslarger than (2199023255040 bytes) for 512-byte sectors. Use parted (1) and guidpartition table format (GPT).
If you need to divide a partition larger than 2T, you need to use the command parted the following is an introduction
We use the following example to divide a new partition and introduce some common parameters
Check that there is a recognized disk on the system , and use the grep command to filter all disk information .
[[Email protected]~]# fdisk-l | grep "disk/dev/sd.*" disk/dev/sda:53.7 GB, 53687091200 bytesdisk/dev/sdb:21.5 GB, 21474836480 bytes
2. Select the hard disk you want to partition
[Email protected] ~]# fdisk/dev/sdb warning:dos-compatible mode is deprecated. It ' sstrongly recommended to switchoff the mode (command ' C ') and change display units to sectors (command ' U '). Command (M for help):
3. by command N ( create a new partition ), 4 ( select partition ), +500m ( This partition size is 500M), W ( Store and exit )
in the input w before you can use p if not satisfied can be directly q exit without saving .
command (m for help): ncommand action e extended p primary partition (1-4) Pselected partition 4first cylinder (147-2610, default 147): 4value out of range. first cylinder (147-2610, default 147):using default value 147last cylinder, +cylinders or +size{k,m,g} (147-2610,default 2610): +500M Command (M FOR HELP): wthe partition table has been altered! Calling ioctl () to re-read partition table. warning: re-reading the partition table failed witherror 16: device or resource busy. The kernel still uses the old table. the new table willbe used atthe next reboot oR after you run partprobe (8) orkpartx (8) syncing disks.
Parted command
View all current partitions
[[Email protected] ~]# parted /dev/sdbgnu parted 2.1using /dev/sdbwelcome to GNU Parted! Type ' Help ' to view a list ofcommands. (parted) print Model: VMware, VMware Virtual S (SCSI ) disk /dev/sdb: 21.5gbsector size (logical/physical): 512b/512bpartition table: msdos number start end size type File system Flags 1 32.3kb 115mb 115mb primary ext4 2 115mb 658mb 543MB primary ext4 3 658MB 1201mb 543mb primary ext3 4 1201mb 1736mb 535mb primary
Change the display unit to TB
(parted) Unit TB
when formatting, be sure to print out The first step, so you know where to start formatting .
(parted) mkpartfs warning: you are attempting to use parted to operate on (mkpartfs) a file system.parted ' s file system Manipulation code is not as robustas what you ' ll find indedicated , file-system-specific packages likee2fsprogs. we recommendyou use Parted only to manipulate partition tables,whenever possible. support for performing most operations on most types offile Systemswill be removed in an&nbsP;upcoming release. partition type? primary/extended? primary File system type? [ext2]? Start? 17367End? 18367 &nBsp Warning: warning: the kernel failed to re-read thepartition table on /dev/sdb (device or resourcebusy). as aresult, it may not reflect all of your changes until after reboot.
Create a file system ,
we can choose to format different file types with –t ext2 ext3
[Email protected] ~]# mke2fs-t EXT4/DEV/SDB3
Linux Disk Management