Disk partition fdisk, mount

1. The disk partition is divided into a primary partition (primary partion) and extended partitions (extension partion) are two, the number of primary partition and extended partitions and can not exceed four. And the primary partition can be used immediately but can not be partitioned. After the partition must be expanded in order to use another partition, which means that it must also be a secondary partition. So what to go by the expansion of the partition subdivision is it? It is a logical partition (logical partion), Moreover, there is no limit on the number of logical partitions.

In Linux, each hardware device is mapped to a file system for hard disk drives and other IDE or SCSI devices are no exception. Linux various IDE devices assigned to a file composed of hd prefix; and for a variety of SCSI devices, then the file is assigned a prefix consisting of sd.

For ide hard drive identifier "hdx", wherein "hd" indicates the type of device where the partition, this means that the hard disk ide. "X" is the tray number (a substantially disc, b is dependent substantially dish, c is the secondary master disc, d is a secondary slave disk), "" represents the partition, the first four partitions with numbers 1-4 indicate that they are primary or extended partition, logical partitions from 5 beginning. Embodiment, hda3 expressed as a third primary or extended partition on the first hard ide, hdb2 denoted as a second primary or extended partition on the second hard ide. For scsi hard disk is identified as "sdx ~", scsi hard drives with "sd" to indicate the type of device where the partition, and the rest as representation ide hard drive, not to say.

In Linux provide that each hard disk device can have up to four primary partitions (which contains the extended partition) constitute, any one extended partition should occupy a primary partition number, that is, a hard disk, the primary and extended partitions up to a total of It is four.

Linux provides primary partition (or extended partition) numbers 1 to 16 occupies the first four numbers. In an example first IDE hard drive, a primary partition (or extended partition) occupies hda1, hda2, hda3, hda4, hda5 logical partitions occupy 12 to hda16 like numbers.
Therefore, Linux each of the following total of up to 16 hard disk partitions.

IDE hard disk partitions of up to 64
fdisk

[root@ 777 ~]# fdisk /dev/sdb
命令(输入 m 获取帮助):m
   a   toggle a bootable flag	//切换分区激活开关
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition  //删除分区
   g   create a new empty GPT partition table
   G   create an IRIX (SGI) partition table
   l   list known partition types  // 显示分区类型
   m   print this menu      //打印帮助菜单
   n   add a new partition   // 增加一个新分区
   o   create a new empty DOS partition table
   p   print the partition table  //显示分区表
   q   quit without saving changes  // 不保存退出
   s   create a new empty Sun disklabel
   t   change a partition's system id	//改变硬盘分割区属性
   u   change display/entry units
   v   verify the partition table	//进行分区检查
   w   write table to disk and exit   // 保存操作并退出
   x   extra functionality (experts only)	//扩展应用,高级功能
   
Command (m for help): n   ----新建一个分区
Partition type:
   p   primary (2 primary, 0 extended, 2 free)    p:主分区
   e   extended                         e:扩展分区
Select (default p):     --直接默认回车
Using default response p
Partition number (1,4, default 1):   ---直接默认回车
First sector (1230848-41943039, default 1230848):   ---直接默认 回车
Using default value 1230848
Last sector, +sectors or +size{K,M,G} (1230848-41943039, default 41943039):  +5G  //输入分区大小
Partition 3 of type Linux and of size 1 GiB is set
Command (m for help): w   //保存退出
1

1. Disk Management commonly used commands

1.1 ls -i file name to see which files are stored in innode

[root@test6 ~]# ls -i lstest 
 1179659 lstest

1.2 ls -id folder name to view the folders are stored in which innode

[root@test6 ~]# ls -id lstest1
1179661 lstest1

1.3 filefrag -v file name to view file storage block specific location

2. Hard disk tools:

2.1 dumpe2fs / dev / sda1 partition superblock and view details such as blockgroup

2.2 fsck / dev / sda check the hard disk where the display checking process -f -C forced checking
  2.3 badblocks / dev / sda5 check hard disk damage -sv progress and results df view the file system (-h suitable unit shown in system size -T system types) du view folder size, which contains the file folder du -s only view the folder size du -h display size in M mode, for easy viewing

fuser -mv / mnt When the display device is busy, you can use this command to view the process of using tune2fs -l / dev / sda
View disk parameters (-h to see the available options, the option to change)

Automatically mount

[root@ 777 ~]# vim /etc/fstab
/dev/sdb1	/sdb1	xfs	defaults	0	0
[root@ 777 ~]# mount -a	//自动挂载

How to view UUID, UUID mounts

[root@ 777 ~]# blkid	//查看UUID
[root@ 777 ~]# vim /etc/fstab
UUID=015b0dae-1e2c-46db-89e7-6b660ae36175  /sb1 xfs defaults  0 0
第四列:
关于/etc/fstab文件里,第四列文件系统参数
Async /sync : 设置是否为同步方式运行,默认async
auto/noauto : 当执行mount -a的时候,此文件被主动挂载,默认auto
rw/ro :	是否以只读 或者读写方式挂载
exec/noexec: 限制此文件系统是否能够进行执行操作
defaults : 同时具有以上参数的默认参数设置功能,默认参数设置samba nfs

第五列: 是否进行备份, 通常只有0或者1
0: 代表不要做备份
1 : 代表每天进行备份
2: 代表不定期的进行操作
Published 44 original articles · won praise 20 · views 1800

Guess you like

Origin blog.csdn.net/qq_45019159/article/details/104533463