Step 4 : Mount the image

  • In this program, you are going to learn

  • How to ?

Topics in this section,

  • Get the correct offset value using fdisk command

test:_qemu_rpi4b_linux$ fdisk -l 2023-12-05-raspios-bullseye-arm64.img
Disk 2023-12-05-raspios-bullseye-arm64.img: 4.25 GiB, 4563402752 bytes, 8912896 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: 0xcd9d3b46

Device                                 Boot  Start     End Sectors  Size Id Type
2023-12-05-raspios-bullseye-arm64.img1        8192  532479  524288  256M  c W95 FAT32 (LBA)
2023-12-05-raspios-bullseye-arm64.img2      532480 8912895 8380416    4G 83 Linux
  • Mount the image in /mnt/rpi directory.

$ sudo mkdir /mnt/rpi
$ sudo mount -o loop,offset=4194304 2023-12-05-raspios-bullseye-arm64.img /mnt/rpi
  • Create a file name ssh to enable ssh.

$ cd /mnt/rpi
$ sudo touch ssh
  • Create a userconf.txt to store the credentials.

$ sudo touch userconf.txt
  • Create the username and password the OS using openssl command.

test:~$ openssl passwd -6
Password:
Verifying - Password:
$6$9HzsE8vYjPJWtvGf$mLbbuPcdNjWwYeJz3avtblgJR4R/kP72J8xVIitu7AMmnfoaMuZn1KkgKFs5Bg38da50z.Euh7YpjK5Zo.0bp1
  • add the credentials in the userconf.txt

$ echo pi:$6$9HzsE8vYjPJWtvGf$mLbbuPcdNjWwYeJz3avtblgJR4R/kP72J8xVIitu7AMmnfoaMuZn1KkgKFs5Bg38da50z.Euh7YpjK5Zo.0bp1 | sudo tee userconf.txt
  • go to the directory qemu_rpi_3b and umount the image.

$ cd $HOME/qemu_rpi_3b
$ sudo umount /mnt/rpi