X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=2019-fosdem%2Fpaper%2Ffosdem-rjones-better-loopback-paper.tex;h=f6bcf6bb730ea051620fbb3ea706bcc67781ffee;hb=4507e94c3ba68dbf455a9399de5f4ac1732eb5b7;hp=6a0e47f708faa02a39a682a8ed3f18a9a1187a8a;hpb=11cec0e3dd88fa2eab119aaa087c0a9f120eb267;p=libguestfs-talks.git diff --git a/2019-fosdem/paper/fosdem-rjones-better-loopback-paper.tex b/2019-fosdem/paper/fosdem-rjones-better-loopback-paper.tex index 6a0e47f..f6bcf6b 100644 --- a/2019-fosdem/paper/fosdem-rjones-better-loopback-paper.tex +++ b/2019-fosdem/paper/fosdem-rjones-better-loopback-paper.tex @@ -1,3 +1,10 @@ +% TODO: +% Can we use nbdkit to test kernel limits? +% - max size (already mostly covered) +% - max number of partitions: +% try 128 partitions with GPT +% then modify GPT code to try > 128 partitions + \documentclass[12pt,a4paper]{article} \usepackage[utf8x]{inputenc} \usepackage{parskip} @@ -183,15 +190,75 @@ gone, making this very useful for testing filesystems. \section{Concatenating files into a partitioned disk} -\textit{In the talk this section will talk about creating a virtual - disk with a virtual partition table using the nbdkit - ``partitioning'' plugin.} +Whereas loopback mounts are limited to a single file, there are +several nbdkit plugins for combining files. One of them is called the +``partitioning'' plugin, and it turns partitions into disk images: + +\begin{verbatim} +$ nbdkit partitioning \ + boot.img \ + swap.img \ + root.img +\end{verbatim} + +This time I'll use \texttt{guestfish} to examine this virtual disk: + +\begin{verbatim} +$ guestfish --format=raw -a nbd://localhost -i + +Welcome to guestfish, the guest filesystem shell for +editing virtual machine filesystems and disk images. + +Type: ‘help’ for help on commands + ‘man’ to read the manual + ‘quit’ to quit the shell + +Operating system: Fedora 26 (Twenty Six) +/dev/sda3 mounted on / +/dev/sda1 mounted on /boot + +> list-filesystems +/dev/sda1: ext4 +/dev/sda2: swap +/dev/sda3: xfs +\end{verbatim} + +You can see that the NBD disk contains three +partitions\footnote{\texttt{/dev/sdX} inside libguestfs is equivalent + to \texttt{/dev/nbd0} on the host}. \section{Mounting a VMware VMDK file} -\textit{In the talk this section will talk about modifying VMware VMDK - files using the nbdkit ``vddk'' plugin.} +VMware VMDK disk images are difficult to open on Linux machines. +VMware provides a proprietary library to handle them, and nbdkit has a +plugin to handle this library (the plugin is free software, but the +VMware library that it talks to is definitely not). We can use this +to loopback mount VMDK files: + +\begin{verbatim} +# nbdkit vddk file=TestLinux-disk1.vmdk +# nbd-client -b 512 localhost 10809 /dev/nbd0 +\end{verbatim} + +This disk image contains two partitions and several logical volumes. +The Linux kernel finds them all automatically: + +\begin{verbatim} +# file -bsL /dev/nbd0p1 +Linux rev 1.0 ext4 filesystem data, UUID=9d1d5cb7-b453-48ac-b83b-76831398232f (needs journal recovery) (extents) (huge files) +# file -bsL /dev/nbd0p2 +LVM2 PV (Linux Logical Volume Manager), UUID: bIY2oM-CgAN-npqG-gItS-WY6e-wO7d-L6G3Bv, size: 8377444864 +# ls /dev/vg_testlinux/ +lv_root lv_swap +\end{verbatim} + +You can read and write to VMDK files this way: + +\begin{verbatim} +# mount /dev/vg_testlinux/lv_root /mnt +# touch /mnt/hello +\end{verbatim} \section{Testing a RAID array}