1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > Centos7系统挂载U盘和移动硬盘

Centos7系统挂载U盘和移动硬盘

时间:2019-04-25 18:48:11

相关推荐

Centos7系统挂载U盘和移动硬盘

Centos7系统挂载U盘和移动硬盘

查看系统版本

[root@localhost ~]# cat /etc/redhat-release CentOS Linux release 7.4.1708 (Core)

查看系统分区情况

[root@localhost ~]# df -Th文件系统类型容量 已用 可用 已用% 挂载点/dev/mapper/centos-root xfs 17G 1.6G 16G 10% /devtmpfsdevtmpfs 478M0 478M 0% /devtmpfs tmpfs489M0 489M 0% /dev/shmtmpfs tmpfs489M 6.7M 482M 2% /runtmpfs tmpfs489M0 489M 0% /sys/fs/cgroup/dev/sda1xfs1014M 125M 890M 13% /boottmpfs tmpfs98M0 98M 0% /run/user/0

查看机器硬盘个数及分区情况

[root@localhost ~]# fdisk -l磁盘 /dev/sda:21.5 GB, 21474836480 字节,41943040 个扇区Units = 扇区 of 1 * 512 = 512 bytes扇区大小(逻辑/物理):512 字节 / 512 字节I/O 大小(最小/最佳):512 字节 / 512 字节磁盘标签类型:dos磁盘标识符:0x000b2bce设备 BootStart EndBlocks Id System/dev/sda1 * 204820991991048576 83 Linux/dev/sda2 2099200 41943039 19921920 8e Linux LVM磁盘 /dev/mapper/centos-root:18.2 GB, 18249416704 字节,35643392 个扇区Units = 扇区 of 1 * 512 = 512 bytes扇区大小(逻辑/物理):512 字节 / 512 字节I/O 大小(最小/最佳):512 字节 / 512 字节磁盘 /dev/mapper/centos-swap:2147 MB, 2147483648 字节,4194304 个扇区Units = 扇区 of 1 * 512 = 512 bytes扇区大小(逻辑/物理):512 字节 / 512 字节I/O 大小(最小/最佳):512 字节 / 512 字节

插入U盘或者移动硬盘

[root@localhost ~]# fdisk -l磁盘 /dev/sda:21.5 GB, 21474836480 字节,41943040 个扇区Units = 扇区 of 1 * 512 = 512 bytes扇区大小(逻辑/物理):512 字节 / 512 字节I/O 大小(最小/最佳):512 字节 / 512 字节磁盘标签类型:dos磁盘标识符:0x000b2bce设备 BootStart EndBlocks Id System/dev/sda1 * 204820991991048576 83 Linux/dev/sda2 2099200 41943039 19921920 8e Linux LVM磁盘 /dev/mapper/centos-root:18.2 GB, 18249416704 字节,35643392 个扇区Units = 扇区 of 1 * 512 = 512 bytes扇区大小(逻辑/物理):512 字节 / 512 字节I/O 大小(最小/最佳):512 字节 / 512 字节磁盘 /dev/mapper/centos-swap:2147 MB, 2147483648 字节,4194304 个扇区Units = 扇区 of 1 * 512 = 512 bytes扇区大小(逻辑/物理):512 字节 / 512 字节I/O 大小(最小/最佳):512 字节 / 512 字节磁盘 /dev/sdb:7747 MB, 7747397632 字节,15131636 个扇区#可以看到这个是刚刚多出来的U盘信息Units = 扇区 of 1 * 512 = 512 bytes扇区大小(逻辑/物理):512 字节 / 512 字节I/O 大小(最小/最佳):512 字节 / 512 字节磁盘标签类型:dos磁盘标识符:0x00f9614f设备 BootStart EndBlocks Id System/dev/sdb1 * 2048 151316357564794 c W95 FAT32 (LBA)#多出来的U盘信息

创建挂载点并挂载

[root@localhost ~]# pwd/root[root@localhost ~]# mkdir /udisk[root@localhost ~]# ll /udisk/总用量 0[root@localhost ~]# mount -t vfat /dev/sdb1 /udisk/[root@localhost ~]# ll /udisk/总用量 688-rwxr-xr-x 1 root root 34494 8月 11 00:02 autorun.ico-rwxr-xr-x 1 root root 202 8月 11 00:02 autorun.inf-rwxr-xr-x 1 root root14 8月 10 23:22 CentOS_BuildTagdrwxr-xr-x 3 root root 4096 8月 10 23:22 EFI-rwxr-xr-x 1 root root 227 8月 10 23:22 EULA-rwxr-xr-x 1 root root 18009 8月 10 23:22 GPLdrwxr-xr-x 3 root root 4096 8月 10 23:22 imagesdrwxr-xr-x 2 root root 4096 8月 10 23:22 isolinux-r-xr-xr-x 1 root root 37512 8月 10 23:22 ldlinux.sysdrwxr-xr-x 2 root root 4096 8月 10 23:23 LiveOSdrwxr-xr-x 2 root root 552960 8月 10 23:25 Packagesdrwxr-xr-x 2 root root 4096 8月 11 00:02 repodata-rwxr-xr-x 1 root root 1690 8月 11 00:02 RPM-GPG-KEY-CentOS-7-rwxr-xr-x 1 root root 1690 8月 11 00:02 RPM-GPG-KEY-CentOS-Testing-7-rwxr-xr-x 1 root root94 8月 11 00:02 syslinux.cfgdrwxr-xr-x 2 root root 4096 8月 10 23:22 System Volume Information-rwxr-xr-x 1 root root 2883 8月 11 00:02 TRANS.TBL[root@localhost ~]# df -Th文件系统类型容量 已用 可用 已用% 挂载点/dev/mapper/centos-root xfs 17G 1.6G 16G 10% /devtmpfsdevtmpfs 478M0 478M 0% /devtmpfs tmpfs489M0 489M 0% /dev/shmtmpfs tmpfs489M 6.7M 482M 2% /runtmpfs tmpfs489M0 489M 0% /sys/fs/cgroup/dev/sda1xfs1014M 125M 890M 13% /boottmpfs tmpfs98M0 98M 0% /run/user/0/dev/sdb1vfat7.2G 4.3G 3.0G 59% /udisk#这个就是我们挂载的U盘

