Search notes:

loop device

A loop device allows to use a regular file as a block device. «Within» that regular file, a filesystem can then mounted just as any other block device (such as hart drive partitions).
If the file does not contain a file system, one can also be created with the usual tools.

Mounting a copy of a Windows partition

A loop device can for example be used to mount a copy of a Windows partition.
First, we need to prepare a directory into which we copy the partition:
$ sudo mkdir /backup-windows
$ cd         /backup-windows
The Windows partition is on /dev/nvme0n1p3 (the 3rd partition of the 1st namespace of the NVMe device):
$ sudo dd if=/dev/nvme0n1p3 bs=1M of=nvme0n1p3
Find an unused loop device, …
$ /usr/sbin/losetup  -f
/dev/loop0
… create the loop device …
$ sudo /usr/sbin/losetup /dev/loop0 /backup-windows/nvme0n1p3
… and mount it:
$ sudo mkdir /backup-windows/mnt
$ sudo mount /dev/loop0 /backup-windows/mnt
The mounted files have 777 (rwxrwxrwx) permissions, so I, as ordinary user, can access them:
$ cd /backup-windows/mnt/
$ ls
$ mount | grep /dev/loop0
/dev/loop0 on /backup-windows/mnt type fuseblk (rw,relatime,user_id=0,group_id=0,allow_other,blksize=4096)
Note that I also found a (smaller) version of losetup under /usr/lib/klibc/bin.

See also

/dev/loopX
The shell commands losetup and udisksctl.

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/Linux/lo...', 1759391373, '216.73.216.42', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/Linux/loop-device(82): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78