磁盘挂载方法 fdisk parted

1创建磁盘分区

[root@web01 ~]# fdisk -cu /dev/sdc    
-c 关闭dos兼容模式
-u 使用扇区进行分区 (默认位柱面)
[root@web01 ~]# partprobe /dev/sdc   更新分区表
[root@web01 ~]# fdisk -l |grep sdc   查看分区表
Disk /dev/sdc: 1073 MB, 1073741824 bytes
/dev/sdc1 2 1886 1047552 83 Linux


2格式化磁盘与磁盘检查设置

[root@web01 ~]# mkfs.ext4 /dev/sdc1         使用EXT4文件系统格式进行磁盘格式化       
[root@web01 ~]# tune2fs -c 0 -i 0 /dev/sdc1   取消磁盘自动检测   0 取消检测  1 进行检测
     -c   每挂载多少次后进行磁盘检查功能
     -i   每隔180天进行磁盘检测  

3挂载磁盘到系统   (使用df-h 确认是否挂载有冲突)

[root@web01 ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda3       8.6G  2.2G  6.0G  27% /
tmpfs           1.9G     0  1.9G   0% /dev/shm
/dev/sda1       190M   40M  141M  22% /boot
[root@web01 ~]# mount /dev/sdc1 /data     把磁盘挂载到/data  

4进行永久挂载

方法一: 直接写入rc.local 文件中实现开机挂在

[root@web01 ~]# vim /etc/rc.local      
    bin/mount   /dev/sdc1   /date

方法二:写入fstabl 中实现开机挂载

[root@web01 ~]# vim /etc/fstab 
/dev/sdc1               /data                   ext4    defaults        0     0     
  磁盘           挂载点           文件类型  挂载参数  是否磁盘备份  是否进行检测

parted 创建分区

[root@web01 ~]# parted /dev/sdd
GNU Parted 2.1
Using /dev/sdd
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p          显示分区别                                                        
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdd: 107MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt   

Number  Start   End     Size    File system  Name     Flags
 1      17.4kB  50.0MB  50.0MB               primary
 2      50.0MB  107MB   56.9MB               primary
(parted) mklabel gpt  创建分区表
(parted)
mkpart primary 0 100   创建磁盘 0-100M (默认Mb)

 创建与删除分区 (注意此模式直接生效无需W保存退出)

(parted) mkpart primary  0 50 I   
Warning: The resulting partition is not properly aligned for best performance.
(parted) mkpart primary  50 107
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? I                                                          
(parted) p                                                                
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdd: 107MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start   End     Size    File system  Name     Flags
 1      17.4kB  50.0MB  50.0MB               primary
 2      50.0MB  107MB   56.9MB               primary

(parted) rm 1     删除1号分区                                                           
(parted) p     查看是否删除分区
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdd: 107MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start   End    Size    File system  Name     Flags
 2      50.0MB  107MB  56.9MB               primary

  

原文地址:https://www.cnblogs.com/imp-W/p/10748975.html