1, Disk partitioning command fdisk
[Email protected] ~]# fdisk-l #查看磁盘分区情况
disk/dev/sda:10.8 GB, 10837518250 bytes
255 heads, Sectors/track, 1305 cylinders
Units = Cylinders of 16065 * 8225280bytes
(The size of this drive is 10.8GB, with 255 magnetic faces, 63 sectors, 1305 magnetic columns (cylinders)
The capacity of each cylinder (magnetic column) is 8225280 bytes=8225.280k (approx.) =8.225280m (approx))
Device Boot Start End Blocks Id System
/DEV/SDA1 * 1 104391 Linux
/dev/sda2 1305 10377990 8e Linux LVM
(ID and system represent the partition type, the ID looks less intuitive, we want to create a partition in Fdisk, we can specify the ID to confirm the partition type, such as 7 for the NTFS partition; This is specified by the parameter "T" in Fdisk.) )
The representation of a hard disk partition: In Linux is represented by hd*x or sd*x:
where * denotes a, B, c ...
In addition x represents the number 1, 2, 3 ...
HD is mostly IDE hard disk; SD is mostly SCSI or removable Storage; boot: Indicates boot partition, in the example above, SDA1 is the boot partition;
Start: Represents a partition starting from the Xcylinder (magnetic column);
End: Represents a partition to the end of the Ycylinder (magnetic column);
disk/dev/sdb:21.4 gb,21474836480 bytes
255 heads, Sectors/track, 2610 cylinders
Units = Cylinders of 16065 * 8225280bytes
Disk/dev/sdb doesn ' t contain a validpartition table
[Email protected] ~]# fdisk/dev/sda #对磁盘sda进行分区
Thenumber of cylinders for this disk was set to 1305.
There isnothing wrong with a, but the is larger than 1024,
and Couldin certain setups cause problems with:
1) Softwarethat runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from the other OSs
(e.g., DOS fdisk, OS/2 fdisk)
(input m can get help information)
Command (M for assist): m ---output help information
Commandaction
A toggle a bootable flag---set the boot partition
b Edit BSD disklabel---editing partition labels
C Toggle the DOS Compatibility flag---switch DOS compatibility mode
D Delete a partition--delete a partition
L list known partition types--list partition types
M Print this menu--help
n Add a new partition--Create a fresh partition
o Create a new empty DOS partition table-Creates a fresh, blank DOS partition table
P Print the partition table---printing partition table
Q Quit without saving changes---Exit Do not save settings
s createa new empty sun Disklabel---to create sun disk labels
T Changea partition ' s system ID---Change the ID of the partition
U changedisplay/entry Units---change the units displayed
V verifythe partition Table---Check validation partition tables
W Write table to disk and exit---save partition table
X Extra functionality (experts only)---extended function
Command (M for help): N (Create a new partition)
Command Action
E Extended
P primary partition (1-4)---Specify partition type E for extended partition P primary partition
P (input p select Create Primary partition)
Partition number (1-4): 1 (to create the first primary partition, which is the later SDA1)---The primary partition can have a maximum of four
First cylinder (1-2610, default 1): 1 ---Set the location of the starting partition
Last cylinder or +size or +sizem or +sizek (1-2610, default 2610):2610
Using The default value 2610 ---Set the location of the end partition
Command (M for help): w ---Save the configuration information just now.
The partition table has been altered!
Calling IOCTL () to re-read partition table.
Syncing disks.
Delete Partition
[Email protected] ~]# Fdisk/dev/sdb
The number of cylinders for this disk isset to 2610.
There is nothing wrong with that, but thisis larger than 1024,
And could in certain setups cause Problemswith:
1) software that runs at boot time (e.g.,old versions of LILO)
2) booting and partitioning software fromother OSs
(e.g., DOS fdisk, OS/2 fdisk)
Command (M for help): D (---D is for deletion and will list the number of partitions on the current disk)
Selected partition 1 (1 is the partition number to be deleted)
Command (M for help): p (---p is represented after deletion, showing disk with several remaining partitions)
disk/dev/sdb:21.4 GB, 21474836480 bytes
255 heads, Sectors/track, 2610 cylinders
Units = Cylinders of 16065 * 8225280bytes
Device Boot Start End Blocks Id System is no longer partitioned.
Command (M for help): W (---w save just the operation and take effect)
The partition table has been altered!
Calling IOCTL () to re-read partition table.
Use the FDISK command to create a partition of a specified size and add a partition
[Email protected] ~]# Fdisk/dev/sdb
The number of cylinders for this disk isset to 2610.
There is nothing wrong with that, but thisis larger than 1024,
And could in certain setups cause Problemswith:
1) software that runs at boot time (e.g.,old versions of LILO)
2) booting and partitioning software fromother OSs
(e.g., DOS fdisk, OS/2 fdisk)
Command (M for help): n---create partition
Command Action
E Extended
P primary partition (1-4)
P Input P--Specify partition type as primary partition
Partition number (1-4): 1--Specify the actually partition
First cylinder (1-2610, default 1): 1--Specify the starting cylinder number
Last cylinder or +size or +sizem or +sizek (1-2610, default 2610): 1024x768---Specify terminating cylinder number
Command (M for help): w---Save partition configuration information
The partition table has been altered!
Calling IOCTL () to re-read partition table.
Warning:re-reading the partition tablefailed with error 16:device or resource busy.
The kernel still uses the old table.
The new table is used at the Nextreboot.
Syncing disks.
Add partition
[[email protected] ~]# FDISK/DEV/SDB-----Add partition
The number of cylinders for this disk isset to 2610.
There is nothing wrong with that, but thisis larger than 1024,
And could in certain setups cause Problemswith:
1) software that runs at boot time (e.g.,old versions of LILO)
2) booting and partitioning software fromother OSs
(e.g., DOS fdisk, OS/2 fdisk)
Command (M for help): N---partition type
Command Action
E Extended
P primary partition (1-4)---or specify primary partition
P
Partition number (1-4): 1---partition, I specify 1.
Partition 1is already defined. Delete it beforere-adding it.
– Prompt for partition number 1 already exists, post-deletion action
Command (M for help): N--we re-create the partition
Command Action
E Extended
P primary partition (1-4)--Specify partition type
P
Partition number (1-4): 2---Since partition 1 already exists, we specify Partition 2, which can be passed.
First cylinder (1025-2610, default 1025):---Specify the starting drains bar number, which defaults to the last partition number.
Using Default Value 1025
Last cylinder or +size or +sizem or +sizek (1025-2610, Default 2610): 2000 Specifies the terminating bar number.
Command (M for help): W---Save partition configuration
The partition table has been altered!
Calling IOCTL () to re-read partition table.
Warning:re-reading the partition tablefailed with error 16:device or resource busy.
The kernel still uses the old table.
The new table is used at the Nextreboot.
Syncing disks.
[Email protected] ~]#
To modify an existing partition type by using the FDISK command
FDISK uses the t parameter to specify
View partition type
[[email protected] ~]# fdisk-l/DEV/SDB View partition information, type is Linux,id is 83
disk/dev/sdb:21.4 GB, 21474836480 bytes
255 heads, Sectors/track, 2610 cylinders
Units = Cylinders of 16065 * 8225280bytes
Device Boot Start End Blocks Id System
/DEV/SDB1 1 1024x768 8225248+ Linux
/DEV/SDB2 1025 7839720 Linux
To modify a partition type
[Email protected] ~]# Fdisk/dev/sdb
The number of cylinders for this disk isset to 2610.
There is nothing wrong with that, but thisis larger than 1024,
And could in certain setups cause Problemswith:
1) software that runs at boot time (e.g.,old versions of LILO)
2) booting and partitioning software fromother OSs
(e.g., DOS fdisk, OS/2 fdisk)
Command (M for help): t---Enter modify partition type
Partition number (1-4): 1---Specify the partition numbers you want to modify
Hex code (type L tolist codes): 6---The specified partition number is 6, which is FAT16
Note: View the code for the partition type, where you can enter L to view it.
Changed system type of partition 1 to 6 (FAT16)
Command (M for help): W---Save
The partition table has been altered!
Calling IOCTL () to re-read partition table.
Warning:re-reading the partition tablefailed with error 16:device or resource busy.
The kernel still uses the old table.
The new table is used at the Nextreboot.
Warning:if you have created or Modifiedany DOS 6.x
partitions, please see the Fdisk manualpage for additional
Information.
Syncing disks.
[Email protected] ~]# fdisk-l/dev/sdb--we've seen FAT16, and the ID has been changed to 6 .
disk/dev/sdb:21.4 GB, 21474836480 bytes
255 heads, Sectors/track, 2610 cylinders
Units = Cylinders of 16065 * 8225280bytes
Device Boot Start End Blocks Id System
/DEV/SDB1 1 8225248+ 6 FAT16
/DEV/SDB2 1025 7839720 Linux
[Email protected] ~]#
MKFS to format a partition :
The command to format the partition is as follows, and MKFS is followed by the file system type that will be formatted:
Mkfs.bfs
Mkfs.ext3
Mkfs.ext4
Mkfs.jfs
Mkfs.msdos
Mkfs.vfat
Mkfs.cramfs
Mkfs.minix
Mkfs.reiserfs
Mkfs.xfs
To format a partition:
[[email protected] ~]# MKFS.EXT4/DEV/SDB1---format partition type to EXT4
Mke4fs 1.41.5 (23-apr-2009)
Filesystem label=---We did not specify the label, there is no
OS type:linux---operating system type
Block size=4096 (log=2)--the size of a single block
Fragment size=4096 (log=2)--Sheet size
1310720 Inodes, 5241198blocks
262059 blocks (5.00%) reserved for the Super user
First Data block=0
Maximum filesystem blocks=0
Block groups
32768 blocks per group, 32768fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912,819200, 884736, 1605632, 2654208,
4096000
Writing Inode Tables:done
Creating Journal (32768blocks): Done
Writing superblocks Andfilesystem Accounting Information:done
This filesystem'll beautomatically checked every mounts or
Whichever comesfirst. Use Tune4fs-c or-i to override.
Mount Mount Disk: (Temporary mount)
[[email protected] ~]# Mkdir/data--Create mount Directory point
[[email protected] ~]# mount/dev/sdb1/data--Mount/DEV/SDB1 to/data
Verify that the mount is successful
[Email protected] ~]# df-h
Filesystem Size used Avail use% mounted on
/dev/mapper/volgroup00-logvol00
7.7G 3.1G 4.2G 43%/
/DEV/SDA1 99M 12M 82M 13%/boot
Tmpfs 506M 0 506M 0% Dev/shm
/dev/sdb1 20G 16K 20G 1%/data--has been mounted successfully .
[Email protected] ~]#
Modifying the Fstab table Mount disk (permanent mount)
Edit the/etc/fstab file with the Vim editor, as follows (the red part is just added):
Mount path mount partition file system mount parameter whether to back up the self-test order
/DEV/VOLGROUP00/LOGVOL00/EXT3 Defaults 1 1
Label=/boot/boo ext3 Defaults 1 2
TMPFS/DEV/SHM TMPFS Defaults 0 0
Devpts/dev/pts devpts gid=5,mode=620 0 0
Sysfs/sys Sysfs Defaults 0 0
PROC/PROC proc Defaults 0 0
/dev/volgroup00/logvol01swap Swap Defaults 0 0
/DATA/DEV/SDB1 EXT4 Defaults 0 0
After saving execute command mount-a load latest configuration
Fourth Column mount parameter: View by looking at Man Mount
Whether the fifth column is to be backed up: (0 is not backed up, 1 is to be backed up, and generally does not have to be backed up)
The sixth column of the self-test (0 is not self-test, 1 or 2 is to self-test, if the root partition to set 1, the other partition can only be 2)
This article is from the "Practical Linux knowledge and Skills sharing" blog, please be sure to keep this source http://superleedo.blog.51cto.com/12164670/1886547
Linux Disk Management----partition format Mount Fdisk, MKFS, Mount