Outils pour utilisateurs

Outils du site


articles:linux_mount

Ceci est une ancienne révision du document !


Linux mount & usage

La commande mount de Linux permet de connecter un file-system sur un folder linux; le plus simple et le plus connu étant le fameux mount /dev/sbxx; mais Linux est tellement capable de faire mieux (et plus).

Ce billet/article est avant tout un post-it de mes notes.

Monter une image disque

On peut lister les partitions d'une image, au même titre qu'une “vrai” disque:

<cli> root@hades-vm:~# fdisk -l /home/frater/images/recalbox.img

Disk recalbox.img: 1.9 GiB, 2002632192 bytes, 3911391 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: 0x00000000

Device Boot Start End Sectors Size Id Type recalbox.img1 1263 132334 131072 64M c W95 FAT32 (LBA) recalbox.img2 132335 3911390 3779056 1.8G 83 Linux </cli>

les deux paramètres qui nous intéressent ici sont “Units” et la colonne “Start”; ces informations font nous permettre de calculer l'offset DANS le fichier image que vous désirez monter.

ici, notre bloc size (unit) est de 512 bytes.

<cli>

1263*512 = 646656     # offset for partition #1

132335*512 = 67755520 # offset for partition #2 </cli>

Une fois cette valeur d'offset calculée, on peut la passer à la commande mount, via l'option “-o”:

<cli> root@hades-vm:~# mkdir /mnt/rec-img # create the mounting folder (if not already present) root@hades-vm:~# mount -o loop,offset=67755520 recalbox.img /mnt/rec-img/ # mount second partition </cli>

Monter un serveur distant via SSH

Qui n'a jamais rêver de pouvoir modifier des fichiers distants sans pour autant se charger de les uploader?

Cette note suppose que vous avez 2 linux disponibles (je n'ai pas tester via ces machines Windows).

sur le “serveur” (pc distant) il faut s'assurer d'avoir un user local pouvant se connecter en SSH et qui dispose des droits suffisant sur le folder que l'on désire accéder.

sur le “client” il faut installer les outils sshfs:

<cli> root@hades-vm:~# apt install sshfs Reading package lists… Done Building dependency tree… Done Reading state information… Done The following additional packages will be installed:

fuse3

The following NEW packages will be installed:

fuse3 sshfs

0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded. Need to get 81.6 kB of archives. After this operation, 227 kB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://deb.debian.org/debian bookworm/main amd64 fuse3 amd64 3.14.0-4 [35.9 kB] Get:2 http://deb.debian.org/debian bookworm/main amd64 sshfs amd64 3.7.3-1.1 [45.6 kB] Fetched 81.6 kB in 0s (519 kB/s) Selecting previously unselected package fuse3. (Reading database … 42718 files and directories currently installed.) Preparing to unpack …/fuse3_3.14.0-4_amd64.deb … Unpacking fuse3 (3.14.0-4) … Selecting previously unselected package sshfs. Preparing to unpack …/sshfs_3.7.3-1.1_amd64.deb … Unpacking sshfs (3.7.3-1.1) … Setting up fuse3 (3.14.0-4) … Setting up sshfs (3.7.3-1.1) … root@hades-vm:~# modprobe fuse # not sure that it's still necessary </cli>

mount first time

<cli> root@hades-vm:~# sshfs -o idmap=user,allow_other -C -p 1234 remote_ssh_frater@heaven-hades.noloop.cloud:/home/frater /mnt/remote-heaven/ The authenticity of host '172.16.0.254 (172.16.0.254)' can't be established. ED25519 key fingerprint is SHA256: C9tEvcWVV6U9GNYfwQVpRiyxwfmnEBEovmsYqShk6k5. This key is not known by any other names. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes (remote_ssh_frater@heaven-hades.noloop.cloud) Password for remote_ssh_frater@heaven-hades: </cli>

Vous devez confirmer et vérifier votre fingerprint.

Vous devrez également vous authentifier en suivant les politiques d’authentification du serveur distant (mot de passe et/ou clé publique, mfa, etc.).

Si aucune erreur n'est affichée, vous pourrez lire et écrire dans le dossier /home/frater du serveur, via le folder local /mnt/remote-heaven/.

quelques informations sur les paramètres:

-C : enable compression
-o : idmap ?
   : allow_other : allow other users to use the mount point (ex root or other local user)

Démonter la connexion:

<cli> root@hades-vm:~# umount /mnt/remote-heaven/ </cli>

Mount read-only NTFS

device

mount -t NTFS -o ro /dev/sdxx /mnt/loop

image

mount -t vfat -o loop,ro,noexec image.img /mnt/loop

mount -t vfat -o loop,ro,noexec,offset=63 image.img /mnt/loop

Mount windows Network Share

install pre-requis:

<cli> root@hades-vm:~# apt-get install cifs-utils </cli>

temporary mount: <cli> root@hades-vm:~# mount -t cifs [SERVER.DOMAIN.LOCAL]/[SHARE] /mnt/[MOUNT_DIR] -o username=[USERNAME],password=[PASSWORD],domain=[DOMAIN_OR_WORKGROUP] </cli> or if you have credentials file. <cli> root@hades-vm:~# mount -t cifs [SERVER.DOMAIN.LOCAL]/[SHARE] /mnt/[MOUNT_DIR] -o credentials=/root/.smbcredentials </cli>

permanent mount:

<cli> root@hades-vm:~# nano /etc/fstab </cli>

ajouter cette ligne à la fin

[SERVER.DOMAIN.LOCAL]/[SHARE] /mnt/[MOUNT_DIR] cifs credentials=/root/.smbcredentials,iocharset=utf8 0 0

credentials file

if you put .smbcredentials in home dir, only that user can mount the drive and view the credentials.

example of /root/.smbcredentials

username=[USERNAME]
password=[PASSWORD]
domain=[DOMAIN_OR_WORKGROUP]

don't forget to chmod rw only for root. and remove read right for other

Mounting macOSX filesystem

install "drivers"

<cli> root@hades-vm:~# apt-get install hfsplus </cli>

mount drive in Read Only

<cli> root@hades-vm:~# mkdir /media/loop # create folder if needed root@hades-vm:~# mount -o ro /dev/hdxx /media/loop -t hfsplus </cli>

dismount

<cli> root@hades-vm:~# umount /media/loop </cli>

articles/linux_mount.1719582067.txt.gz · Dernière modification : de frater