1、添加完成磁盤后
使用fdisk -l 查看計算機硬盤資源。
出現如下信息:
[root@localhost Desktop]# fdisk -l
Disk /dev/sda: 26.8 GB, 26843545600 bytes, 52428800 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: 0x000a61e6
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 83 Linux
/dev/sda2 1026048 52428799 25701376 8e Linux LVM
Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors <----此處為要操作的磁盤,要管理設備的名稱為 /dev/sdb
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 /dev/mapper/rhel-root: 24.2 GB, 24150802432 bytes, 47169536 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 /dev/mapper/rhel-swap: 2164 MB, 2164260864 bytes, 4227072 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
[root@localhost Desktop]# fdisk /dev/sdb <----進行磁盤分區
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 0x37e3ca7d.
Command (m for help): n <----輸入n,嘗試添加新分區。
Partition type:
p primary (0 primary, 0 extended, 4 free) <----創建主分區
e extended <----創建擴展分區
Select (default p): p <----此處創建主分區
Partition number (1-4, default 1): 1 <----主分區編號1-4,此處默認1
First sector (2048-41943039, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): +5G <----輸入+5G即可創建出一個容量為5G的硬盤分區
Partition 1 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.
[root@localhost Desktop]# partprobe <----partprobe命令手動將分區信息同步到內核
[root@localhost ~]# mkfs <----輸入mkfs雙擊tab鍵
mkfs mkfs.cramfs mkfs.ext3 mkfs.fat mkfs.minix mkfs.vfat
mkfs.btrfs mkfs.ext2 mkfs.ext4 mkfs.gfs2 mkfs.msdos mkfs.xfs
[root@localhost ~]# mkfs.xfs /dev/sdb1 <----選擇mkfs.xfs 格式化
meta-data=/dev/sdb1 isize=256 agcount=4, agsize=327680 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0
data = bsize=4096 blocks=1310720, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
格式化完畢
[root@localhost /]# mkdir /newFS <----創建newFS
[root@localhost /]# mount /dev/sdb1 /newFS/ <----掛載
[root@localhost /]# df -l <----查看本地文件系統
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/rhel-root 23573252 4679212 18894040 20% /
devtmpfs 929800 0 929800 0% /dev
tmpfs 939104 140 938964 1% /dev/shm
tmpfs 939104 9068 930036 1% /run
tmpfs 939104 0 939104 0% /sys/fs/cgroup
/dev/sda1 508588 124220 384368 25% /boot
/dev/sdb1 5232640 32928 5199712 1% /newFS <----已經掛載到newFS