Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[Solved] Gentoo on compactflash card
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
MacGyver031
Tux's lil' helper
Tux's lil' helper


Joined: 11 Jul 2004
Posts: 141
Location: Ilavalai, Sri Lanka

PostPosted: Tue Jan 31, 2012 10:30 am    Post subject: [Solved] Gentoo on compactflash card Reply with quote

Hi folks,
I have been playing around with gentoo on compactflash. So far I have managed to set up and run Gentoo on squashfs but I have failed in getting the system to run on flashdisk with the known structure (/bin /boot ....).

For those who do not want to read long threads to get to the question:
How can I mount /dev/sda1 readonly and overlay with aufs.ko so that I can mount /dev/sda1 to manually commit changes without using genkernel? I would be happy if I could mount /dev/sda1 to /mnt/sda1 on the "newroot", but I doesn't work (reported error: "/dev/sda1 is already mounted on /mnt/disk", force mounting results in empty /mnt/sda1).

My approach was create initrd.gz (includes busybox and modprobe), mount the flash readonly at /mnt/flash, create a tmpfs on /tmp, and use aufs to overlay /mnt/disk with /tmp to /mnt/root (this is my "newroot") so that changes are faked to write on disk. Then handover to /mnt/root and startup /sbin/init. This works well, but I am unable to mount /dev/sda1 on "newroot"/mnt/sda1 so that I can manually commit changes to /etc.
As I have said, as soon as I would like to mount "newroot"/mnt/sda1, mount denies to do so.

init (softlinked to linuxrc) thus far:
Code:

#!/bin/sh

mount none /proc -t proc
mount none /sys -t sysfs

mount /dev/sda1 /mnt/flash -o ro
modprobe aufs
mount none /tmp -t tmpfs
mount none /mnt/root -t aufs -o dirs=/tmp:/mnt/flash

umount /sys
umount /proc

exec switch_root /mnt/root /sbin/init

_________________
Sincerely your
Joanand K.

MacBook Pro 5.1: 2.4GHz Core2 Duo, 4096MB, 500GB, NVidia 9400/9600 M GT
Gentoo, Kernel 3.4.9, XOrg, Fluxbox.


Last edited by MacGyver031 on Thu Feb 02, 2012 2:43 pm; edited 1 time in total
Back to top
View user's profile Send private message
MacGyver031
Tux's lil' helper
Tux's lil' helper


Joined: 11 Jul 2004
Posts: 141
Location: Ilavalai, Sri Lanka

PostPosted: Thu Feb 02, 2012 2:42 pm    Post subject: [Solved] Gentoo on compactflash card Reply with quote

Hi,
After some trial and kernel panics, I got it working:

Basically you have to mount the drive to /mnt/flash in RAM, create /newroot in RAM, bind /mnt/flash/tmp (which lies on the flash) to tmpfs.
Then you overlay with AUFS /mnt/flash and /mnt/flash/tmp to /newroot, then move the mount to /newroot/mnt/sda1 and then switch_root.

Effectively (I have made everything modular, so I had to load necessary modules manually)
Code:

#!/bin/sh
## Project:     Embedded Gentoo (mini- and micro-servants)
## Date:        February 01, 2012
## Author:      Joanand Kuharajasekaram
## Copyright:   1995-2012, Mac Industries
##
## Description: Gentoo on Wrap, Alix, Acer, Dell and others with flash and aufs.

clear
echo "Mac Industries Five Thousand"

mount none /proc -t proc -o noexec,nosuid,nodev >/dev/null 2>&1
mount none /sys -t sysfs -o noexec,nosuid,nodev >/dev/null 2>&1

modprobe -q sd_mod
modprobe -q ext2

## Qemu-KVM:
modprobe -q ata_piix

## Wrap:
#modprobe -q pata_sc1200

## Alix:
#modprobe -q pata_cs5536

mount /dev/sda1 /mnt/flash -o ro

modprobe -q aufs

mount none /mnt/flash/tmp -t tmpfs
mkdir -p /newroot
mount none /newroot -t aufs -o dirs=/mnt/flash/tmp:/mnt/flash
mkdir -p /newroot/mnt/sda1
mount --move /mnt/flash /newroot/mnt/sda1

umount /sys
umount /proc
exec switch_root /newroot /sbin/init


With this, I now have the possibility to remount /mnt/sda1 rw and save changes. I have also seen the approach of Gentoo-LiveCD, which creates links to read-only directories and copies of /etc, /root and /home to the tmpfs /. This approach uses more memory in my application than aufs.

Aufs: Total memory usage 22MB
Tmpfs with copy (ala LiveCD, with squashfs): Total memory usage 80MB

If someone needs help in creating initrd, do not hesistate to ask.
_________________
Sincerely your
Joanand K.

MacBook Pro 5.1: 2.4GHz Core2 Duo, 4096MB, 500GB, NVidia 9400/9600 M GT
Gentoo, Kernel 3.4.9, XOrg, Fluxbox.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum