fdisk
Realice la partición del disco duro, un método de formateo. Utilice fdisk para realizar la partición principal y la partición extendida en el disco duro. Después de crear una partición extendida, puede crear una partición lógica.
fdisk -l
ver todos los discos duros y particiones del sistema
[root@xxx /gogo]# :fdisk -l
Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000d2163
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 41943039 19921920 8e Linux LVM
fdisk -l partición especificada
Ver la información de la partición especificada
[root@xxx /gogo]# :fdisk -l /dev/sdb6
Disk /dev/sdb6: 5365 MB, 5365563392 bytes, 10479616 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
fdisk Nombre del disco (/ dev / sda) #Cree o modifique la estructura de partición del disco
参数:
p:打印分区表
n:新建一个新分区
d:删除一个分区
m:输出菜单
q:退出不保存
w:把分区写进分区表,保存并退出
Crear una partición primaria
[root@xxx /gogo]# :fdisk /dev/sdc
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0xc2957253.
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-41943039, default 2048): 2048
Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): +10G
Partition 1 of type Linux and of size 10 GiB is set
Command (m for help): W
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
You have new mail in /var/spool/mail/root
Nota: Si se informa un error Dispositivo o recurso ocupado. El núcleo todavía usa la tabla anterior. La nueva tabla se usará en el próximo reinicio. Puede realizar una prueba parcial para resolver o reiniciar.
Crear partición extendida
[root@xxx /gogo]# :fdisk /dev/sdc
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): n
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
Select (default p): e
Partition number (2-4, default 2): 2
First sector (20973568-41943039, default 20973568):
Using default value 20973568
Last sector, +sectors or +size{K,M,G} (20973568-41943039, default 41943039): +5G
Partition 2 of type Extended and of size 5 GiB is set
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
Crear partición lógica
[root@xxx /gogo]# :fdisk /dev/sdc
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): n
Partition type:
p primary (1 primary, 1 extended, 2 free)
l logical (numbered from 5)
Select (default p): l
Adding logical partition 5
First sector (20975616-31459327, default 20975616):
Using default value 20975616
Last sector, +sectors or +size{K,M,G} (20975616-31459327, default 31459327):
Using default value 31459327
Partition 5 of type Linux and of size 5 GiB is set
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
Verifique la información de partición
partprobe
格式:partprobe 磁盘名 #将磁盘的最新分区状况发送给内核
Aviso de advertencia: si se le solicita Dispositivo o recurso ocupado. El núcleo aún usa la tabla anterior. La nueva tabla se utilizará en el próximo reinicio. No es necesario reiniciar para resolver el problema de la ocupación del equipo.
mkfs
Formato: nombre de partición de opción mkfs
-t 文件系统,指定文件系统类型ext3、ext4、xfs。若不指定-t,默认是ext3
mkfs命令非常简单易用,不过不能调整分区的默认参数(比如块大小是4096)
一些文件类型
[root@xxx /gogo]# :mkfs
mkfs mkfs.btrfs mkfs.cramfs mkfs.ext2 mkfs.ext3 mkfs.ext4 mkfs.minix mkfs.xfs
指定sdc2分区为ext4文件格式等...
[root@xxx /gogo]# :mkfs.ext4 /dev/sdc2
[root@xxx /gogo]# :mkfs.xfs /dev/sdc5
Expandir un comando
mke2fs establece el tipo de archivo, el tamaño del bloque y el número de inodo
eg:**mke2fs -t ext4 –b4096 –i4096 /dev/sdb1**
Formato: nombre de partición de opción mke2fs
-t sistema de archivos: especifique qué tipo de sistema de archivos está formateado como ext3, ext4, xfs
-b bytes aún no son compatibles : especifique el tamaño de cada bloque al formatear
-i bytes: especifique cuántas palabras Asigne un número de inodo a la sección
Cuando use -i para especificar el número de inodos de partición, también debe especificar el tamaño del bloque
Pasos para configurar la información del disco
-
Partición primero, dar formato de archivo
-
Crea un punto de montaje
mkdir –p /disk/movie
-
Monte
mount /dev/sdb1 /disk/movie
-
Vista
mount #查看已挂载的所有设备 df -h #查看分区占用百分比
-
Automount- / etc / fstab
Primera columna: nombre de archivo del dispositivo (UUID)
查看UUID的方式: dumpe2fs -h 分区名称 ls –l /dev/disk/by-uuid/ 或者命令blkid
Segunda columna: punto de montaje
Tercera columna: tipo de sistema de archivos
Cuarta columna: opciones especiales de montaje
Quinta columna: si hacer una copia de seguridad: 0 No hacer una copia de seguridad 1 Copia de seguridad diaria # Hacer una copia de seguridad
Sexta columna: Si verificar el estado del disco: 0 No marcar 1 Verificar al inicio 2 Verificar al inicio