Debian Wheezy 屏幕截图
Wine / PlayOnLinux 安装与配置

Debian/Linux 设备挂载

Qspy posted @ 2013年9月28日 14:21 in Debian with tags mount debian , 8653 阅读

mount 命令用于挂载光盘镜像文件、移动硬盘、U盘、Windows和NFS网络共享等等。

mount/umount 指令解析

"mount" 命令参数非常多,可以在终端下,键入 "man mount" 获取帮助。
使用 "mount" 命令时,经常需要查询磁盘设备信息,这时可使用 "fdisk" 指令或查看 "/proc/partitions" 信息

命令格式

mount [-t vfstype] [-o options] device dir
其中:

1."-t vfstype" 指定文件系统的类型,通常不必指定。mount 会自动选择正确的类型。常用类型有:
§   光盘或光盘镜像:iso9660
§   DOS fat16文件系统:msdos
§   Windows 9x fat32文件系统:vfat
§   Windows NT ntfs文件系统:ntfs
§   Mount Windows文件网络共享:smbfs
§   UNIX(LINUX) 文件网络共享:nfs

2."-o options" 主要用来描述设备或档案的挂接方式。常用的参数有:
§   loop:用来把一个文件当成硬盘分区挂接上系统
§   ro:采用只读方式挂接设备
§   rw:采用读写方式挂接设备
§   iocharset:指定访问文件系统所用字符集


3."device" 要挂接(mount)的设备。

4."dir" 设备在系统上的挂接点(mount point)。
 

自动挂载


自动挂载即利用 /etc/fstab 文件,详细情况请参考 fstab 用法。

 

磁盘分区挂载

如果安装了双系统,或者使用移动硬盘,那么就要使用磁盘分区挂载。
本地磁盘和移动硬盘的区别仅在于,本地磁盘通常使用 IDE 或 SATA 接口连接,移动硬盘通常使用 USB 接口连接。
对linux系统而言,USB接口的移动硬盘是当作 SCSI 设备对待的。

1. 查看磁盘信息 "fdisk -l"

注意:"fdisk" 需要 root 权限

$ sudo fdisk -l

Disk /dev/sda: 250.1 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders, total 488397168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0xafdc0a3f

  Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2457599     1227776    7  HPFS/NTFS/exFAT
/dev/sda2         2457600   139827199    68684800    7  HPFS/NTFS/exFAT
/dev/sda3       467916800   488394751    10238976    7  HPFS/NTFS/exFAT
/dev/sda4       139829246   467916799   164043777    5  Extended

Partition 4 does not start on physical sector boundary.
/dev/sda5       139829248   140218367      194560   83  Linux
/dev/sda6       140220416   218343423    39061504   83  Linux
/dev/sda7       218345472   249593855    15624192   83  Linux
/dev/sda8       249595904   386312191    68358144    7  HPFS/NTFS/exFAT
/dev/sda9       386314240   467916799    40801280    7  HPFS/NTFS/exFAT

上方信息中说明本地磁盘(/dev/sda) 中包含 4 个主分区( sda1/sda2/sda3/sda4 ),其中 sda1/sda2/sda3 是Windows分区; sda4 是扩展分区,该扩展分区包含 5 个逻辑分区 ( sda5/sda6/sda7/sda8/sda9 ),其中 sda5/sda6/sda7 是 Linux 分区,sda8/sda9 是Windows分区。

如果要挂载的是移动硬盘,应在连接移动硬盘后,再次使用 "fdisk -l" 查询。

$ sudo fdisk -l

Disk /dev/sda: 250.1 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders, total 488397168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0xafdc0a3f

  Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2457599     1227776    7  HPFS/NTFS/exFAT
/dev/sda2         2457600   139827199    68684800    7  HPFS/NTFS/exFAT
/dev/sda3       467916800   488394751    10238976    7  HPFS/NTFS/exFAT
/dev/sda4       139829246   467916799   164043777    5  Extended
Partition 4 does not start on physical sector boundary.

/dev/sda5       139829248   140218367      194560   83  Linux
/dev/sda6       140220416   218343423    39061504   83  Linux
/dev/sda7       218345472   249593855    15624192   83  Linux
/dev/sda8       249595904   386312191    68358144    7  HPFS/NTFS/exFAT
/dev/sda9       386314240   467916799    40801280    7  HPFS/NTFS/exFAT

