天天看點

Linux挂載iso檔案

方式一

通過vm虛拟軟體"設定"->>cd/dvd ->>設定ISO映像.選中 '‘開機連接配接’'和"已連接配接"

建立一個iso挂載的目錄 mkdir /mnt/cdrom

lsblk -f

​ sr0 iso9660 CentOS_6.9_Final

執行挂載指令 :mount /dev/sr0 /mnt/cdrom

[[email protected] mnt]# mount /dev/sr0 /mnt/cdrom/

mount: block device /dev/sr0 is write-protected, mounting read-only

檢視資訊

[[email protected] mnt]# ll /mnt/cdrom/

​ 總用量 564

-r–r--r–. 2 root root 14 3月 29 2017 CentOS_BuildTag

dr-xr-xr-x. 3 root root 2048 3月 29 2017 EFI

-r–r--r–. 2 root root 212 11月 27 2013 EULA

-r–r--r–. 2 root root 18009 11月 27 2013 GPL

dr-xr-xr-x. 3 root root 2048 3月 29 2017 images

dr-xr-xr-x. 2 root root 2048 3月 29 2017 isolinux

dr-xr-xr-x. 2 root root 534528 3月 29 2017 Packages

-r–r--r–. 2 root root 1359 3月 28 2017 RELEASE-NOTES-en-US.html

dr-xr-xr-x. 2 root root 4096 3月 29 2017 repodata

-r–r--r–. 2 root root 1706 11月 27 2013 RPM-GPG-KEY-CentOS-6

-r–r--r–. 2 root root 1730 11月 27 2013 RPM-GPG-KEY-CentOS-Debug-6

-r–r--r–. 2 root root 1730 11月 27 2013 RPM-GPG-KEY-CentOS-Security-6

-r–r--r–. 2 root root 1734 11月 27 2013 RPM-GPG-KEY-CentOS-Testing-6

-r–r--r–. 1 root root 3380 3月 29 2017 TRANS.TBL

//挂載成功可以看見如上檔案

方式二

通過将iso檔案上傳到linux系統内部實作挂載

1 将iso檔案傳到linux檔案系統

2 建立需要将iso挂載到的目錄

mkdir /mnt/cdrom

3 實作挂載

mount -o loop /CentOS-6.9-x86_64-bin-DVD1.iso /mnt/cdrom

ios名檔案為自己傳入linux檔案系統的 名字

4 檢視挂載

[[email protected] Packages]# df -h

Filesystem Size Used Avail Use% Mounted on

/dev/sda2 20G 5.9G 13G 32% /

tmpfs 1.9G 0 1.9G 0% /dev/shm

/dev/sda1 190M 40M 141M 22% /boot

/dev/sda3 7.8G 18M 7.4G 1% /mnt/disk1

/dev/sda5 7.6G 18M 7.2G 1% /mnt/disk2

/dev/sdb1 3.8G 7.7M 3.6G 1% /mnt/disk3

/dev/sdb2 6.0G 14M 5.7G 1% /mnt/disk4

/CentOS-6.9-x86_64-bin-DVD1.iso

3.7G 3.7G 0 100% /mnt/cdrom

總結:第二種方法把檔案放入linux系統内部後 一行代碼搞定 很棒!