码迷,mamicode.com
首页 > 系统相关 > 详细

Linux挂载磁盘

时间:2021-03-04 13:25:41      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:cal   id3   last   linux挂载磁盘   version   dev   group   one   ber   

查看本机的磁盘:

[root@jojo ~]# 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: 0x0008de3e

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048    83884031    41940992   83  Linux

Disk /dev/vdb: 21.5 GB, 21474836480 bytes, 41943040 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@jojo ~]#

创建分区

[root@jojo ~]# 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 0x9dad631d.

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-41943039, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039):
Using default value 41943039
Partition 1 of type Linux and of size 20 GiB is set

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@jojo ~]#

格式化文件系统为xfs

[root@jojo ~]# mkfs.xfs /dev/vdb1
meta-data=/dev/vdb1              isize=512    agcount=4, agsize=1310656 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=5242624, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
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

挂载到 /app 目录

[root@jojo ~]# mount /dev/vdb1 /app
[root@jojo ~]# df -hl
Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1        40G   11G   28G  28% /
devtmpfs        481M     0  481M   0% /dev
tmpfs           496M     0  496M   0% /dev/shm
tmpfs           496M  984K  495M   1% /run
tmpfs           496M     0  496M   0% /sys/fs/cgroup
tmpfs           100M     0  100M   0% /run/user/0
/dev/vdb1        20G   33M   20G   1% /app

添加到 fstab 文件实现开机自动挂载

[root@jojo ~]# echo "$(blkid /dev/vdb1 | awk -F‘"‘ {print "UUID="$2}) /app         xfs    defaults   1 1 " >>/etc/fstab
[root@jojo ~]# cat /etc/fstab
# /etc/fstab
# Created by anaconda on Fri Aug 18 03:51:14 2017
#
# 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
#
UUID=59d9ca7b-4f39-4c0c-9334-c56c182076b5 /                       ext4    defaults        1 1
UUID=48daa1b3-518f-48da-95bf-9ca8def5e475 /app         xfs    defaults   1 1
[root@jojo ~]#

至此配置完毕。

 

Linux挂载磁盘

标签:cal   id3   last   linux挂载磁盘   version   dev   group   one   ber   

原文地址:https://www.cnblogs.com/rexlee/p/14477876.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!