需求:添加一塊100M的硬盤並把它永久掛載到/data01上,寫出詳細的操作步驟
方法一:
[root@localhost ~]# fdisk -l |grep 'sdb'
Disk /dev/sdb: 106 MB, 106954752 bytes
[root@localhost ~]# fdisk -cu /dev/sdb
Command (m for help): m
Command 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 exit
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First sector (2048-208895, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-208895, default 208895):
Using default value 208895
Command (m for help): p
Disk /dev/sdb: 106 MB, 106954752 bytes
64 heads, 32 sectors/track, 102 cylinders, total 208896 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 identifier: 0x65338ab6
Device Boot Start End Blocks Id System
/dev/sdb1 2048 208895 103424 83 Linux
Command (m for help): w
The 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 -h
Filesystem 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 -h
Filesystem 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 y
parted /dev/sdb mkpart primary 0 -1 Ignore(全部容量默認給一個分區)
parted /dev/sdb p
partprobe /dev/sdb
mkfs.ext4 /dev/sdb1
tune2fs -c 0 -i 0 /dev/sdb1
/bin/mount /dev/sdb1 /data01/
df -h
echo "/bin/mount /dev/sdb1 /data01/" >>/etc/rc.local
步驟總結:
1.分區
2.通知系統/dev/sdb硬盤的磁盤分區表變化了格式化創建文件系統
3.格式化創建文件系統
4.關閉磁盤分區的自動檢查
5.進行磁盤分區掛載
6.進行永久掛載(開機自動掛載)