boot to rootfs from looped image file?

This forum is for topics specific to the Raspberry Pi and Arch Linux ARM

boot to rootfs from looped image file?

Postby cv007 » Sun Jan 05, 2014 5:31 pm

I would like to boot from a single partition on the sd card- required boot files and a single image file as the root file system mounted as a loop device. Is this possible?

I would like to simply be able to take the boot files and a single image file and be able to copy it easily to another sd card (in Windows, no special utilities). Although I'm getting quite good at dd'ing images on my linux laptop, I'm getting quite tired of it. This would also create a simple way to backup or keep various images, etc.

I think the kernel has the required modules built in to do this, but I suspect I will still need to deal with initramfs stuff which I'm finding a little hard to understand.

Any pointers or suggestions where to start ?
cv007
 
Posts: 6
Joined: Sun Jan 05, 2014 2:38 pm

Re: boot to rootfs from looped image file?

Postby cv007 » Tue Jan 07, 2014 10:23 pm

I made a few laps around the internet, and think I may eventually get what I want (after a few dozen more laps around the internet, I'm sure).

If anyone else is interested, I can (poorly) document here what I'm doing. If not, I'll crawl back under my rock.

I can currently boot into an image file as the root file system. I have more work to do, but if I could get more than one sd card to be happy mounted in the pi, it would help. This is one reason for my quest- either most of the sd cards I have are crappy and will not work in the pi (they work everywhere else), or the pi is a fussy eater (my guess).
cv007
 
Posts: 6
Joined: Sun Jan 05, 2014 2:38 pm

Re: boot to rootfs from looped image file?

Postby pepedog » Wed Jan 08, 2014 12:57 am

Please continue.
Sd card, let them eat cake. Use a USB stick for image.
pepedog
Developer
 
Posts: 2431
Joined: Mon Jun 07, 2010 3:30 pm
Location: London UK

Re: boot to rootfs from looped image file?

Postby cv007 » Wed Jan 08, 2014 10:19 am

I would love to use a usb flash drive, but I'm using a model A and have a usb wifi dongle as my network connection. If I use a usb hub, then I may as well get the model B which is $10 more. In either case, I still would have the same problem- the pi not booting from most of my sd crads. Maybe I'm the only one with this problem,.
cv007
 
Posts: 6
Joined: Sun Jan 05, 2014 2:38 pm

Re: boot to rootfs from looped image file?

Postby cv007 » Thu Jan 09, 2014 2:43 am

I'm booting into my Pi with just these files on a single fat32 partition-

ArchLinuxArm.img
config.txt
initrootfs <<-- the only special file needed
start.elf
bootcode.bin
fixup.dat
kernel.img
start_cd.elf
cmdline.txt
fixup_cd.dat

I'll have to double check my instructions before I post them, and hopefully I can attach/upload the initrootfs file here.
cv007
 
Posts: 6
Joined: Sun Jan 05, 2014 2:38 pm

Re: boot to rootfs from looped image file?

Postby cv007 » Thu Jan 16, 2014 4:57 pm

supplies-
Model A Raspberry Pi (256MB, 1 usb port, no ethernet)- should also work on Model B
usb-serial adapter connected to pi (I don't use video, so this is my only initial link to pi)
sd card formatted to fat32 (if new card, is most likely already done)

programs-
terminal program of your choice (I use putty for both Windows and Linux)
7zip program (for Windows only, to extract boot.tar.gz files)

downloads-
http://os.archlinuxarm.org/os/rpi/boot.tar.gz (boot files)
http://os.archlinuxarm.org/os/rpi/root.tar.gz (root file system)

setup.sh (helper script)-
https://drive.google.com/uc?export=down ... zlCRVVvN2M

initrootfs (initramfs root)-
https://drive.google.com/uc?export=down ... mFiQjhkVDQ

cmdline.txt (optional- can edit existing file)
https://drive.google.com/uc?export=down ... 0xIWjZGWUU

config.txt (optional- can edit existing file)
https://drive.google.com/uc?export=down ... 3hfM3BNRDQ

* make sure you have the sd card formatted as fat/fat32
* extract boot.tar.gz to the sd card (the files to the root of the sd card)
* copy root.tar.gz to the sd card (no extract, just copy it)
* copy initrootfs to sd card
* copy setup.sh to the sd card

* edit the cmdline.txt file on the sd card as shown below (if not downloaded)
---cmdline.txt - the 1 line below---
$this->bbcode_second_pass_code('', 'break=4 loglevel=2 ipv6.disable=1 avoid_safe_mode=1 selinux=0 plymouth.enable=0 smsc95xx.turbo_mode=N dwc_otg.lpm_enable=0 console=tty1 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 root=/mmcblk0p1/ArchLinuxArm.img rootfstype=ext4 elevator=noop rootwait rw')

* edit the config.txt file on the sd card as shown below (if not downloaded)
---config.txt - the 2 lines below---
$this->bbcode_second_pass_code('', 'gpu_mem=16
initramfs initrootfs 0x00f00000')

=== cmdline.txt === notes ===
console=ttyAMA0 is listed after console=tty1 in order for the console to work in initramfs
root=/mmcblk0p1/ArchLinuxArm.img - this will be the root file system (will get setup inside initramfs)
rw (to make sure root is mounted rw)
break=4 (this will give an opportunity to break in the initramfs if needed)

=== config.txt === notes ===
I am not using video output, so I set gpu ram to minimum
the initramfs option specifies the filename and an address where to load it
(I chose the filename 'initrootfs', but can be anything)
(the address I found somewhere on the internet- thats all I know, but it seems to work)

$this->bbcode_second_pass_code('', '===============================================================================
summary of (necessary) files on sd card to setup Arch Linux Arm-
===============================================================================
bootcode.bin -boot code read by gpu bootloader
start.elf -loaded by bootcode.bin
start_cd.elf -cut down version of start.elf (when gpu_mem=16)
fixup.dat -sdram info I think
fixup_cd.dat
kernel.img -the linux kernel loaded by start.elf (or start_cd.elf)
cmdline.txt -command line parameters passed to the kernel
config.txt -configuration options
root.tar.gz -the latest Arch Linux Arm root file system (for rpi)
initrootfs -the 'initial' root file system copied to ram
setup.sh -shell functions to create the loop file
===============================================================================')

connect terminal program to serial port device
put sd card into pi, power up pi
initramfs looproot script will run setup since the image file does not exist
(setup will not run if either setup.sh or root.tar.gz do not exist)
follow instructions to create the image file
(YES enter 1000 enter YES enter will get you a 1GB image)

should now be booted into ArchLinuxArm
username/password= root/root


I am not a Linux guru, but this is working for me. I tested it with an 8GB micro sd card, and an 8GB usb flash drive. Both were formatted to fat32 in Windows. If you want to change what image file you are using, or want to create a new one, change the 'root=' value in cmdline.txt. If I wanted to use a usb drive, I would make it something like this- 'root=/sda1/myarch.img', if using an sd card and only 1 partition (normal), it would be something like this- 'root=/mmcblk0p1/myarch.img'.

The 'break=' value in cmdline.txt can be- looproot , premount, postmount, or a value between 2 and 10-
break=looproot -break to interactive shell at the beginning of the looproot 'hook' function
break=sec (2 to 10, like break=5) -like looproot, but break if a B is pressed within 'sec' seconds
break=premount -break to interactive shell in init function before it tries to mount root
break=postmount -break to interactive shell in init function after it mounts root
cv007
 
Posts: 6
Joined: Sun Jan 05, 2014 2:38 pm

Re: boot to rootfs from looped image file?

Postby pepedog » Thu Jan 16, 2014 7:45 pm

I can't see how these got onto card
bootcode.bin -boot code read by gpu bootloader
start.elf -loaded by bootcode.bin
start_cd.elf -cut down version of start.elf (when gpu_mem=16)
fixup.dat -sdram info I think
fixup_cd.dat
kernel.img -the linux kernel loaded by start.elf (or start_cd.
pepedog
Developer
 
Posts: 2431
Joined: Mon Jun 07, 2010 3:30 pm
Location: London UK

Re: boot to rootfs from looped image file?

Postby cv007 » Thu Jan 16, 2014 9:39 pm

* make sure you have the sd card formatted as fat/fat32
* extract boot.tar.gz to the sd card (the files to the root of the sd card)
* copy root.tar.gz to the sd card (no extract, just copy it)
* copy initrootfs to sd card
* copy setup.sh to the sd card


Maybe needs to be worded better-
* extract the files from the boot.tar.gz file, and put them in the root folder of the sd card
cv007
 
Posts: 6
Joined: Sun Jan 05, 2014 2:38 pm

Re: boot to rootfs from looped image file?

Postby pepedog » Thu Jan 16, 2014 11:39 pm

My eyes must have missed that. Well done
pepedog
Developer
 
Posts: 2431
Joined: Mon Jun 07, 2010 3:30 pm
Location: London UK


Return to Raspberry Pi

Who is online

Users browsing this forum: No registered users and 0 guests