Linux设置开机自动挂载镜像文件

1.挂载

mount -o loop /dev/sr0 /media

2.使用df -T查看镜像文件格式(一般都是iso9660)

[root@zabbix_test ~]# df -T
Filesystem            Type     1K-blocks    Used Available Use% Mounted on
/dev/mapper/rhel-root xfs       52403200 1054636  51348564   3% /
devtmpfs              devtmpfs   4074828       0   4074828   0% /dev
tmpfs                 tmpfs      4086896       0   4086896   0% /dev/shm
tmpfs                 tmpfs      4086896    8740   4078156   1% /run
tmpfs                 tmpfs      4086896       0   4086896   0% /sys/fs/cgroup
/dev/sda1             xfs         508580  128008    380572  26% /boot
/dev/mapper/rhel-Data xfs       43498752 4424928  39073824  11% /Data
tmpfs                 tmpfs       817380       0    817380   0% /run/user/0
/dev/loop0            iso9660    4391278 4391278         0 100% /media

3.编辑fstab文件

[root@zabbix_test ~]# vi /etc/fstab 

#
# /etc/fstab
# Created by anaconda on Tue Oct 27 10:35:21 2020
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/rhel-root   /                       xfs     defaults        0 0
/dev/mapper/rhel-Data   /Data                   xfs     defaults        0 0
UUID=4394cca8-82c3-4ee7-9cd7-c90a71fb65ef /boot                   xfs     defaults        0 0
/dev/mapper/rhel-swap   swap                    swap    defaults        0 0
/dev/sr0 /media iso9660 loop,defaults 0 0

4.卸载/media

umount /media

5.使用mount -a测试是否OK

[root@zabbix_test ~]# mount -a
mount: /dev/loop0 is write-protected, mounting read-only
[root@zabbix_test ~]# df -h
Filesystem             Size  Used Avail Use% Mounted on
/dev/mapper/rhel-root   50G  1.1G   49G   3% /
devtmpfs               3.9G     0  3.9G   0% /dev
tmpfs                  3.9G     0  3.9G   0% /dev/shm
tmpfs                  3.9G  8.6M  3.9G   1% /run
tmpfs                  3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/sda1              497M  126M  372M  26% /boot
/dev/mapper/rhel-Data   42G  4.3G   38G  11% /Data
tmpfs                  799M     0  799M   0% /run/user/0
/dev/sr0             4.2G  4.2G     0 100% /media

发表评论

评论列表,共 0 条评论

    暂无评论