linux挂载u盘及卸载

对于最小化安装的linux来说,其并没有向windows一样的方便的gui界面,所以需要用命令实现u盘的挂载与卸载

1.创建挂载点:

通常情况,挂载点的位置在/mnt目录下

[root@master mnt]# mkdir u

2.查询设备名:

[root@master mnt]# fdisk -l

Disk /dev/sda: 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: 0x000b0bb2

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      616447      307200   83  Linux
/dev/sda2          616448    41943039    20663296   8e  Linux LVM

Disk /dev/mapper/centos-swap: 549 MB, 549453824 bytes, 1073152 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/centos-root: 20.6 GB, 20606615552 bytes, 40247296 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/sdb: 130.0 GB, 130023424000 bytes, 253952000 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: 0x210f72f0

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *        2048   253886463   126942208    7  HPFS/NTFS/exFAT
/dev/sdb2       253886464   253951999       32768   ef  EFI (FAT-12/16/32)

linux会自动为u盘这种即插即用设备自动分配用户名,所以执行fdisk -l命令后多出来的新设备就是u盘设备

3.挂载文件系统mount 参数 设备名 挂载点:

参数
-t fstype	指定挂载文件系统类型,-t auto可以实现自动挂载
-r	只读模式挂载
-w	默认选项,读写模式挂载
-o	设置挂载属性
-a	挂载/etc/fstab文件中记录的设备
[root@master mnt]# mount /dev/sdb1 /mnt/u

4.卸载文件系统umount 设备名/挂载点:

[root@master mnt]# umount /dev/sdb1 	#指定设备名卸载
[root@master mnt]# umount /mnt/u 	#指定挂载点卸载

你可能感兴趣的:(linux,运维,服务器)