Let's start by talking about the use of a disk:
The use of the disk must be formatted, the first to start with a low-level format, that is, dividing tracks, sectors and so on.
Later, you have to partition, create the file system, and then mount (that is, a directory associated to/below as the Access portal).
That is:
Low-level formatting (tracks, sectors)---> Partitioning---> Creating file Systems---> Mounting
Here, by the way, the root partition becomes the root partition (root filesystem), some directories are not independent
Out (such as/etc,/bin,/sbin, etc.)
To access a partition, you do not have to enter it from a directory under the root.
If/var/a/b can say/var on a partition, A is on partition 2nd and B is on partition 3rd.
To access partition 3rd, you need to access partition 1th and then access partition 2nd and then access the partition number 3rd.
So access to a partition is not directly or indirectly from/to the beginning.
Say the device file name of the hard disk device:
IDE, ATA: Starting with HD
SATA: Start with SD
SCSI: Start with SD
USB: Start with SD
A, B, c ..... Used to distinguish different devices under the same type
The IDE is unique and typically has only 2 IDE ports, with two disks per port
IDE: First IDE port: Master, from (HDA HDB)
Second IDE port: Master, Slave (hdc HDD)
1, 2, 3, 4, 5 ..... Used to flag partitions on a disk
Starting from 5 can only be logical partitions
Logical partitions can have multiple, extended partitions can only have one, primary partition up to 4
If you want to add a virtual hard disk, see the bottom picture of this blog post.
Here's the fdisk command:
Fdisk is the partitioning tool for Linux hard drives.
Usage: fdisk [-l] [device name]
Common usage: fdisk-l lists all disk devices and partition tables in the system
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6E/89/wKiom1V-2P3T-rMhAAND3ShzLQc861.jpg "title=" 11.PNG "alt=" Wkiom1v-2p3t-rmhaand3shzlqc861.jpg "/>
The fdisk-l device names the partition table of the device
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6E/85/wKioL1V-2wiSfrOdAAJ9HenfxW4685.jpg "title=" 12.PNG "alt=" Wkiol1v-2wisfrodaaj9henfxw4685.jpg "/>
fdisk device name to partition the device directly
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6E/89/wKiom1V-2f_imptEAAJgSpmLwAg856.jpg "title=" 13.PNG "alt=" Wkiom1v-2f_impteaajgspmlwag856.jpg "/>
M Get help p displays the partition on the current hard disk
Q Do not save exit n Create new partition
W Save exit D Delete a partition
T modify the partition type L displays the supported file system types
The following is a brief demonstration of an operation to create a partition on/dev/sdb
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6E/89/wKiom1V-24OTcPI1AAODAyiKg80093.jpg "title=" 14.PNG "alt=" Wkiom1v-24otcpi1aaodayikg80093.jpg "/>
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6E/89/wKiom1V-27zy6p2VAAJ867P8ViU927.jpg "title=" 15.PNG "alt=" Wkiom1v-27zy6p2vaaj867p8viu927.jpg "/>
An operation that modifies the partition type
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6E/89/wKiom1V-3VDSoktwAAMilksbk-c554.jpg "title=" 1.PNG " alt= "Wkiom1v-3vdsoktwaamilksbk-c554.jpg"/>
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6E/85/wKioL1V-3wqgOdmxAAFLiCuRcc4763.jpg "title=" 2.PNG " alt= "Wkiol1v-3wqgodmxaaflicurcc4763.jpg"/>
Note: The above uses N to create a partition with P and E for selection (p stands for creating primary partition, E for creating extended partition)
Start cylinder can be directly enter
size words: +n (g| m| K)
Be sure to save with W after modifying.
You can use cat/proc/partitions to see if you have synced to the kernel after you modify it
If it is not synchronized to the kernel, it can be restarted, or partx-a the device name .
when deleting a partition, make sure that the partition is not used, to see if the partition is being used,
Can be viewed with df-h.
Create partitions with scripts (using Echo and | )
Add a virtual disk to the Linux host in the VM:
As shown in the right script, note that/DEV/SDB is a blank disk
The result is a 3 primary partition, and the 3rd primary partition is the swap partition.
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6E/84/wKioL1V-1u_DhCyDAABjlbRXNzk714.jpg "title=" 1.PNG " alt= "Wkiol1v-1u_dhcydaabjlbrxnzk714.jpg"/>
Click Add Directly
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6E/89/wKiom1V-1VODNef7AAFrGboJmT0301.jpg "title=" 2.PNG " alt= "Wkiom1v-1vodnef7aafrgbojmt0301.jpg"/>
Here the mouse clicks on the hard drive and then next
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6E/89/wKiom1V-1WDg-JxEAAC_JtDTDII376.jpg "title=" 3.PNG " alt= "Wkiom1v-1wdg-jxeaac_jtdtdii376.jpg"/>
Select the type of disk you want and then next
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6E/89/wKiom1V-1XuiF9WlAAFJ3pGMBxs955.jpg "title=" 4.PNG " alt= "Wkiom1v-1xuif9wlaafj3pgmbxs955.jpg"/>
Just go straight to the next line.
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6E/84/wKioL1V-13zguSEOAAHQetpHE4o931.jpg "title=" 5.PNG " alt= "Wkiol1v-13zguseoaahqetphe4o931.jpg"/>
Set the disk size yourself and then the next step
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6E/84/wKioL1V-16jxXWdHAAHyo7A8Fz4444.jpg "title=" 6.PNG " alt= "Wkiol1v-16jxxwdhaahyo7a8fz4444.jpg"/>
Direct Click to finish
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6E/89/wKiom1V-1jiiNJTwAAEr60k5SL4422.jpg "title=" 7.PNG " alt= "Wkiom1v-1jiinjtwaaer60k5sl4422.jpg"/>
Restart the system at this time
Can be viewed with fdisk-l after reboot
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6E/85/wKioL1V-2I7TcV0XAALKBUd95XE342.jpg "title=" 10.PNG "alt=" Wkiol1v-2i7tcv0xaalkbud95xe342.jpg "/>
Linux file Systems (2)