Xen Zynq Distribution Support Forums
kpartx won't mount root partition - Printable Version

+- Xen Zynq Distribution Support Forums (http://xzdforums.dornerworks.com)
+-- Forum: General Xilinx Support (http://xzdforums.dornerworks.com/forumdisplay.php?fid=1)
+--- Forum: Public Support (http://xzdforums.dornerworks.com/forumdisplay.php?fid=6)
+--- Thread: kpartx won't mount root partition (/showthread.php?tid=696)



kpartx won't mount root partition - jrheisey - 07-11-2017

Here are the steps from the document from DornerWorks Xen-Zynq-Distribution-XZD-Users-Manual.pdf

Quote:1. Create a new clean two partition image.
   $ dd if=/dev/zero of=$RELEASE_DIR/dist/images/sdcard.img bs=1G count=7
   $ echo -e "n\np\n1\n\n+256M\nt\nc\nn\np\n2\n\n\nt\n2\n83\nw\n" | fdisk
   $RELEASE_DIR/dist/images/sdcard.img
2. Install kpartx if it is not already.
   $ sudo apt-get install kpartx
3. Mount both partitions of the image using kpartx.
   sudo kpartx -av $RELEASE_DIR/dist/images/sdcard.img
   sudo mkfs.vfat /dev/mapper/loop1p1
   sudo mkfs.ext4 /dev/mapper/loop1p2

I am using CentOS as a guest of VirtualBox with Windows 7 as the host OS.
I have a couple of issues with the document.
  • For dd I changed the count=7 to count=15 for my larger SD card.
  • The string piped to fdisk did not work out-of-the-box. I needed to manually run fdisk to create the two partitions.
  • The string shows the first partition set to the system ID of 'c' which is 'W95 FAT32 (LBA)'.
          I tried leaving it at the default of '83' for 'Linux' but it did not change the behavior of kpartx.
  • Result of kpartx
         $ sudo kpartx -av $RELEASE_DIR/dist/images/sdcard.img
         [sudo] password for username:
         add map loop0p2 (253:2): 0 14680001 linear /dev/loop0 63
  • mkfs.*: loop1 part of loop1p1 reference is not appropriate for my system because it is mounting as loop0. Easy to compensate.
  • In the two mkfs.vfat command loop0p1 is not mounted at all just loop0p2.
My specific question is why kpartx won't mount the root partition of sdcard.img?


Results from fdisk -l
Code:
Disk /media/sf_projects/RDP3/XZD_20161231/dist/images/sdcard.img: 16.1 GB, 16106127360 bytes, 31457280 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
Disk label type: dos
Disk identifier: 0x322d1bed
                                                      Device Boot      Start         End      Blocks   Id  System
/media/sf_projects/RDP3/XZD_20161231/dist/images/sdcard.img1            2048     2099199     1048576   83  Linux
/media/sf_projects/RDP3/XZD_20161231/dist/images/sdcard.img2         2099200    31457279    14679040   83  Linux



RE: kpartx won't mount root partition - jarvis_roach - 07-12-2017

(07-11-2017, 09:10 PM)jrheisey Wrote: Here are the steps from the document from DornerWorks Xen-Zynq-Distribution-XZD-Users-Manual.pdf

Quote:1. Create a new clean two partition image.
   $ dd if=/dev/zero of=$RELEASE_DIR/dist/images/sdcard.img bs=1G count=7
   $ echo -e "n\np\n1\n\n+256M\nt\nc\nn\np\n2\n\n\nt\n2\n83\nw\n" | fdisk
   $RELEASE_DIR/dist/images/sdcard.img
2. Install kpartx if it is not already.
   $ sudo apt-get install kpartx
3. Mount both partitions of the image using kpartx.
   sudo kpartx -av $RELEASE_DIR/dist/images/sdcard.img
   sudo mkfs.vfat /dev/mapper/loop1p1
   sudo mkfs.ext4 /dev/mapper/loop1p2

I am using CentOS as a guest of VirtualBox with Windows 7 as the host OS.
I have a couple of issues with the document.
  • For dd I changed the count=7 to count=15 for my larger SD card.
  • The string piped to fdisk did not work out-of-the-box. I needed to manually run fdisk to create the two partitions.
  • The string shows the first partition set to the system ID of 'c' which is 'W95 FAT32 (LBA)'.
          I tried leaving it at the default of '83' for 'Linux' but it did not change the behavior of kpartx.
  • Result of kpartx
         $ sudo kpartx -av $RELEASE_DIR/dist/images/sdcard.img
         [sudo] password for username:
         add map loop0p2 (253:2): 0 14680001 linear /dev/loop0 63
  • mkfs.*: loop1 part of loop1p1 reference is not appropriate for my system because it is mounting as loop0. Easy to compensate.
  • In the two mkfs.vfat command loop0p1 is not mounted at all just loop0p2.
My specific question is why kpartx won't mount the root partition of sdcard.img?


Results from fdisk -l
Code:
Disk /media/sf_projects/RDP3/XZD_20161231/dist/images/sdcard.img: 16.1 GB, 16106127360 bytes, 31457280 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
Disk label type: dos
Disk identifier: 0x322d1bed
                                                      Device Boot      Start         End      Blocks   Id  System
/media/sf_projects/RDP3/XZD_20161231/dist/images/sdcard.img1            2048     2099199     1048576   83  Linux
/media/sf_projects/RDP3/XZD_20161231/dist/images/sdcard.img2         2099200    31457279    14679040   83  Linux

J.R., 
Not sure why the fdisk isn't working for you... were there any error messages? One thought is that there might be some differences due to the version of Linux you're using. Officially we support Ubuntu 16.04, unofficially we've done this on other Linux distros like Mint, but I don't think anyone on our team has a VM running CentOS. Here's the version of fdisk I have:

Quote:jarvis@jarvis-VirtualBox ~ $ fdisk -v

fdisk (util-linux 2.20.1)

As for the kpartx failing to mount both partitions, were there any error messages? What is the result of `ls \dev\mapper` ?


If `kpartx` isn't working for you, you can also try:

Quote:sudo losetup -f

to find an available loop device, say "loopN"

Quote:sudo losetup /dev/loopN test.img -o 1048576

to get it setup as a loopback device.



Regards,

-Jarvis