Partition table entries are not in disk order

Disk /dev/sdb: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 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 identifier: 0xef943d9e

  Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *        2048   112660479    56329216    7  HPFS/NTFS/exFAT
/dev/sdb2       112662528   976769023   432053248    5  Extended
/dev/sdb5       112664576   419887103   153611264    7  HPFS/NTFS/exFAT
/dev/sdb6       419890968   665653274   122881153+   7  HPFS/NTFS/exFAT
/dev/sdb7       665653338   809017334    71681998+   7  HPFS/NTFS/exFAT
/dev/sdb8       809017398   874369754    32676178+   7  HPFS/NTFS/exFAT
/dev/sdb9       874371072   976769023    51198976    7  HPFS/NTFS/exFAT

上方信息中可以看到多了一个移动硬盘(/dev/sdb),其包含了两个主分区( /sdb1/sdb2 ) 和 5 个逻辑分区( sda5/sda6/sda7/sda8/sda9 ),所有均是 Windows 分区

2. 挂载分区

执行 "mount" 指令前,须先确保挂载点 ("dir") 是存在的,可以用 "mkdir" 指令创建挂载点。
这里假设挂载点为 "/mnt/hd1" 。

挂载 FAT /FAT32分区

"fdisk -l" 查询信息如:
 

$ sudo fdisk -l
Disk /dev/sdc: 131 MB, 131072000 bytes
239 heads, 31 sectors/track, 34 cylinders, total 256000 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 identifier: 0x00000000

  Device Boot      Start         End      Blocks   Id  System
/dev/sdc1   *          63      255999      127968+   6  FAT16

$ sudo fdisk -l
Disk /dev/sdb: 131 MB, 131072000 bytes
239 heads, 31 sectors/track, 34 cylinders, total 256000 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 identifier: 0x00000000

  Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *          63      255999      127968+   b  W95 FAT32

挂载命令:

$sudo mount -t vfat /dev/sdb1 /mnt/hd1

避免乱码的挂载命令:

$sudo mount -t vfat -o iocharset=cp936 /dev/sdb1 /mnt/hd1

 

挂载 NTFS 分区

在Linux系统中,NTFS分区需要 ntfs-3g 包支持,在 Debian 中安装命令如下:

$sudo apt-get install ntfs-3g

挂载命令:

$sudo mount -t ntfs /dev/sdb1 /mnt/hd1

避免乱码的挂载命令:

$sudo mount -t ntfs -o iocharset=cp936 /dev/sdb1 /mnt/hd1

 

挂载 exFAT 分区

在Linux系统中,exFAT分区需要 exfat-fuse 包支持,在 Debian 中安装命令如下:

$sudo apt-get install exfat-fuse

挂载命令:

$sudo mount -t exfat-fuse -o allow_other /dev/sdb1 /mnt/hd1

 

U盘挂载

和USB接口的移动硬盘相同对linux系统而言U盘也是当作SCSI设备对待的。使用方法和移动硬盘完全相同。请参考前一节<磁盘分区挂载>

SD/MMC卡挂载

SD/MMC挂载和磁盘分区挂载的不同在于设备名,SD/MMC默认的名称是 "/dev/mmcblk0p1"。
假设挂载点是 "/mnt/sdmmc"
挂载命令:

sudo mount -t vfat /dev/mmcblk0p1 /mnt/sdmmc

注:如果SD/MMC 是其他文件系统,请更换参数 "-t vfat"

Windows 文档共享挂载

Windows网络共享的核心是SMB/CIFS,在linux下要挂载(mount)windows的磁盘共享,就必须安装和使用samba软件包。
Debian 安装 samba:

$sudo apt-get install samba

假设挂载点为 "/mnt/samba",挂载

$sudo mount -t smbfs -o username=administrator,password=pldy123 //10.140.133.23/c$ /mnt/samba

说明:
administrator 是Windows电脑的登录用户名
pldy123 是administrator的登录密码
10.140.133.23 是windows电脑的ip地址
c$ 是Windows电脑的一个磁盘共享

如此就能够在linux系统上通过/mnt/samba来访问windows系统磁盘上的文档了。

