首页 > 系统相关 >Linux基础 - 文件系统 mount挂载

Linux基础 - 文件系统 mount挂载

时间:2023-02-19 07:22:39浏览次数:36  
标签:mount partition bytes dev centos78 Linux 挂载 512 root

 

一、挂载硬盘(不超2T)

1.1 虚拟机新加一块硬盘

 

 1.2  查看新增的硬盘

[root@centos78 ~]# fdisk -l

Disk /dev/sda: 42.9 GB, 42949672960 bytes, 83886080 sectors  # 原有的40G盘 
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: 0x000b63e0

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200    83886079    40893440   8e  Linux LVM

Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors   # 新增20G硬盘, 盘符为/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

  

[root@centos78 ~]#  lsblk
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda               8:0    0   40G  0 disk
├─sda1            8:1    0    1G  0 part /boot
└─sda2            8:2    0   39G  0 part
  ├─centos-root 253:0    0   37G  0 lvm  /
  └─centos-swap 253:1    0    2G  0 lvm  [SWAP]
sdb               8:16   0   20G  0 disk
sr0              11:0    1  4.5G  0 rom

  

1.3 硬盘分区

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

Command (m for help): m             # 查看帮助
Command action
   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)

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): 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.

  

Disk /dev/sdb: 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
Disk label type: dos
Disk identifier: 0xe3c58cf4

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048    41943039    20970496   83  Linux            # 出现分区盘符

  

 1.4 分区格式化

[root@centos78 ~]# mkfs.
mkfs.btrfs   mkfs.cramfs  mkfs.ext2    mkfs.ext3    mkfs.ext4    mkfs.minix   mkfs.xfs

[root@centos78 ~]# mkfs.xfs /dev/sdb1
meta-data=/dev/sdb1              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

  

1.5 挂载

[root@centos78 ~]# mkdir /data
[root@centos78 ~]# mount /dev/sdb1 /data
[root@centos78 ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
devtmpfs                 475M     0  475M   0% /dev
tmpfs                    487M     0  487M   0% /dev/shm
tmpfs                    487M  7.7M  479M   2% /run
tmpfs                    487M     0  487M   0% /sys/fs/cgroup
/dev/mapper/centos-root   37G  1.5G   36G   4% /
/dev/sda1               1014M  137M  878M  14% /boot
tmpfs                     98M     0   98M   0% /run/user/0
/dev/sdb1                 20G   33M   20G   1% /data

  

1.6 开启自启动挂载

[root@centos78 ~]# blkid
/dev/sda1: UUID="67218b41-d9cc-4aed-b03d-59ffede4be40" TYPE="xfs"
/dev/sda2: UUID="VLE9DP-n2tl-HbKO-QHSb-Hkfl-Y2ul-JEP1Ny" TYPE="LVM2_member"
/dev/sdb1: UUID="1e1bbaac-a773-4c0f-af7e-ed5a3a0d417f" TYPE="xfs"
/dev/sr0: UUID="2020-04-22-00-54-00-00" LABEL="CentOS 7 x86_64" TYPE="iso9660" PTTYPE="dos"
/dev/mapper/centos-root: UUID="7ceacd9a-3cef-42ab-b9a7-50f77ccaeb6e" TYPE="xfs"
/dev/mapper/centos-swap: UUID="6bf5b53d-0b59-4794-bdc2-83ac8d32d6ef" TYPE="swap"

  

[root@centos78 ~]# vi /etc/fstab
UUID=1e1bbaac-a773-4c0f-af7e-ed5a3a0d417f /data                   xfs     defaults        0 0

 

二、 挂载U盘

2.1 保证U盘的格式为fat格式
# cd /mnt
# mkdir usb

2.2 插上U盘,使用fdisk -l,查看是否有新的硬盘添加上。
# fdisk -l

2.3 执行挂载
# mount -t vfat /dev/sdb /mnt/usb

2.4 查看分区
# cd /mnt/usb

标签:mount,partition,bytes,dev,centos78,Linux,挂载,512,root
From: https://www.cnblogs.com/kingdomer/p/9452213.html

相关文章

  • Linux安装
    更详细的可参考基于VirtualBox搭建Linux(CentOS7)虚拟机环境(学习必备技能)-码霸霸(lupf.cn)1.软件VirtualBox官网下载最新的VirtualBox,地址:https://www.virtualbox.o......
  • linux018之安装mysql
    linux上安装mysql:第一步:查看是否已经安装mariadb,mariadb是mysql数据库的分支,mariadb和mysql一起安装会有冲突,所以需要卸载掉。yumlistinstalled|grepmariadb:查看是......
  • docker-数据卷挂载
    docker容器数据卷数据卷也叫:目录挂载即:将容器内的目录,挂载到宿主机为什么要使用数据卷容器的持久化和同步操作!多个容器间也是可以数据共享的,即多个容器可以挂载同......
  • Linux - ethtool 使用方法
    ethtool是用于查询及设置网卡参数的命令。1、安装yum源安装:yuminstallethtool源码包安装:ethtool源码包下载地址:http://ethtool.sourcearchive.com/2、ethtool常......
  • linux 基础(10)进程管理
    使用ps观察程序ps-lps程序可以查询当前在运行的进程信息。ps-l可以列出详细的信息,默认仅列出当前bash相关的进程。sudo-ips-lFSUIDPIDPPIDCP......
  • linux017之安装tomcat
    linux安装Tomcat:一、安装tomcat之前,需要先配置好jdk,不会配置jdk可以看着篇文章:https://www.cnblogs.com/FBGG/p/17133711.html二、下载Tomcat,地址:http://tomcat.apache.......
  • Linux之iptables防火墙
    一、安全技术1.安全技术分类入侵检测系统(IntrusionDetectionSystems):特点是不阻断任何网络访问,量化、定位来自内外网络的威胁情况,主要以提供报警和事后监督为主,提供......
  • linux016之安装JDK
    linux上安装JDK:一:首先检查一下linux上是否已经安装有jdkrpm-qa|grepjdk:查询目前系统已安装的jdk,直接复制该命令执行,如下图就是系统已经安装好的JDK  rpm-qa......
  • Android SELinux 权限问题总结
    SELinuxTE添加权限不生效的解决方法==============================================selinuxsecuritylevel引起的deniedu:r:untrusted_app:s0:c512,c768问题,可以查看:h......
  • Linux USB 文件读写性能测试
    USB端口读写性能测试:========================================================读测试:sync&&echo3>/proc/sys/vm/drop_caches;ddif=/mnt/media_rw/F004-BB9B/file......