Mount: Difference between revisions
No edit summary |
m Leo moved page Mount Tips & Tricks to Mount: Generic information on mount |
||
| (2 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
__FORCETOC__ | __FORCETOC__ | ||
Mounting Tips & Tricks for Linux. | Mounting Tips & Tricks for Linux. | ||
== Mounting Filesystems == | ==Mounting Filesystems== | ||
=== ISO Disk Images === | ===ISO Disk Images=== | ||
To mount a {{code|.iso}} image, use {{code|iso9660}} type: | To mount a {{code|.iso}} image, use {{code|iso9660}} type: | ||
{{highlight|lang=terminal|code= | {{highlight|lang=terminal|code= | ||
| Line 9: | Line 10: | ||
}} | }} | ||
=== Samba Network Shares === | ===Samba Network Shares=== | ||
See: [[Mounting Samba (CIFS) shares]] | |||
== {{code|/etc/fstab}} == | =={{code|/etc/fstab}}== | ||
The filesystem tab file contains all filesystems that the system should mount on start up. Each line of the file defines a filesystem that should be mounted. Example entries from Wikipedia shows various examples for different file systems: | The filesystem tab file contains all filesystems that the system should mount on start up. Each line of the file defines a filesystem that should be mounted. Example entries from Wikipedia shows various examples for different file systems: | ||
{{highlight|lang=text|code= | {{highlight|lang=text|code= | ||
| Line 66: | Line 44: | ||
Each field in order are: | Each field in order are: | ||
{| class="wikitable" | {| class="wikitable" | ||
! Device Spec | !Device Spec | ||
| The device name, label, UUID that defines the data source, hardware, or partition | |The device name, label, UUID that defines the data source, hardware, or partition | ||
|- | |- | ||
! Mount Point | !Mount Point | ||
| The mount point of the filesystem. Swap partitions or specific files is set to 'none' | |The mount point of the filesystem. Swap partitions or specific files is set to 'none' | ||
|- | |- | ||
! Filesystem Type | !Filesystem Type | ||
| The filesystem type of this device. | |The filesystem type of this device. | ||
|- | |- | ||
! Mount Options | !Mount Options | ||
| Mount options used by the filesystem. 'defaults' refers to the filesystem defaults. | |Mount options used by the filesystem. 'defaults' refers to the filesystem defaults. | ||
|- | |- | ||
! Dump | !Dump | ||
| Determines how often the filesystem should be backed up by the {{code|dump}} program. {{code|0}} to never backup. | |Determines how often the filesystem should be backed up by the {{code|dump}} program. {{code|0}} to never backup. | ||
|- | |- | ||
! Pass | !Pass | ||
| Determines the order in which the {{code|fsck}} program will check devices for errors on startup. {{code|1}} for root filesystem. {{code|2}} to check after root. {{code|0}} to disable. | |Determines the order in which the {{code|fsck}} program will check devices for errors on startup. {{code|1}} for root filesystem. {{code|2}} to check after root. {{code|0}} to disable. | ||
|} | |} | ||
== Tips == | ==Tips== | ||
=== Remounting from Read-Only to Read-Write === | ===Remounting from Read-Only to Read-Write=== | ||
You can remount something that's mounted read-only by using the {{code|remount}} option. | You can remount something that's mounted read-only by using the {{code|remount}} option. | ||
| Line 94: | Line 72: | ||
}} | }} | ||
=== Mounting a disk image without root === | ===Mounting a disk image without root=== | ||
Using {{code|udisksctl}}, you can mount disk images without requiring root or sudoers access. | Using {{code|udisksctl}}, you can mount disk images without requiring root or sudoers access. | ||
| Line 117: | Line 95: | ||
See Also: https://wiki.debian.org/ManipulatingISOs | See Also: https://wiki.debian.org/ManipulatingISOs | ||
=== Mounting disk image partitions === | ===Mounting disk image partitions=== | ||
To mount a specific partition inside a disk image, use the {{code|fdisk}} utility to see where the partition boundaries are. | To mount a specific partition inside a disk image, use the {{code|fdisk}} utility to see where the partition boundaries are. | ||
| Line 153: | Line 131: | ||
== Troubleshooting == | ==Troubleshooting== | ||
=== Samba Network Shares === | ===Samba Network Shares=== | ||
The first time I ran {{code|mount -a}}, I got the following error: | The first time I ran {{code|mount -a}}, I got the following error: | ||
| Line 179: | Line 157: | ||
==See Also== | |||
#http://madduck.net/blog/2006.10.20:loop-mounting-partitions-from-a-disk-image/ | |||
# http://madduck.net/blog/2006.10.20:loop-mounting-partitions-from-a-disk-image/ | #https://en.wikipedia.org/wiki/Fstab | ||
# https://en.wikipedia.org/wiki/Fstab | |||
{{Navbox Linux}}[[Category:Linux]] | {{Navbox Linux}} | ||
[[Category:Linux]] | |||
[[Category:LinuxUtilities]] | |||
Latest revision as of 21:21, 30 December 2021
Mounting Tips & Tricks for Linux.
Mounting Filesystems
ISO Disk Images
To mount a .iso image, use iso9660 type:
mount -o loop -t iso9660 <isofile> <destination>
See: Mounting Samba (CIFS) shares
/etc/fstab
The filesystem tab file contains all filesystems that the system should mount on start up. Each line of the file defines a filesystem that should be mounted. Example entries from Wikipedia shows various examples for different file systems:
# device-spec mount-point fs-type options dump pass
LABEL=/ / ext4 defaults 1 1
/dev/sda6 none swap defaults 0 0
none /dev/pts devpts gid=5,mode=620 0 0
none /proc proc defaults 0 0
none /dev/shm tmpfs defaults 0 0
# Removable media
/dev/cdrom /mnt/cdrom udf,iso9660 noauto,owner,ro 0 0
# NTFS Windows 7 partition
/dev/sda1 /mnt/Windows ntfs-3g quiet,defaults,locale=en_US.utf8,umask=0,noexec 0 0
# Partition shared by Windows and Linux
/dev/sda7 /mnt/shared vfat umask=000 0 0
# mounting tmpfs
tmpfs /mnt/tmpfschk tmpfs size=100m 0 0
# mounting cifs
//cifs_server_name/ashare /store/pingu cifs credentials=/root/smbpass.txt 0 0
# mounting NFS
nfs_server_name:/store /store nfs rw 0 0
Each field in order are:
| Device Spec | The device name, label, UUID that defines the data source, hardware, or partition |
|---|---|
| Mount Point | The mount point of the filesystem. Swap partitions or specific files is set to 'none' |
| Filesystem Type | The filesystem type of this device. |
| Mount Options | Mount options used by the filesystem. 'defaults' refers to the filesystem defaults. |
| Dump | Determines how often the filesystem should be backed up by the dump program. 0 to never backup.
|
| Pass | Determines the order in which the fsck program will check devices for errors on startup. 1 for root filesystem. 2 to check after root. 0 to disable.
|
Tips
Remounting from Read-Only to Read-Write
You can remount something that's mounted read-only by using the remount option.
# mount -o remount,rw /
Mounting a disk image without root
Using udisksctl, you can mount disk images without requiring root or sudoers access.
$ dd if=/dev/zero of=test.img bs=1M count=100
$ udisksctl loop-setup -f test.img
Mapped file $PATH_TO_IMAGE as /dev/loop0.
Depending on your system, this may have triggered the loopmount to automount somewhere in /run/media/username. If nothing was mounted, manually mount the loopmount device:
$ udisksctl mount -b /dev/loop0
Mounted /dev/loop0 at /media/$USER/$IMAGE_NAME
To unmount the filesystem:
$ udisksctl unmount -b /dev/loop0
$ udisksctl loop-delete -b /dev/loop0
See Also: https://wiki.debian.org/ManipulatingISOs
Mounting disk image partitions
To mount a specific partition inside a disk image, use the fdisk utility to see where the partition boundaries are.
# fdisk -l out.bin
Disk out.bin: 58.6 MiB, 61440000 bytes, 120000 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: 0x000981cb
Device Boot Start End Sectors Size Id Type
out.bin1 8192 122879 114688 56M c W95 FAT32 (LBA)
out.bin2 122880 5785599 5662720 2.7G 83 Linux
The first partition starts on sector 8192. Since each sector is 512 bytes, we can mount this particular partition by passing an offset of 8192 * 512 bytes.
# mount -o loop,offset=$((8192 * 512)) out.bin /mnt/card
Alternatively, you may want to set up a loopback device specifically for a partition using losetup:
# losetup /dev/loop0 disk.img -o $((10860003 * 512))
# file -s /dev/loop0
/dev/loop0: Linux rev 1.0 ext3 filesystem data
# mount /dev/loop0 /mnt
[...]
# umount /mnt
# losetup -d /dev/loop0
Troubleshooting
The first time I ran mount -a, I got the following error:
root@server:~# mount -a
mount: wrong fs type, bad option, bad superblock on //box/Volume_1,
missing codepage or other error
In some cases useful info is found in syslog - try
dmesg | tail or so
with dmesg showing:
CIFS VFS: No username specified
CIFS VFS: cifs_mount failed w/return code = -22
Error -22 means the executable doesn't exist. To resolve this, install cifs-utils
# yum -y install cifs-utils
See Also
- http://madduck.net/blog/2006.10.20:loop-mounting-partitions-from-a-disk-image/
- https://en.wikipedia.org/wiki/Fstab