UNIX/Linux 系统 NFS 文档共享

类似于windows的网络共享,UNIX(Linux)系统也有自己的网络共享,那就是NFS(网络文档系统)。
一般 Linux 安装时都会默认安装 NFS 支持,但可能没有安装 NFS Server。做为共享端的 Linux 是需要安装NFS Server的,这部分将另开篇幅介绍。
这里假设共享端的 NFS Server 和共享文档已设置好,并且挂载点为 "/mnt/nfs"。

$sudo mount -t nfs -o rw 10.140.133.9:/export/home/sunky /mnt/nfs

说明:
10.140.133.9 是NFS服务端的主机IP地址,当然这里也能够使用主机名,但必须在本机/etc/hosts文档里增加服务端ip定义。
/export/home/sunky 为服务端共享的目录。

如此就能够在linux客户端通过/mnt/nfs来访问其他linux系统或UNIX系统以NFS方式共享出来的文档了。
 

CDROM或镜像文件挂载

CDROM或ISO文件挂载

CDROM挂载

在现有的Linux系统中,CDROM一般都是默认挂载的,只要放入光盘就可以了。
如果没挂载,则可以用下面的命令实现挂载,这里假设挂载点是 "/media/cdrom":

$sudo mount -t iso9660 -r /dev/cdrom /media/cdrom

ISO镜像挂载

假设ISO镜像文件是 "/home/sunky/mydisk.iso",挂载点是 "/mnt/vcdrom"。
挂载命令如下:

$sudo mount -o loop -t iso9660 /home/sunky/mydisk.iso /mnt/vcdrom

附录1: 从光盘制作光盘映像文档

$sudo cp /dev/cdrom /home/sunky/mydisk.iso

$sudo dd if=/dev/cdrom of=/home/sunky/mydisk.iso

一般情况,使用 "dd" 指令制作光盘映像居多。

附录2: 将文档和目录制作成光盘映像文档

这里将使用 "mkisofs" 指令制作光盘映像。但在 Debian 中,仓库中没有这个包,需要网上查找 mkisofs 的 deb 包安装;或者使用 "genisoimage" 代替这个指令。

$sudo mkisofs -r -J -V mydisk -o /home/sunky/mydisk.iso /home/sunky/ mydir

说明:
mkisofs 是制作光盘映像指令
-r 参数1 Rock Ridge
-J 参数2 Joliet
-V mydisk 将卷标设置为 "mydisk"
-o /home/sunky/mydisk.iso 是在 /home/sunky 目录下创建 mydisk.iso 映像文件
/home/sunky/mydir 指的是制作光盘映像的源目录

$sudo genisoimage -udf -allow-limited-size -r -J -joliet-long -V mydisk -o /home/sunky/mydisk.iso /home/sunky/ mydir

说明:
genisoimage 是制作光盘映像指令
-udf 指文件系统是 UDF filesystem
-allow-limited-size 允许单文件超过 2G 大小
-r 指 Rock Ridge
-J 指 Joliet
-joliet-long 允许超长文件名
-V mydisk 将卷标设置为 "mydisk"
-o /home/sunky/mydisk.iso 是在 /home/sunky 目录下创建 mydisk.iso 映像文件
/home/sunky/mydir 指的是制作光盘映像的源目录

上面两条命令将/home/sunky/mydir目录下任何的目录和文档制作成光盘映像文档/home/sunky/mydisk.iso,光盘卷标为:mydisk

IMG镜像挂载

IMG镜像指的是后缀为 ".img" 的镜像文件。这类文件和 ISO文件略有不同,主要原因是其可能带有文件系统。
这里假设挂载点是 "/mnt/img",要挂载的镜像是"office2007pro.chs.img"

1. 查看IMG镜像

$ sudo fdisk office2007pro.chs.img  -lu
Disk office2007pro.chs.img: 694 MB, 694059008 bytes
255 heads, 63 sectors/track, 84 cylinders, total 1355584 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 identifier: 0x00000000

Disk office2007pro.chs.img doesn't contain a valid partition table

从最后一行可以看出,该IMG并没有带文件系统

2.载入到loop

载入之前,先执行:

$ sudo losetup -a

这时发现并没有任何有关"office2007pro.chs.img"的信息输出
载入使用下面命令:

