linux 重新挂载命令

linux 重新挂载命令,第1张

linux 重新挂载需要先卸载再重新挂载,如果要一条命令可以通过&&符号将两个命令组合到一个命令里,例如:

umount -l /mnt/test &&mount -o ro /dev/hda1  /mnt/test

linux中挂载命令是mount,卸载是umount,在命令行中使用&&可以将多条命令组合成一条命令并顺序执行,以达到快速执行的目的。

扩展资料

linux挂载命令mount的用法介绍:

1、语法

mount [-fnrsvw] [-t vfstype] [-o options] device dir

2、参数说明:

-V:显示程序版本

-h:显示辅助讯息

-v:显示较讯息,通常和 -f 用来除错。

-a:将 /etc/fstab 中定义的所有档案系统挂上。

-F:这个命令通常和 -a 一起使用,它会为每一个 mount 的动作产生一个行程负责执行。在系统需要挂上大量 NFS 档案系统时可以加快挂上的动作。

-f:通常用在除错的用途。它会使 mount 并不执行实际挂上的动作,而是模拟整个挂上的过程。通常会和 -v 一起使用。

-n:一般而言,mount 在挂上后会在 /etc/mtab 中写入一笔资料。但在系统中没有可写入档案系统存在的情况下可以用这个选项取消这个动作。

重新挂载需要先将驱动器卸掉,然后重新挂载。mount -o remount,rw /linux 挂载详解:需要注意一下两点:1、挂载点必须是一个目录。 2、一个分区挂载在一个已存在的目录上,这个目录可以不为空,但挂载后这个目录下以前的内容将不可用。挂载时使用mount命令: 格式:mount [-参数] [设备名称] [挂载点] 其中常用的参数有 :-t<文件系统类型>指定设备的文件系统类型。minix linux最早使用的文件系统 ext2 linux目前常用的文件系统 msdos MS-DOS的fat,就是fat16 vfat windows98常用的fat32 nfs 网络文件系统 iso9660 CD-ROM光盘标准文件系统 ntfs windows NT 2000的文件系统 hpfs OS/2文件系统 auto 自动检测文件系统 -o<选项>指定挂载文件系统时的选项。有些也可用在/etc/fstab中。iocharset=XXX 字符集 ro 以只读方式挂载 rw 以读写方式挂载 nouser 使一般用户无法挂载 user 可以让一般用户挂载设备 mount命令没有建立挂载点的功能,因此你应该确保执行mount命令时,挂载点已经存在。例子:windows98装在hda1分区,同时计算机上还有软盘和光盘需要挂载。 # mk /mnt/winc # mk /mnt/floppy # mk /mnt/cdrom # mount -t vfat /dev/hda1 /mnt/winc # mount -t msdos /dev/fd0 /mnt/floppy # mount -t iso9660 /dev/cdrom /mnt/cdrom 现在就可以进入/mnt/winc等目录读写这些文件系统了。 要保证最后两行的命令不出错,要确保软驱和光驱里有盘。如果windows98目录里有中文文件名,使用上面的命令挂载后,显示的是一堆乱码。这就要用到 -o 参数里的codepage iocharset选项。codepage指定文件系统的代码页,简体中文中文代码是936;iocharset指定字符集,简体中文一般用cp936或gb2312。 当挂载的文件系统linux不支持时,mount一定报错,如windows2000的ntfs文件系统。可以重新编译linux内核以获得对该文件系统的支持。。 自动挂载:其实,每次开机时,linux自动将需要挂载的linux分区挂载上了。可以设定让linux在启动的时候挂载望挂载的分区,如windows分区,在/etc目录下有个fstab文件,它里面列出了linux开机时自动挂载的文件系统的列表。/etc/fstab文件如下: /dev/hda2 / ext3 defaults 1 1 /dev/hda1 /boot ext3 defaults 1 2 none /dev/pts devpts gid=5,mode=620 0 0 none /proc proc defaults 0 0 none /dev/shm tmpfs defaults 0 0 /dev/hda3 swap swap defaults 0 0 /dev/cdrom /mnt/cdrom iso9660 noauto,codepage=936,iocharset=gb2312 0 0 /dev/fd0 /mnt/floppy auto noauto,owner,kudzu 0 0 /dev/hdb1 /mnt/winc vfat defaults,codepage=936,iocharset=cp936 0 0 /dev/hda5 /mnt/wind vfat defaults,codepage=936,iocharset=cp936 0 0 在/etc/fstab文件里,第一列是挂载的文件系统的设备名,第二列是挂载点,第三列是挂载的文件系统类型,第四列是挂载的选项,选项间用逗号分隔。按照上面格式写入信息,就可以实现开机启动自动挂载分区。

