User avatar
ukscone
Forum Moderator
Forum Moderator
Posts: 4152
Joined: Fri Jul 29, 2011 2:51 pm
Contact: Website

Re: Using the debian rootfs with the development vm

Fri Feb 17, 2012 10:08 pm

i just grabbed the debian rootfs and installed it in the development vm so that it can be used with scratchbox2.

there are simpler ways (use the mount offset option) to do this but this is the way I am used to.

sudo losetup -o 80740352 /dev/loop0 debian6-17-02-2012.imgsudo mkdir /mnt/debrootfssudo mount /dev/loop0 /media/debrootfs then use your favourite method to copy whole directory trees of files from one place to another to copy all the files and dirs in debrootfs to a directory in $HOME/raspberry_pi_developmentsay raspi_debianand then cd $HOME/raspberry_pi_development/sudo chown -R raspberry raspi_debian/*sudo chgrp -R raspberry raspi_debian/*sudo chmod -R 777 raspi_debian/* cd raspi_debiansb2-init raspberry_deb $HOME/raspberry_pi_development/arm-2011.03/bin/arm-none-linux-gnueabi-gcc  and that's pretty much it.

User avatar
ukscone
Forum Moderator
Forum Moderator
Posts: 4152
Joined: Fri Jul 29, 2011 2:51 pm
Contact: Website

Re: Using the debian rootfs with the development vm

Fri Feb 17, 2012 10:09 pm

oh and don't worry your little heads about where I got the 80740352 from it's just magic

liamfraser280
Posts: 354
Joined: Tue Oct 04, 2011 6:53 pm
Contact: Website

Re: Using the debian rootfs with the development vm

Fri Feb 17, 2012 10:20 pm

Looks great mate

Will have to try that out.

Where did you dl from in the end?

User avatar
ukscone
Forum Moderator
Forum Moderator
Posts: 4152
Joined: Fri Jul 29, 2011 2:51 pm
Contact: Website

Re: Using the debian rootfs with the development vm

Fri Feb 17, 2012 10:22 pm

grabbed it using bittorrent in my windows host and setup a shared folder between the vm and windohs!

thorium
Posts: 1
Joined: Fri Feb 17, 2012 11:30 pm

Re: Using the debian rootfs with the development vm

Fri Feb 17, 2012 11:38 pm

oh and don"t worry your little heads about where I got the 80740352 from it"s just magic

It"s the sector in the image where file system starts times the sector size (157696*512)

User avatar
ukscone
Forum Moderator
Forum Moderator
Posts: 4152
Joined: Fri Jul 29, 2011 2:51 pm
Contact: Website

Re: Using the debian rootfs with the development vm

Fri Feb 17, 2012 11:45 pm

Thorium said:


oh and don"t worry your little heads about where I got the 80740352 from it"s just magic

It"s the sector in the image where file system starts times the sector size (157696*512)


correct



and another interesting offset is 1048576 which is the offset to the fat partition

User avatar
grumpyoldgit
Posts: 1452
Joined: Thu Jan 05, 2012 12:20 pm

Re: Using the debian rootfs with the development vm

Sat Feb 18, 2012 9:34 am

ukscone said:


i just grabbed the debian rootfs and installed it in the development vm so that it can be used with scratchbox2.

there are simpler ways (use the mount offset option) to do this but this is the way I am used to.

sudo losetup -o 80740352 /dev/loop0 debian6-17-02-2012.imgsudo mkdir /mnt/debrootfssudo mount /dev/loop0 /media/debrootfs then use your favourite method to copy whole directory trees of files from one place to another to copy all the files and dirs in debrootfs to a directory in $HOME/raspberry_pi_developmentsay raspi_debianand then cd $HOME/raspberry_pi_development/sudo chown -R raspberry raspi_debian/*sudo chgrp -R raspberry raspi_debian/*sudo chmod -R 777 raspi_debian/* cd raspi_debiansb2-init raspberry_deb $HOME/raspberry_pi_development/arm-2011.03/bin/arm-none-linux-gnueabi-gcc  and that's pretty much it.

I've not used virtual machines in Linux before so this is a bit new to me. I have Lubuntu 11.10.

On the third line sudo mount /dev/loop0 /media/debrootfs 
I get mount: mount point /media/debrootfs does not exist Any idea what I am doing wrong?
 

liamfraser280
Posts: 354
Joined: Tue Oct 04, 2011 6:53 pm
Contact: Website

Re: Using the debian rootfs with the development vm

Sat Feb 18, 2012 9:41 am

Hi grumpyoldgit,

You mount media into a directory. If the directory /media/debrootfs doesn't exist then you'll probably get that message above.

You should just need to do a 'mkdir /media/debrootfs/'

Hope this helps,

Liam.

stek
Posts: 1
Joined: Sat Feb 18, 2012 1:39 pm

Re: Using the debian rootfs with the development vm

Sat Feb 18, 2012 1:56 pm




The more simple way to mount the image, as mentioned by ukscone:

($ sudo mkdir /media/debrootfs)

($ sudo losetup -d /dev/loop0)

$ sudo mount -o loop=/dev/loop0,offset=80740352 debian6-17-02-2012.img /media/debrootfs/

The magic numbers (divided/multiplied by 512, the sector size) can be extracted from the image file using `fdisk`:

$ fdisk -l -u debian6-17-02-2012.img

User avatar
piglet
Posts: 908
Joined: Sat Aug 27, 2011 1:16 pm

Re: Using the debian rootfs with the development vm

Sat Feb 18, 2012 8:34 pm

*edit* trying again

jannis
Posts: 56
Joined: Tue Jan 17, 2012 3:48 pm

Re: Using the debian rootfs with the development vm

Fri Feb 24, 2012 9:58 am

If you want to extract the single partitions to use them with an ARM emulator (qemu) and not to mount them:

For the FAT-part (where the GPU, boot and kernel stuff is):

dd bs=512 if=debian6-17-02-2012.img of=debian6-17-02-2012-fat.img skip=2048 count=76800

For the ext4 (rootfs)-part:

dd bs=512 if=debian6-17-02-2012.img of=debian6-17-02-2012-rootfs.img skip=157696 count=1628160

User avatar
jojopi
Posts: 3084
Joined: Tue Oct 11, 2011 8:38 pm

Re: Using the debian rootfs with the development vm

Fri Feb 24, 2012 11:12 am

jannis said:


If you want to extract the single partitions to use them with an ARM emulator (qemu) and not to mount them:

dd bs=512 if=debian6-17-02-2012.img of=debian6-17-02-2012-rootfs.img skip=157696 count=1628160


You do not actually need to extract the partitions for qemu, since the operating system understands partitions just as it would on real hardware.  In fact, it may be better not to extract the partitions, so that you can easily access the swap partition, and can return the image to an SD card later.

If you do wish to extract the partitions it is worth noting that they are all exact multiples of 1MiB in both size and position, as is the modern practice.  This allows a much more efficient block size on the 'dd's:dd if=debian6-17-02-2012.img of=d6boot.raw bs=1M skip=1 count=75
dd if=debian6-17-02-2012.img of=d6root.raw bs=1M skip=77 count=1590
dd if=debian6-17-02-2012.img of=d6swap.raw bs=1M skip=1668 count=191

jannis
Posts: 56
Joined: Tue Jan 17, 2012 3:48 pm

Re: Using the debian rootfs with the development vm

Fri Feb 24, 2012 1:21 pm

jojopi said:


You do not actually need to extract the partitions for qemu, since the operating system understands partitions just as it would on real hardware.  In fact, it may be better not to extract the partitions, so that you can easily access the swap partition, and can return the image to an SD card later.


True, you don't have to extract the partitions. But you can It was rather meant for reference.


If you do wish to extract the partitions it is worth noting that they are all exact multiples of 1MiB in both size and position, as is the modern practice.  This allows a much more efficient block size on the 'dd's:dd if=debian6-17-02-2012.img of=d6boot.raw bs=1M skip=1 count=75
dd if=debian6-17-02-2012.img of=d6root.raw bs=1M skip=77 count=1590
dd if=debian6-17-02-2012.img of=d6swap.raw bs=1M skip=1668 count=191

Didn't notice this, though. Thanks for pointing it out

Return to “Other projects”