zoukankan      html  css  js  c++  java
  • linux mount命令学习

    我们在下面这篇博文中已经有笼统的学习了文件系统的一些相关知识,
    http://blog.csdn.net/boyxulin1986/article/details/12107113

    本篇我们主要是用来学习如何去挂载一个磁盘文件系统,以U盘为例进行说明和分析。

    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
    nodev   ubifs
            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

     

  • 相关阅读:
    UltraSoft
    UltraSoft
    UltraSoft
    UltraSoft
    UltraSoft
    2020软工提问回顾与个人总结作业
    2020软工结对项目作业-简单几何形状间交点统计
    2020软工个人博客作业-博客园班级博客分析
    2020软工个人阅读博客作业
    2020软工第一次作业-热身
  • 原文地址:https://www.cnblogs.com/keanuyaoo/p/3348094.html
Copyright © 2011-2022 走看看