$ sudo losetup /dev/loop0 office2007pro.chs.img
$ sudo losetup -a
/dev/loop0: [0808]:15356 (/home/wang/work/office2007pro.chs.img)

可以发现,载入后再使用 "losetup -a"查询时就有 "office2007pro.chs.img"的信息了,说明载入成功。
如果载入不成功,可以修改 "/dev/loop0" 为 "/dev/loop1",依此类推。

3.挂载IMG镜像

$ sudo mount -o loop,offset=512 office2007pro.chs.img /mnt/img
mount: you must specify the filesystem type
$ sudo mount -o loop office2007pro.chs.img /mnt/img
mount: warning: /media/usb0/ seems to be mounted read-only.

从上方可以发现,如果没有带文件系统的挂载,是不需要带 "offset=" 参数的;反之,则是需要的。
当要使用 "offset=" 参数时,其值可以用公式 : offset=start_sector x sector_byte_size(即offse=1*512) 计算得来

参考

linux的mount命令详解

Linux 下ros img镜像挂载
 

maid services dubai 说:
2019年9月22日 19:50

In case you dread planting season cleaning – as well as cleaning some other month or year – have you thought to let us help you along. You don’t need your home last shape as well as tackle your current seasonal cleaning yourself when you do have a residential cleanup service much like the Maids ranking by to address the soiled work.

uk cleaning director 说:
2019年11月16日 17:53

or lots of people, buying a house is probably the most costly as well as significant repayment they'll actually make within their lives. Because of this, it helps to stay the understand how to spend your own mortgage cash wisely.

river bank marketing 说:
2020年3月26日 22:12

To start up business owners, starting an online business is often specific to it reward. They can be thrilled kid be their own individual bosses, and to help you successfully acquire a business uploaded and functioning. Often they are really happy merely keep that dream survive. <a href="http://www.riverbankmarketing.com">www.riverbankmarketing.com</a>

healthy n balanced 说:
2020年3月26日 22:16

It is best to important to manage oneself using the principles of health and wellness. Regular check-ups, proper food intake and good living every enable you to always watch out for their health at a careful though reasonable option. Often you becomes overly involved with health matters and swept up in an important cycle in health fears. <a href="http://www.healthynbalanced.com">www.healthynbalanced.com</a>

sikkim health 说:
2020年3月26日 22:16

It is best to important to manage oneself using the principles of health and wellness. Regular check-ups, proper food intake and good living every enable you to always watch out for their health at a careful though reasonable option. Often you becomes overly involved with health matters and swept up in an important cycle in health fears. <a href="http://www.sikkimhealth.org">www.sikkimhealth.org</a>

clean tech laws 说:
2020年3月26日 22:17

What the law states of The law of gravity is certainly a Simple Law. So is definitely the Law in Conservation of one's, that is without a doubt, energy may not be created and destroyed, only transformed from a form to a new one. However, different from human procedures, which vary from area to area, Universal Procedures are frequent and predetermined. You connect to these procedures with each individual breath one take. Some people govern ones own existence. <a href="http://www.cleantechlaws.com">www.cleantechlaws.com</a>

maid service dubai 说:
2020年4月30日 19:21

Whenever you get the maid in the future in as well as help this could free upward more of your energy to be able to pursue your own hobbies as well as do exercises you could not perform previously. Exercises cause you to healthier and lower your real grow older by many years. Exercises delay your trip to a physician, saving a person expenses as well as ensuring that you don't lose your time and effort.

house painting servi 说:
2020年4月30日 19:21

d most instances, having the painter get the job done can also help you save the expenses of supplies. While the majority of painters will probably mark the costs up a little for those who have them purchase the materials, also, they are likely to understand where you'll get them cheaply to start with. This can lead to you obtaining quality fresh paint at a reasonable price that could normally just buy a person unprofessional or poor materials.

home maids dubai 说:
2021年6月07日 17:50

To obtain a great cleaning, applying this top-bottom clean-up method will likely be highly useful and fewer time-consuming. So, start clean-up the pieces of furniture, appliances or maybe room on the top then proceed down. Additionally, you should remove the pet hair, dog's fur, dust dust, crumbs, along with particles on the surfaces.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter