开机时自动挂载ISO文件

 想让 “Add/Remove Software”使用本地的DVD境像,先要挂载ISO,不知道文件格式等后面怎么写,搜了下。顺便复习一下fstab的用法:

以下内容摘自:http://wiki.linuxquestions.org/wiki/Fstab

 

/etc/fstab is a configuration file that is used to tell Linux what file systems to mount on boot and where.

 

Format

The format of every line is

[Device] [Mount Point] [Filesystem] [Options] [dump] [fsck order]

the character # allows to write comments into the file. A typical /etc/fstab file can look like this:

/dev/hda2		/               ext2		defaults	1  1
/dev/cdrom /mnt/cdrom iso9660 noauto,ro,user 0 0
/dev/hda1 /mnt/dos/c msdos defaults 0 0
/dev/fd0 /mnt/floppy ext2 noauto,user 0 0
/dev/hdb1 /mnt/hdb1 auto defaults 0 0
/dev/hda3 none swap sw
mynfsserver:/vol/vol1 /mnt/filer nfs defaults 0 0
//mysambaserver/share /mnt/sambashare smbfs rw,credentials=/home/joe/winbox-credentials.txt 0 0

Device

This is the physical location of the file system, e.g

  • /dev/hda - The master drive connected to the primary IDE cable.
  • /dev/hda2 - The second partition on master drive on primary IDE.
  • /dev/hdb - second drive on primary IDE cable.
  • /dev/fd0 - First floppy drive

It can also be a file system volume label or UUID, using this has the advantage that adding/removing disks won't effect what gets mounted. The format to use instead of the device name in the fstab file is:

LABEL=<label>

(Where <label> is some name, e.g. Boot)

UUID=<uuid>

(Where <uuid> is some number like 3e6be9de‐8139‐11d1‐9106‐a43f08d823a6. You can find out the uuid of your devices using hwinfo --block.)

How the label and the UUID are set depends on the file system type used. It can normally be set when creating/formatting the file system and the file system type usually has some tool to change it later on (e.g. e2tunefs, xfs_admin, reiserfstune etc.)

Mount Point

The mount point is what folder the filesystem is to be available under from system root, e.g.

  • /media/floppy
  • /media/cdrom
  • /mnt (temporary mount point)

Note: Make sure folder exists

Filesystem

This specifies what filesystem the device uses. Typically you will be mounting iso9660 for CDs and ext2/ext3/ReiserFS for hard drives/floppies. It can also be NFS which means the mount operation can only start after the network is up. If it is not a network drive and you just want it to be mounted (no matter which filesystem), use auto .

Options

This field describes how kernel should handle filesystem, i.e. will it be writable by the user.

  • sync/async - All I/O to the file system should be done (a)synchronously.
  • auto - The filesystem can be mounted automatically (at bootup, or when mount is passed the -a option). This is really unnecessary as this is the default action of mount -a anyway.
  • noauto - The filesystem will NOT be automatically mounted at startup, or when mount passed -a. You must explicitly mount the filesystem.
  • dev/nodev - Interpret/Do not interpret character or block special devices on the file system.
  • exec / noexec - Permit/Prevent the execution of binaries from the filesystem.
  • suid/nosuid - Permit/Block the operation of suid, and sgid bits.
  • ro - Mount read-only.
  • rw - Mount read-write.
  • user - Permit any user to mount the filesystem. This automatically implies noexec, nosuid,nodev unless overridden.
  • nouser - Only permit root to mount the filesystem. This is also a default setting.
  • defaults - Use default settings. Equivalent to rw, suid, dev, exec, auto, nouser, async.
  • _netdev - this is a network device, mount it after bringing up the network. Only valid with fstype nfs.
  • atime - This option causes Linux to record the last (or latest) time when a particular file was accessed.
  • noatime - This option stops recording the last file access time when the file is just read.
  • relatime - This option causes the access time to be updated if they are earlier than the modification time.

Dump

Dump field sets whether the backup utility dump will backup file system. If set to "0" the file system is ignored, with "1" it is backed up.

Fsck

Fsck order is to tell fsck what order to check the file systems, if set to "0" the file system is ignored.

Auto-mount of iso-image in /etc/fstab

/iso-archiv/image.iso /mnt/image1 iso9660 ro,loop,auto 0 0
( first mkdir /mnt/image1 !)

Rocky Linux(以及大多数Linux发行版)可以通过修改`/etc/fstab`文件来实现开机自动挂载本地镜像。以下是一般的步骤: 1. 首先,确保你有一个本地镜像文件,通常是一个ISO文件,并且你已经把它放置在了Rocky Linux系统的文件系统中的某个位置。 2. 创建一个挂载点目录,用于挂载你的ISO文件。你可以使用`mkdir`命令来创建一个新的目录。例如: ```bash sudo mkdir /mnt/your_mountpoint ``` 这里的`your_mountpoint`是你想要挂载ISO文件的目录路径。 3. 接下来,挂载ISO文件到你刚才创建的目录中,可以使用`mount`命令: ```bash sudo mount -o loop /path/to/your.ISO /mnt/your_mountpoint ``` 其中`/path/to/your.ISO`是你的ISO文件的路径。 4. 现在你需要编辑`/etc/fstab`文件以添加开机自动挂载的条目。在编辑之前,备份该文件是一个好习惯: ```bash sudo cp /etc/fstab /etc/fstab.backup ``` 然后打开`/etc/fstab`文件进行编辑: ```bash sudo nano /etc/fstab ``` 或者使用你喜欢的任何文本编辑器。 5. 在`/etc/fstab`文件中添加一行来定义开机自动挂载: ``` /path/to/your.ISO /mnt/your_mountpoint iso9660 loop,ro 0 0 ``` 其中: - `/path/to/your.ISO`是ISO文件的完整路径。 - `/mnt/your_mountpoint`是挂载点目录。 - `iso9660`是文件系统类型,适用于大多数ISO文件。 - `loop`指定使用循环设备挂载。 - `ro`指定为只读模式。 - 最后两个`0`表示不使用dump备份和fsck检查。 6. 保存并关闭文件。当你重启Rocky Linux系统,系统将会自动挂载你在`/etc/fstab`文件中指定的ISO文件到指定的挂载点。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值