Pages

Saturday, 10 November 2012

Dreamplug with Debian Squeeze

The goal is to set up a new debian squeeze on the Dreamplug, using the New IT kernel. What is this about? It is about to put some bytes to an USB drive. This is not rocket science. In order to reduce the USB unplugs, I will create the whole image on a virtual disk image (a file), and dd it to the USB drive, as I am ready. With this, I don't have to do expensive file operations on the slow USB drive, only a sequential copy, which is usually fast. So here is a small list of what I have done. Create a root filesystem by using debootstrap:
sudo apt-get install debootstrap
sudo mkdir rootfs
sudo debootstrap --verbose --foreign \
--arch armel squeeze rootfs \
http://mirrors.kernel.org/debian
The root filesystem is not yet ready. As the kernel does not contain the udev system, if this root filesystem were booted, the following message would appear followed by a shutdown:
Warning: unable to open an initial console.
To avoid this, let us create the generic devices:
(
cd rootfs
sudo MAKEDEV generic
)
Now, it is time to create an 1G image:
dd if=/dev/zero of=debian.img bs=1024 count=1000000
Set up this disk as a disk device, and partition it.
sudo apt-get install kpartx
sudo kpartx -av debian.img
(
cat << EOF
,100,6
,,83
EOF
) | sudo sfdisk /dev/loop0 -u M -D
And so I created two primary partitions: 100M FAT16, and the rest as type LINUX. Let's unplug, and replug the device, so partitions are recognised:
sudo kpartx -d debian.img
sudo kpartx -av debian.img
From this point the two partitions are available as /dev/mapper/loop0p1 and /dev/mapper/loop0p2. Now I need to format the filesystems:
sudo mkfs.vfat /dev/mapper/loop0p1
sudo mkfs.ext3 /dev/mapper/loop0p2
sudo e2label /dev/mapper/loop0p2 pluggedroot
Place the kernel image to the first partition:
sudo mkdir p1
sudo mount /dev/mapper/loop0p1 p1
wget -O - \
http://dreamplug.googlecode.com/files/uImage-DreamPlug%20v9 |
 sudo dd of=p1/uImage
sudo umount p1
Please note, that although there is a newer kernel available, I am still using an elder one, because otherwise, the dmesg is full with messages related to gpio. The version that I have is:
Linux xxx 2.6.33.7-dirty #1 PREEMPT Tue Nov 29 06:13:06 EST 2011 armv5tel GNU/Linux
Now, copy the root filesystem to the second one:
sudo mkdir p2
sudo mount /dev/mapper/loop0p2 p2
sudo tar -cf - rootfs | sudo tar -xf - -C p2/ --strip-components=1
sudo umount p2
We can disconnect the virtual disk, and the partition mappings
sudo kpartx -d debian.img
Let us put it on a physical device:
time sudo dd if=debian.img of=/dev/sdb bs=1048576
That took around 40 seconds on my machine, using a Flash Voyager GT
976+1 records in
976+1 records out
1024000000 bytes (1.0 GB) copied, 38.7155 s, 26.4 MB/s

real0m38.734s
user0m0.000s
sys0m1.504s

Part 2 - on the Dreamplug

Let us see if I can use that USB stick at all on the Dreamplug device:
setenv x_bootcmd_kernel fatload usb 2:1 0x6400000 uImage
setenv x_bootargs_root root=/dev/sdc2 rootdelay=10 panic=10 init=/bin/bash
I also tried to specify root="LABEL=pluggedroot" but that failed. After it booted up, I finished the debootstrap:
/debootstrap/debootstrap --second-stage
You should see some lines showing up, and the latest is:
I: Base system installed successfully.
The serial console needs to be set:
echo 'T0:2345:respawn:/sbin/getty -L ttyS0 115200 linux' >> /etc/inittab
As well as the root password (I set it to the standard nosoup4u):
passwd root
Really important to flush the changes made to the filesystem:
sync
And leave the shell simply with:
exit
At this point, I disconnected my USB drive, and made a backup of it. With this action, I will have a snapshot, that could be easily modified according to my needs.
sudo dd if=/dev/sdb of=debian.phase2.img bs=1024 count=1000000
Boot to the new stuff. There is one thing that is interesting:
modprobe: FATAL: Could not load /lib/modules/2.6.33.7-dirty/modules.dep: No such file or directory
That needs to be fixed. The operating system's configuration will be covered in the next post.

References

No comments:

Post a Comment