测试挂载的U盘能否写入数据

[root@localhost ~]# cd /udisk/[root@localhost udisk]# touch 123.txt[root@localhost udisk]# ll总用量 688-rwxr-xr-x 1 root root0 12月 9 17:41 123.txt-rwxr-xr-x 1 root root 34494 8月 11 00:02 autorun.ico-rwxr-xr-x 1 root root 202 8月 11 00:02 autorun.inf-rwxr-xr-x 1 root root14 8月 10 23:22 CentOS_BuildTagdrwxr-xr-x 3 root root 4096 8月 10 23:22 EFI-rwxr-xr-x 1 root root 227 8月 10 23:22 EULA-rwxr-xr-x 1 root root 18009 8月 10 23:22 GPLdrwxr-xr-x 3 root root 4096 8月 10 23:22 imagesdrwxr-xr-x 2 root root 4096 8月 10 23:22 isolinux-r-xr-xr-x 1 root root 37512 8月 10 23:22 ldlinux.sysdrwxr-xr-x 2 root root 4096 8月 10 23:23 LiveOSdrwxr-xr-x 2 root root 552960 8月 10 23:25 Packagesdrwxr-xr-x 2 root root 4096 8月 11 00:02 repodata-rwxr-xr-x 1 root root 1690 8月 11 00:02 RPM-GPG-KEY-CentOS-7-rwxr-xr-x 1 root root 1690 8月 11 00:02 RPM-GPG-KEY-CentOS-Testing-7-rwxr-xr-x 1 root root94 8月 11 00:02 syslinux.cfgdrwxr-xr-x 2 root root 4096 8月 10 23:22 System Volume Information-rwxr-xr-x 1 root root 2883 8月 11 00:02 TRANS.TBL[root@localhost udisk]#

将挂载的信息写入配置中

若要长期挂载还需要将挂载信息写入配置中

不填写分区表信息,系统重启后不会自动挂载,我们挂载就会失效。

[root@localhost udisk]# vim /etc/fstab # /etc/fstab# Created by anaconda on Wed Aug 22 19:27:55 ## 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#/dev/mapper/centos-root / xfsdefaults 0 0UUID=6ca7a7f6-84fe-427d-8e72-1a7dbbe4e877 /boot xfsdefaults 0 0/dev/mapper/centos-swap swapswap defaults 0 0/dev/sdb1 /udisk vfat defaults 0 0#这一行就是我们写入的配置信息[root@localhost udisk]# df -Th文件系统类型容量 已用 可用 已用% 挂载点/dev/mapper/centos-root xfs 17G 1.6G 16G 10% /devtmpfsdevtmpfs 478M0 478M 0% /devtmpfs tmpfs489M0 489M 0% /dev/shmtmpfs tmpfs489M 6.7M 482M 2% /runtmpfs tmpfs489M0 489M 0% /sys/fs/cgroup/dev/sda1xfs1014M 125M 890M 13% /boottmpfs tmpfs98M0 98M 0% /run/user/0/dev/sdb1vfat7.2G 4.3G 3.0G 59% /udisk

如果只是使用一次,则不需要执行上一步。用完直接卸载即可。

卸载临时挂载

[root@localhost /]# umount /udisk [root@localhost /]# df -Th文件系统类型容量 已用 可用 已用% 挂载点/dev/mapper/centos-root xfs 17G 1.6G 16G 10% /devtmpfsdevtmpfs 478M0 478M 0% /devtmpfs tmpfs489M0 489M 0% /dev/shmtmpfs tmpfs489M 6.7M 482M 2% /runtmpfs tmpfs489M0 489M 0% /sys/fs/cgroup/dev/sda1xfs1014M 125M 890M 13% /boottmpfs tmpfs98M0 98M 0% /run/user/0

卸载长期挂载

卸载之前长期挂载的磁盘,除了要进行上一步的卸载之外,还要到配置中去删除相应的配置信息。如果不这么做,下次重启机器有可能无法启动。

[root@localhost udisk]# vim /etc/fstab # /etc/fstab# Created by anaconda on Wed Aug 22 19:27:55 ## 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#/dev/mapper/centos-root / xfsdefaults 0 0UUID=6ca7a7f6-84fe-427d-8e72-1a7dbbe4e877 /boot xfsdefaults 0 0/dev/mapper/centos-swap swapswap defaults 0 0/dev/sdb1 /udisk vfat defaults 0 0#删除这一行

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。