Disk partitions under Linux, and create a file system (theoretical and practical)

First, let's look at the principle disk

Disk data structures are:

Sector: the disc area is divided into a plurality of sectors, each sector of 512 bytes of data storage

Track: a disk with concentric circles of different radii

Cylindrical: cylindrical surface of different radius of the disk made of the same

official:

Disk storage capacity x = number of heads tracks (cylinders) x the number of sectors per track Number of bytes per sector x

----------------------------------------

General disk interface is divided into IDE SATA SCSI IDE

IDE (parallel port), SATA (serial interface), SCSI (typically a server)

Partition table recording area of ​​four partitions, each partition representing recording region 16 bytes


Linux partition in the hard disk device and the like are expressed as a file
/ dev / hda5 hd Representative Sd represent the SCSI devices IDE device A represents a hard disk sequence number to a sequence number of letters abc 5 to figures represent the partitions 12345

 

Standard partition partition is generally divided into logical partitions extended partition

Standard and Extended partitions can only be 1-4 

Logical partition starts 55- *

CentOS7 default file system is XFS CentOS6 is ext3 is ext4 CentOS5

SWAP = swap file system

Other Linux file system types supported: FAT16 FAT32 NTFS EXT4 JFS

------------------- theory on here, let's begin combat --------------------- ------

Adding a disk

I add a disk in VM Workstation for testing combat

 fdisk -l // List all disks

View all Disk

Just insert a 10G hard drive is so we should operate this drive sdb (above theory has sdb say what it means -sd = sata b = a second hard drive)

Enter the disk

fdisk / dev / sdb // into this disk

In it you can enter m to get help

m -> Get Help
p -> Print partition table
n -> add a new partition -> p (primary partition 1-4) e (extended partition 5- *) + 1G = set size 1G - -> l logical partitions Note: the extended partition can not be directly used, can be extended partition to create logical partitions -> t (change type) -L list all (83 for Linux the default)
d -> delete partition configuration
q -> exit without saving
w -> save and exit

So we enter the partition n

Create a partition // where p is a standard partition is an extended partition e

Create a partition size 1G

So we created a partition size 1G

Note: e extended partition is if you want to create logical partitions must first create an extended partition and then in the extended partition to create logical partitions (extended partition can not be used directly)

After you create the partition, the partition can not be used directly we need to

mkfs command Make Filesystem, create a file system (format) 
EG: mkfs -t type of file system partition device 
such as we have just created a partition formatted as xfs types
mkfs -t xfs / dev / sdb1

You then need to mount this disk

mount / dev / sdb1 / need a place to mount 
umount / dev / sdb1 - unmounted

This completes the zoning friends

Note: mount This command is temporary shutdown restart Should the failure to mount

To permanently save mount words

vi / etc / fstab // into the configuration file

Disk Configuration File

/ Dev / sdb1 = partition to mount / media = mount directory after the type xfs xfs = default does not go into the details of the general

Then after saving exit

mount -a // refresh mount

carry out!

 

Guess you like

Origin www.cnblogs.com/laopa/p/11733245.html