Skip to content
Micah Henning edited this page May 7, 2020 · 3 revisions

Mount Process for Debugging

# Uncompress Ubuntu image
$ unxz ubuntu-bionic.img.xz

# View partition table
$ fdisk ubuntu-bionic.img.xz

Welcome to fdisk (util-linux 2.34).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Command (m for help): p
Disk ubuntu-bionic.img: 2.45 GiB, 2624517120 bytes, 5126010 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: 0xda84cd12

Device             Boot  Start     End Sectors  Size Id Type
ubuntu-bionic.img1 *      2048  526335  524288  256M  c W95 FAT32 (LBA)
ubuntu-bionic.img2      526336 5125975 4599640  2.2G 83 Linux

# Mount image using offset, which is the block size * the starting block
# For ubuntu-bionic.img1, 512 * 2048 = 1048576
# For ubuntu-bionic.img2, 512 * 526336 = 269484032
$ sudo mkdir -p /mnt/chroot
$ sudo mount -o loop,offset=1048576 ubuntu-bionic.img /mnt/chroot # for the boot partition
$ sudo mount -o loop,offset=269484032 ubuntu-bionic.img /mnt/chroot # for the root partition

# Mount system partitions to enable chroot
$ sudo mount -t proc none /mnt/chroot/proc
$ sudo mount -t sysfs none /mnt/chroot/sys
$ sudo mount -o bind /dev /mnt/chroot/dev
$ sudo mount -o bind /dev/pts /mnt/chroot/dev/pts
$ sudo mkdir /mnt/chroot/run/systemd                      # if root partition
$ sudo mount -o bind /run/systemd /mnt/chroot/run/systemd # for dns resolution

# Allow ARM emulation with QEMU
$ sudo cp /usr/bin/qemu-aarch64-static /mnt/chroot/usr/bin/

# chroot
$ sudo LANG=C chroot /mnt/chroot
Clone this wiki locally