网站首页 > 博客文章 正文
1. 先查看下mount U盘之前系统上已经挂载了哪些文件系统,
sh-# cat /proc/mounts
rootfs / rootfs rw 0 0
/dev/root / squashfs ro,relatime 0 0
none /proc proc rw,relatime 0 0
none /sys sysfs rw,relatime 0 0
none /tmp tmpfs rw,relatime 0 0
none /opt tmpfs rw,relatime 0 0
none /tmp_fs tmpfs rw,relatime 0 0
none /proc/bus/usb usbfs rw,relatime 0 0
2. 接下来我们要知道挂载的U盘名是什么,这只U盘是什么类型的文件系统,
sh-# fdisk -l
Disk /dev/sda: 4002 MB, 4002910208 bytes
32 heads, 63 sectors/track, 3878 cylinders
Units = cylinders of 2016 * 512 = 1032192 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 3878 3908992+ b Win95 FAT32
3. 查看当前系统中支持哪些类型的文件系统,
sh-# cat /proc/filesystems
nodev sysfs
nodev rootfs
nodev bdev
nodev proc
nodev tmpfs
nodev debugfs
nodev sockfs
nodev usbfs
nodev pipefs
nodev anon_inodefs
nodev devpts
ext2
nodev ramfs
vfat
nodev mqueue
nodev mtd_inodefs
ntfs
4. 挂载一个文件系统必须有一个mount point,所以这里暂时将这只U盘挂载到/tmp_fs这个目录下。
sh-# touch /tmp_fs/test.txt
sh-# ls -l /tmp_fs/test.txt
-rw-r--r-- 1 root root 0 Jan 1 00:07 /tmp_fs/test.txt
5. 真正要mount这个U盘了,
sh-# mount -t vfat /dev/sda1 /tmp_fs
6. 检查是否有挂载成功,
sh-# cat /proc/mounts
rootfs / rootfs rw 0 0
/dev/root / squashfs ro,relatime 0 0
none /proc proc rw,relatime 0 0
none /sys sysfs rw,relatime 0 0
none /tmp tmpfs rw,relatime 0 0
none /opt tmpfs rw,relatime 0 0
none /tmp_fs tmpfs rw,relatime 0 0
none /proc/bus/usb usbfs rw,relatime 0 0
/dev/sda1 /tmp_fs vfat rw,relatime,fmask=0022,dmask=0022,codepage=cp437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro 0 0
接下来我们再访问看看啦,
sh-# ls /tmp_fs/
TF1014VIZUSMTKO0-420.VOB gdb
tcpdump lsof
真的可以访问U盘里面的文件耶,说明mount成功了。
7. umount这个文件系统,可以看到原先的文件系统/tmp_fs又恢复出来了,
sh-# umount /mnt/usb/sda1/
sh-# ls /tmp_fs
test.txt
sh-# mount
rootfs on / type rootfs (rw)
/dev/root on / type squashfs (ro,relatime)
none on /proc type proc (rw,relatime)
none on /sys type sysfs (rw,relatime)
none on /tmp type tmpfs (rw,relatime)
none on /opt type tmpfs (rw,relatime)
none on /tmp_fs type tmpfs (rw,relatime)
none on /proc/bus/usb type usbfs (rw,relatime)
以上说明的是如何mount一个FAT32类型文件系统的U盘。
接下来,我们要将U盘format成NTFS类型的文件系统,再试试看能不能正常挂载。
mount失败了,要如何才能mount成功呢?
sh-# busybox fdisk -l
Disk /dev/sda: 4002 MB, 4002910208 bytes
32 heads, 63 sectors/track, 3878 cylinders
Units = cylinders of 2016 * 512 = 1032192 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 3878 3908992+ 7 HPFS/NTFS
sh-# mount -t ntfs /dev/sda1 /tmp_fs/
mount: wrong fs type, bad option, bad superblock on /dev/sda1,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try
dmesg | tail or so
有时候需要将文件系统从ro改成rw或者从rw更改成ro,我们以U盘进行实验。
1. 通过mount命令查看/dev/sda1为rw的文件系统,
sh-# mount
rootfs on / type rootfs (rw)
/dev/root on / type squashfs (ro,relatime)
none on /proc type proc (rw,relatime)
none on /sys type sysfs (rw,relatime)
none on /tmp type tmpfs (rw,relatime)
none on /opt type tmpfs (rw,relatime)
none on /var/run type tmpfs (rw,relatime)
none on /proc/bus/usb type usbfs (rw,relatime)
/dev/sda1 on /tmp/mnt/usb/sda1 type vfat (rw,noatime,fmask=0000,dmask=0000,allow_utime=0022,codepage=cp437,iocharset=utf8,shortname=mixed,errors=continue)
2. 测试下是否可以写入/dev/sda1,
sh-# touch
/tmp/mnt/usb/sda1/test.txt
sh-# ls -l
/tmp/mnt/usb/sda1/test.txt
-rwxrwxrwx 1 root root 0 Jan 1 00:13
/tmp/mnt/usb/sda1/test.txt
3. 将/dev/sda1这个device重新挂载成ro的文件系统,
sh-# mount -o remount,ro /tmp/mnt/usb/sda1/
4. 再次使用mount命令进行查看,你会发现/dev/sda1已经变成ro了。
sh-# mount
rootfs on / type rootfs (rw)
/dev/root on / type squashfs (ro,relatime)
none on /proc type proc (rw,relatime)
none on /sys type sysfs (rw,relatime)
none on /tmp type tmpfs (rw,relatime)
none on /opt type tmpfs (rw,relatime)
none on /var/run type tmpfs (rw,relatime)
none on /proc/bus/usb type usbfs (rw,relatime)
/dev/sda1 on /tmp/mnt/usb/sda1 type vfat (ro,noatime,fmask=0000,dmask=0000,allow_utime=0022,codepage=cp437,iocharset=utf8,shortname=mixed,errors=continue)
5. 通过实验来验证一下是不是真的有效,
sh-# touch
/tmp/mnt/usb/sda1/test.txt
touch: cannot touch `
/tmp/mnt/usb/sda1/test.txt': Read-only file system
当然如果你的文件系统在忙比如有打开着的文件,那么remount就会失败。
sh-# mount -o remount,ro /tmp/
mount: /tmp is busy
sh-# echo $?
32
sh-# umount /tmp/
umount: /tmp: device is busy.
(In some cases useful info about processes that use
the device is found by lsof(8) or fuser(1))
如果设备处于busy状态,而你却执意要umount这个设备。
可以使用lsof定位哪些进程打开了文件,然后再将这个进程杀死,
再去umount应该就能成功卸载这个设备了。
待确认问题:
linux mount ntfs文件系统?
猜你喜欢
- 2025-03-29 Linux 命令总结,建议收藏(linux命令?)
- 2025-03-29 linux常用命令整理(详细)(linux常用命令示例)
- 2025-03-29 Liunx命令总结全在这里了,几百条!整整几百条!
- 2025-03-29 物理机安装Centos7后,空间只有50G问题
- 2025-03-29 linux基础(二)(linux 基础教程)
- 2025-03-29 Linux磁盘管理(三)——挂载和卸载磁盘分区
- 2025-03-29 CentOS7下动态调整LVM分区大小的操作步骤
- 2025-03-29 第7章 Linux磁盘管理—磁盘格式化和挂载
- 2025-03-29 既然命令提示符的命令跟运行一样,为什么还要用命令提示符?
- 2025-03-29 linux常用系统命令(linux常用命令及含义)
你 发表评论:
欢迎- 最近发表
- 标签列表
-
- ifneq (61)
- 字符串长度在线 (61)
- googlecloud (64)
- messagesource (56)
- promise.race (63)
- 2019cad序列号和密钥激活码 (62)
- window.performance (66)
- qt删除文件夹 (72)
- mysqlcaching_sha2_password (64)
- ubuntu升级gcc (58)
- nacos启动失败 (64)
- ssh-add (70)
- jwt漏洞 (58)
- macos14下载 (58)
- yarnnode (62)
- abstractqueuedsynchronizer (64)
- source~/.bashrc没有那个文件或目录 (65)
- springboot整合activiti工作流 (70)
- jmeter插件下载 (61)
- 抓包分析 (60)
- idea创建mavenweb项目 (65)
- vue回到顶部 (57)
- qcombobox样式表 (68)
- tomcatundertow (58)
- pastemac (61)
本文暂时没有评论,来添加一个吧(●'◡'●)