Linux添加硬盘设备

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

转载于:https://www.cnblogs.com/Azaimer/p/10749221.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值