http://blog.scoutapp.com/articles/2015/04/10/understanding-page-faults-and-memory-swap-in-outs-when-should-you-worry

Linux allocates memory to processes by dividing the physical memory into pages, and then mapping those physical pages to the virtual memory needed by a process. It does this in conjunction with the Memory Management Unit (MMU) in the CPU. Typically a page will represent 4KB of physical memory. Statistics and flags are kept about each page to tell Linux the status of that chunk of memory.

These pages can be in different states. Some will be free (unused), some will be used to hold executable code, and some will be allocated as data for a program. There are lots of clever algorithms that manage this list of pages and control how they are cached, freed and loaded.

由MMU把物理内存分割成众多个page,每个page是4KB. 然后把page映射到进程的虚拟内存空间. CPU在执行进程中的指令时, 以虚拟内存地址为基础, 通过map映射, 进而找到物理内存中实际存放指令的地址.

Imagine a large running program on a Linux system. The program executable size could be measured in megabytes, but not all that code will run at once. Some of the code will only be run during initialization or when a special condition occurs. Over time Linux can discard the pages of memory which hold executable code, if it thinks that they are no longer needed or will be used rarely. As a result not all of the machine code will be held in memory even when the program is running.

A program is executed by the CPU as it steps its way through the machine code. Each instruction is stored in physical memory at a certain address. The MMU handles the mapping from the physical address space to the virtual address space. At some point in the program's execution the CPU may need to address code which isn't in memory. The MMU knows that the page for that code isn't available (because Linux told it) and so the CPU will raise a page fault.

The name sounds more serious than it really is. It isn't an error, but rather a known event where the CPU is telling the operating system that it needs physical access to some more of the code.

Linux will respond by allocating more pages to the process, filling those pages with the code from the binary file, configuring the MMU, and telling the CPU to continue.

page fault, (严格说, 这里指的是major page fault)名字听起来挺严重, 实际上, 并不是什么"错误".

大致是这样, 一个程序可能占几Mb, 但并不是所有的指令都要同时运行, 有些是在初始化时运行, 有些是在特定条件下才会去运行. 因此linux并不会把所有的指令都从磁盘加载到page内存. 那么当cpu在执行指令时, 如果发现下一条要执行的指令不在实际的物理内存page中时, CPU 就会 raise a page fault, 通知MMU把下面要执行的指令从磁盘加载到物理内存page中. 严格说, 这里指的是major fault. 还有另一种, 就是minor fault.

There is also a special case scenario called a minor page fault which occurs when the code (or data) needed is actually already in memory, but it isn't allocated to that process. For example, if a user is running a web browser then the memory pages with the browser executable code can be shared across multiple users (since the binary is read-only and can't change). If a second user starts the same web browser then Linux won't load all the binary again from disk, it will map the shareable pages from the first user and give the second process access to them. In other words, a minor page fault occurs only when the page list is updated (and the MMU configured) without actually needing to access the disk.

minor page fault, 指的就是CPU要执行的指令实际上已经在物理内存page中了, 只是这个page没有被分配给当前进程, 这时CPU就会raise一个minor page fault, 让MMU把这个page分配给当前进程使用, 因此minor page fault并不需要去访问磁盘.

当物理内存不够时,把一些物理内存page中的内容写入到磁盘, 以腾出一些空闲的page出来供进程使用, 这就是swap out.(The process of writing pages out to disk to free memory is called swapping-out)

反过来说, 当CPU要执行的指令被发现已经swap out到了磁盘中, 这时就需要从磁盘把这些指令再swap in到物理内存中,让CPU去执行.

swap in和swap out的 *** 作都是比较耗时的, 频繁的swap in和swap out *** 作很影响系统性能.

-------DONE.-----------


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/yw/7308711.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-04
下一篇2023-04-04

发表评论

登录后才能评论

评论列表(0条)

    保存