1、增加磁盤后查看磁盤是否成功加入
[root@nfs1 autoconf-2.69]# fdisk -l 磁盤 /dev/sdb:107.4 GB, 107374182400 字節,209715200 個扇區 Units = 扇區 of 1 * 512 = 512 bytes 扇區大小(邏輯/物理):512 字節 / 512 字節 I/O 大小(最小/最佳):512 字節 / 512 字節 磁盤 /dev/sda:21.5 GB, 21474836480 字節,41943040 個扇區 Units = 扇區 of 1 * 512 = 512 bytes 扇區大小(邏輯/物理):512 字節 / 512 字節 I/O 大小(最小/最佳):512 字節 / 512 字節 磁盤標簽類型:dos 磁盤標識符:0x0000ee39 設備 Boot Start End Blocks Id System /dev/sda1 * 2048 2099199 1048576 83 Linux /dev/sda2 2099200 41943039 19921920 8e Linux LVM 磁盤 /dev/mapper/centos-root:18.2 GB, 18249416704 字節,35643392 個扇區 Units = 扇區 of 1 * 512 = 512 bytes 扇區大小(邏輯/物理):512 字節 / 512 字節 I/O 大小(最小/最佳):512 字節 / 512 字節 磁盤 /dev/mapper/centos-swap:2147 MB, 2147483648 字節,4194304 個扇區 Units = 扇區 of 1 * 512 = 512 bytes 扇區大小(邏輯/物理):512 字節 / 512 字節 I/O 大小(最小/最佳):512 字節 / 512 字節
2、fdisk /dev/sdb格式化磁盤
[root@nfs1 autoconf-2.69]# fdisk /dev/sdb 歡迎使用 fdisk (util-linux 2.23.2)。 更改將停留在內存中,直到您決定將更改寫入磁盤。 使用寫入命令前請三思。 Device does not contain a recognized partition table 使用磁盤標識符 0xb9792fc6 創建新的 DOS 磁盤標簽。 命令(輸入 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) 命令(輸入 m 獲取幫助):n #選擇n添加新分區 Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): Using default response p 分區號 (1-4,默認 1): 起始 扇區 (2048-209715199,默認為 2048): 將使用默認值 2048 Last 扇區, +扇區 or +size{K,M,G} (2048-209715199,默認為 209715199): 將使用默認值 209715199 分區 1 已設置為 Linux 類型,大小設為 100 GiB 命令(輸入 m 獲取幫助):w #選擇w保存並退出 The partition table has been altered! Calling ioctl() to re-read partition table. 正在同步磁盤。
3、查看分區信息
[root@nfs1 autoconf-2.69]# fdisk -l 磁盤 /dev/sdb:107.4 GB, 107374182400 字節,209715200 個扇區 Units = 扇區 of 1 * 512 = 512 bytes 扇區大小(邏輯/物理):512 字節 / 512 字節 I/O 大小(最小/最佳):512 字節 / 512 字節 磁盤標簽類型:dos 磁盤標識符:0xb9792fc6 設備 Boot Start End Blocks Id System /dev/sdb1 2048 209715199 104856576 83 Linux 磁盤 /dev/sda:21.5 GB, 21474836480 字節,41943040 個扇區 Units = 扇區 of 1 * 512 = 512 bytes 扇區大小(邏輯/物理):512 字節 / 512 字節 I/O 大小(最小/最佳):512 字節 / 512 字節 磁盤標簽類型:dos 磁盤標識符:0x0000ee39 設備 Boot Start End Blocks Id System /dev/sda1 * 2048 2099199 1048576 83 Linux /dev/sda2 2099200 41943039 19921920 8e Linux LVM 磁盤 /dev/mapper/centos-root:18.2 GB, 18249416704 字節,35643392 個扇區 Units = 扇區 of 1 * 512 = 512 bytes 扇區大小(邏輯/物理):512 字節 / 512 字節 I/O 大小(最小/最佳):512 字節 / 512 字節 磁盤 /dev/mapper/centos-swap:2147 MB, 2147483648 字節,4194304 個扇區 Units = 扇區 of 1 * 512 = 512 bytes 扇區大小(邏輯/物理):512 字節 / 512 字節 I/O 大小(最小/最佳):512 字節 / 512 字節
4、查看到sdb1 ;輸入mkfs.ext4將分區格式化為ext4格式:
[root@nfs1 autoconf-2.69]# mkfs.ext4 /dev/sdb1 mke2fs 1.42.9 (28-Dec-2013) 文件系統標簽= OS type: Linux 塊大小=4096 (log=2) 分塊大小=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 6553600 inodes, 26214144 blocks 1310707 blocks (5.00%) reserved for the super user 第一個數據塊=0 Maximum filesystem blocks=2174746624 800 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424, 20480000, 23887872 Allocating group tables: 完成 正在寫入inode表: 完成 Creating journal (32768 blocks): 完成 Writing superblocks and filesystem accounting information: 完成
5、格式完后,最后掛載這個分區,並查看掛載的情況:
[root@nfs1 autoconf-2.69]# mount /dev/sdb1 /nfs/ [root@nfs1 autoconf-2.69]# df -h 文件系統 容量 已用 可用 已用% 掛載點 devtmpfs 1.9G 0 1.9G 0% /dev tmpfs 1.9G 0 1.9G 0% /dev/shm tmpfs 1.9G 12M 1.9G 1% /run tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup /dev/mapper/centos-root 17G 2.2G 15G 13% / /dev/sda1 1014M 193M 822M 19% /boot tmpfs 378M 0 378M 0% /run/user/0 /dev/sdb1 99G 61M 94G 1% /nfs
6、vim /etc/fstab添加開機掛載
# # /etc/fstab # Created by anaconda on Wed Oct 30 09:55:04 2019 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # /dev/mapper/centos-root / xfs defaults 0 0 UUID=7fb7fd5a-c659-4921-a45f-b9f8ca28ca31 /boot xfs defaults 0 0 /dev/mapper/centos-swap swap swap defaults 0 0 /dev/sdb1 /nfs ext4 defaults 0 0