Linux 挂载磁盘-centos

Linux挂载磁盘

1.查看磁盘信息:fdisk -l

fdisk -l

#磁盘信息
Disk /dev/vda: 42.9 GB, 42949672860 bytes, 83887080 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: 0x000abb0d

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048    83886046    41941999+  83  Linux

#未挂载的新硬盘
Disk /dev/vdb: 214.7 GB, 214748364800 bytes, 419430400 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

2.新硬盘分区:

 fdisk /dev/vdb
 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 0x852c786f.

Command (m for help): n   #输入n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p   #主分区输入p  逻辑分区输入e
Partition number (1-4, default 1): 1  #第1分区,输入1默认值,直接回车
First sector (2048-419428351, default 2048): # 直接回车
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-419428351, default 419428351):  #全部存储直接回车,也可M或m结尾数字(1M=8m)例如分1G空间,输入:+1024m
Using default value 419428351
Partition 1 of type Linux and of size 200 GiB is set

Command (m for help): w  #输入w保存
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 22: Invalid argument.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.

3.查看磁盘信息:fdisk -l

# fdisk -l

Disk /dev/vda: 42.9 GB, 42949672960 bytes, 83886080 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: 0x000abb0d

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048    83886046    41941999+  83  Linux

Disk /dev/vdb: 214.7 GB, 214748364800 bytes, 419430400 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: 0xb8238c52

#####新硬盘分区已经出现。
   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1            2048   419430399   209714176   83  Linux

4.格式化分区:mkfs -t ext4 -c /dev/vdb1

# mkfs -t ext4 -c /dev/vdb1
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
13107200 inodes, 52428544 blocks
2621427 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2199912448
1600 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

Checking for bad blocks (read-only test):  100.00% done, 3:59 elapsed. (0/0/0 errors)
# 完成100%,用时3分59秒,0错误。

done                                                
Allocating group tables: done                           
Writing inode tables: done                           
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
#格式化完成

5.挂载目录

# mkdir /data              			 #新建挂载目录
# mount -t ext4 /dev/vdb1 /data		 #挂载磁盘
# df -l								 #查看分区大小
Filesystem     1K-blocks     Used Available Use% Mounted on
/dev/vda1       41931756 14845260  27086496  36% /
devtmpfs         8112960        0   8112960   0% /dev
tmpfs            8133600        0   8133600   0% /dev/shm
tmpfs            8133600    98672   8034928   2% /run
tmpfs            8133600        0   8133600   0% /sys/fs/cgroup
tmpfs            1626720        0   1626720   0% /run/user/0
/dev/vdb1      206291944    61464 195728388   1% /data
#可以看到已挂载成功,且大小一致

# echo "/dev/vdb1 /data ext4 defaults 0 0" >> /etc/fstab  #重启自动生效

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值