파일 마운트
파일을 디바이스로 사용하기 위해서 루프백 디바이스를 사용한다. img 파일을 fdisk로 살펴보면 각각의 시작 오프셋(Start)가 기록되어 있는데, 이에 맞추어 mount시 offset을 파라미터로 넘긴다.
예를 들어 ubuntu-18.04.2-live-server-amd64.iso
라는 파일을 받아 마운트하는 경우는
$ fdisk -l ubuntu-18.04.2-live-server-amd64.iso
Disk ubuntu-18.04.2-live-server-amd64.iso: 834 MiB, 874512384 bytes, 1708032 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
Disklabel type: dos
Disk identifier: 0x11e2b548
Device Boot Start End Sectors Size Id Type
ubuntu-18.04.2-live-server-amd64.iso1 * 0 1708031 1708032 834M 0 Empty
ubuntu-18.04.2-live-server-amd64.iso2 1287748 1292675 4928 2.4M ef EFI (FAT-12/16/32)
두 파티션을 가진 파일의 offset은 각각
- 0 : 0 * 512
- 659326976 : 1287748 * 512
이렇게 된다. 따라서 마운트를 하는 경우는 아래처럼 진행하면 된다.
$ ls -la
합계 2596296
drwxr-xr-x 5 cublr cublr 4096 4월 26 16:05 .
drwxr-xr-x 12 root root 4096 4월 26 12:05 ..
drwxr-xr-x 2 root root 16384 1월 1 1970 boot
drwxrwxr-x 2 cublr cublr 4096 4월 26 12:07 img
-rw-rw-r-- 1 cublr cublr 874512384 2월 14 19:06 ubuntu-18.04.2-live-server-amd64.iso
$ sudo mount -o loop,offset=0 ubuntu-18.04.2-live-server-amd64.iso boot
mount: /mount/disk12/boot: WARNING: device write-protected, mounted read-only.
$ mount -l
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
...
/mount/disk12/ubuntu-18.04.2-live-server-amd64.iso on /mount/disk12/boot type iso9660 (ro,relatime,nojoliet,check=s,map=n,blocksize=2048) [Ubuntu-Server 18.04.2 LTS amd64]
$ sudo umount boot
$ sudo mount -o loop,offset=659326976 ubuntu-18.04.2-live-server-amd64.iso boot
$ mount
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
...
/mount/disk12/ubuntu-18.04.2-live-server-amd64.iso on /mount/disk12/odroid/partition2 type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)
$ tree boot
boot
└── efi
└── boot
├── bootx64.efi
└── grubx64.efi