本文共 2631 字,大约阅读时间需要 8 分钟。
需求:添加一块100M的硬盘并把它永久挂载到/data01上,写出详细的操作步骤
方法一:
[root@localhost ~]# fdisk -l |grep 'sdb'Disk /dev/sdb: 106 MB, 106954752 bytes[root@localhost ~]# fdisk -cu /dev/sdbCommand (m for help): mCommand action …… d delete a partition l list known partition types m print this menu n add a new partition p print the partition table q quit without saving changes w write table to disk and exitCommand (m for help): nCommand action e extended p primary partition (1-4)p Partition number (1-4): 1First sector (2048-208895, default 2048): Using default value 2048Last sector, +sectors or +size{K,M,G} (2048-208895, default 208895): Using default value 208895Command (m for help): pDisk /dev/sdb: 106 MB, 106954752 bytes64 heads, 32 sectors/track, 102 cylinders, total 208896 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x65338ab6 Device Boot Start End Blocks Id System/dev/sdb1 2048 208895 103424 83 LinuxCommand (m for help): wThe partition table has been altered!Calling ioctl() to re-read partition table.Syncing disks.#通知系统/dev/sdb硬盘的磁盘分区表变化了[root@localhost ~]# partprobe /dev/sdb[root@localhost ~]# mkfs.ext4 /dev/sdb1#关闭磁盘分区的自动检查[root@localhost ~]# tune2fs -c 0 -i 0 /dev/sdb1注释:-c 0 count 关闭每挂载多少次进行磁盘检查的功能-i 0 interval 关闭每个180天进行磁盘检查功能[root@localhost ~]# df -hFilesystem Size Used Avail Use% Mounted on/dev/sda3 19G 5.0G 14G 27% /tmpfs 120M 0 120M 0% /dev/shm/dev/sda1 190M 35M 145M 20% /boot[root@localhost ~]# mkdir /data01[root@localhost ~]# mount /dev/sdb1 /data01[root@localhost ~]# df -hFilesystem Size Used Avail Use% Mounted on/dev/sda3 19G 5.0G 14G 27% /tmpfs 120M 0 120M 0% /dev/shm/dev/sda1 190M 35M 145M 20% /boot/dev/sdb1 94M 1.6M 88M 2% /data01[root@localhost ~]# vim /etc/fstab ..../dev/sdb1 /data01 ext4 defaults 0 0第一个0表示:关闭自动备份功能第二个0表示:关闭磁盘自动检查功能
方法二:
使用parted 工具分区(可用于大于2T的数据盘分区),常用参数说明:p[rint] 显示磁盘分区表信息
mklabel 创建磁盘分区表,可用的磁盘分区表为:gpt、msdos(mbr)mkpart 创建分区rm 删除分区 q 退出不保存parted /dev/sdb mklabel gpt yparted /dev/sdb mkpart primary 0 -1 Ignore(全部容量默认给一个分区)parted /dev/sdb ppartprobe /dev/sdbmkfs.ext4 /dev/sdb1 tune2fs -c 0 -i 0 /dev/sdb1/bin/mount /dev/sdb1 /data01/df -hecho "/bin/mount /dev/sdb1 /data01/" >>/etc/rc.local
步骤总结:
1.分区2.通知系统/dev/sdb硬盘的磁盘分区表变化了格式化创建文件系统3.格式化创建文件系统4.关闭磁盘分区的自动检查5.进行磁盘分区挂载6.进行永久挂载(开机自动挂载)转载于:https://blog.51cto.com/12083623/2355463