:: Re: [DNG] alternative to raspbian w…
Página Inicial
Delete this message
Reply to this message
Autor: Gregory Nowak
Data:  
Para: dng
Assunto: Re: [DNG] alternative to raspbian without systemd
Hi all,
I'm back with an update on this, and a mini howto. First, thanks to
everyone who provided various suggestions regarding both hardware and
software. I ended up getting a raspberry pi2 b+. I did consider the
bananapi as well. While I like the sata port, there were a few things
where the raspberrypi (rpi) seemed better for me, and that's what I
got. I also did end up getting the serial cable. That turns out to
have been a good move as well, since I wouldn't have been able to do
without it what I'm about to describe below.

I am currently running devuan on my rpi, which I've taken to thinking
of as raspvuan. This is a devuan jessie armhf port installed by debootstrap,
with pi specific packages from raspbian. I originally wanted to see if
I could do this by doing the initial debootstrap on the pc, chrooting
into the unpacked system, and running debootstrap --second-stage to
complete the rest of the process. This didn't work out for me for a
couple of reasons. I started out with a /boot containing kernel and
firmware from raspbian jessie 7.8. I made a fresh ext4 file system on
the second partition of the sd card, mounted it on the pc, and did an
initial debootstrap with the debootstrap from devuan providing armhf
as the arch, and the --foreign option; that went well. I attempted to
then boot from this sd card on the rpi. I got as far as initialized
random pool, and waiting for root fs. This could be for a couple of
reasons. First, I forgot I was trying to boot into a system which was
unpacked, but hadn't been setup yet. Second, I forgot to enable agetty
on ttyAMA0. Third, I forgot to add ttyAMA0 to /etc/securetty. Fourth,
I didn't modify the newly created /etc/shadow (which I'm not even sure
exists at this stage) to remove the * from root's password entry. So,
at that point I realized this would require two sd cards, one with a
running system, and one to do the install on. You could likely use a
usb drive for the install, but you'll then need to get the image off
the usb drive, and on to the sd card. I already had another sd card
with raspbian wheezy on it, so attempted to use that for the running
system, leaving my initial install done on the pc on the second sd
card, which I put into a usb card reader, and attached to the
rpi. When I attempted to chroot, I got something like: cannot chroot
bin/bash execv format error. So, wheezy's kernel must not be fully
compatible with armhf as found in jessie.

With my initial attempts and their failure documented, I'll proceed to
document what to do to get a raspvuan jessie minimal install on the
rpi2. You will need:
1. A micro sd card with a freshly written raspbian jessie image. You
can find that at: <http://www.raspberrypi.org/downloads>.

2. A second blank micro sd card in a usb card reader. Like I said, you
can probably use a usb drive instead, but you'll need to transfer the
image off it after you're done.

3. A rpi connected to the internet. I don't have a linux-compatible
wifi usb card here, so used an ethernet cable.

4. Usb keyboard and screen, or an appropriate pl2303 usb serial cable
between the rpi, and computer. I used the serial console.

5. The rpi itself, and a power supply.


Insert your sd card with raspbian jessie into the rpi, plug in your
usb reader with the second sd card into the rpi, make whatever other
connections you need, and apply power to the rpi. Once the rpi boots,
login as pi with raspberry as the password. Become root: $ sudo bash
Create your partitions. I use cfdisk for this: # cfdisk


Label: dos, identifier: 0xe786f943

    Device       Boot       Start        End    Sectors    Size   Id
    Type
    /dev/sda1                2048     104447     102400     50M    c
    W95 FAT32 (LBA)

>>  /dev/sda2              104448    2201599    2097152      1G   83

    Linux



You can of course make the partitions whatever size you'd
like. Reboot. I found out the hard way that partition changes on the
rpi don't seem to stick until a reboot is done.
# reboot
Log back in, and sudo bash.
format your file systems: # mkfs.msdos /dev/sda1
# mkfs.ext4 /dev/sda2
Mount the root fs: # mount /dev/sda2 /mnt
get and install devuan's debootstrap:
# wget
http://packages.devuan.org/devuan/pool/main/d/debootstrap/debootstrap_1.0.75-1%2bdevuan1_all.deb
# dpkg -i debootstrap_1.0.75-1+devuan1_all.deb

Let's debootstrap our new system:
# debootstrap jessie /mnt http://packages.devuan.org/merged

Watch it download/extract, or go do something else. Once the base
system installs successfully, mount remaining file systems:

# mount /dev/sda1 /mnt/boot
# mount --bind /proc /mnt/proc
# mount --bind /sys /mnt/sys
# mount --bind /dev /mnt/dev

Copy over some needed files:
# cp -a /boot/config.txt /mnt/boot/
# cp -a /boot/cmdline.txt /mnt/boot/
# cp -a /etc/fstab /mnt/etc/
# cp -a /etc/apt/sources.list.d/raspi.list
/mnt/etc/apt/sources.list.d/

I like the suggestion dev1fanboy gave in his devuan upgrade howto on
running lean (especially on embedded devices), so:
# echo 'APT::Install-Suggests "0";
APT::Install-Recommends "0";
APT::AutoRemove::SuggestsImportant "false";
APT::AutoRemove::RecommendsImportant "false";'
>/mnt/etc/apt/apt.conf.d/01lean


Ok, we're ready to chroot into our new system!

# chroot /mnt bin/bash

Let's run apt-get update: # apt-get update
You'll get a message at the end that the archive key for raspbian is
not available; we'll deal with that next. We want to install some
packages next. If you know what you're doing, you can
leave any of these out. At the very least, you will want to install
raspberrypi-bootloader, or rpi-update; else you'll end up with an unbootable
system. We have isc-dhcp-client already installed, but let's apt-get
install it, so it doesn't get removed because of the lean settings we
made earlier:

# apt-get install isc-dhcp-client
# apt-get install raspbian-archive-keyring

You'll be asked whether to install these packages without
verification. Type y and press enter. As the packages install, you'll
see messages like these:

"perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = (unset),
        LC_ALL = (unset),
        LANG = "en_GB.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_CTYPE to default locale: No such file or
directory
locale: Cannot set LC_MESSAGES to default locale: No such file or
directory
locale: Cannot set LC_ALL to default locale: No such file or directory
E: Can not write log (Is /dev/pts mounted?) - posix_openpt (2: No such
file or directory)"


This is because we haven't installed locales yet, and we're running in
a chroot. You can ignore these as far as I know. Speaking of locales
... let's take care of that next:
# apt-get install locales
You can configure your locale and time zone either with:

# dpkg-reconfigure locales
# dpkg-reconfigure tzdata

or by using raspi-config if you've installed that. Even though we
installed the raspbian-archive-keyring package, running apt-get still
gives an error, at least for me it does. So, let's fix that:

# apt-key adv --keyserver keys.gnupg.net --recv-keys 82B129927FA3303E

Ok, let's install the other packages:

# apt-get install ca-certificates
# apt-get install aptitude
# apt-get install dosfstools
# apt-get install fake-hwclock
# apt-get install ntpdate
# apt-get install openssh-server
# apt-get install rpi-update
or
# apt-get install raspberrypi-bootloader
# apt-get install raspi-config
# apt-get install sudo

If you installed rpi-update instead of raspberrypi-bootloader, run
that now: # rpi-update
Ok, we're almost done! We can either set a password for root, or add a
pi user who can do sudo. Since we have openssh installed, let's create
the pi user:
# adduser pi
# usermod -a -G sudo pi

If you want to login on the serial console, you need to edit
/etc/inittab in whatever editor you're comfortable. By default, nano
and vi are installed. If you prefer something else, go ahead and
apt-get install it. In /etc/inittab, find the line which reads:

#T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100

and change it to read:

T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100

If you created a password for root, and want to allow root to login on
the serial console, you need to add ttyAMA0 to /etc/securetty. Next,
we need to setup eth0 to get an address via dhcp:

# echo "allow-hotplug eth0
iface eth0 inet dhcp" >/etc/network/interfaces.d/eth0

We're almost ready to reboot. Let's exit the chroot:
# exit
Umount file systems:
# umount /mnt/proc
# umount /mnt/sys
# umount /mnt/dev
# umount /mnt/boot
# umount /mnt

I couldn't umount /mnt/dev, because target was busy. Maybe I shouldn't
have mounted /dev as mount --bind /dev /mnt/dev, but in some other way?
That means I couldn't umount /mnt either ... oh well. Ok, let's
shutdown:
# poweroff
Replace the sd card in your pi's sd slot with the one in the usb
reader, or transfer the image from your flash drive to your sd
card. Cross your fingers, and power up the pi. If all went well, you
should be able to login as user pi with a password of raspberry on the
serial console, over ssh, and on the keyboard. You will notice there
is no swap. For the purposes of this mini howto, I didn't need it. If
you need it, you can either create a partition for it, or apt-get
install dphys-swapfile. A couple of things worth noting:

$ cat /etc/devuan_version
jessie
$ aptitude search '~i systemd'
It isn't installed, none of it!

Copyright (C) 2015 Gregory Nowak.
Permission is granted to copy, distribute and/or modify this e-mail
    under the terms of the GNU Free Documentation License, Version 1.3
    or any later version published by the Free Software Foundation;
    with no Invariant Sections, no Front-Cover Texts, and no
    Back-Cover Texts.
    A copy of the license can be found at <http://www.gnu.org/licenses/fdl.html>.


Some of you may be wondering why I used the raspberrypi foundation
package repos for the rpi-specific packages instead of
repositories.collabora.co.uk. The short answer is that when I tried, I
ran into all sorts of problems.

If there is enough interest, I can put an image of devuan jessie for
the pi2 on www.gregn.net. However, at this time, I only have this one
rpi, and it will be serving as my router. So, I won't be able to
reboot it whenever I wish. This means that while I can chroot into
such an image to update, I can't verify that it still remains
bootable. I am very tempted to get another pi to experiment with, but
that won't be happening for a few months, if it happens at all. I also
read that the rpi can be emulated on qemu. If that's correct, I may be
able to experiment in that environment; I'll have to look into this.

I haven't done many debootstraps, and this is my second successful
attempt on the rpi. I'm sure there's a better way to do what I did
here. Constructive comments are welcome. Enjoy.

Greg


--
web site: http://www.gregn.net
gpg public key: http://www.gregn.net/pubkey.asc
skype: gregn1
(authorization required, add me to your contacts list first)
If we haven't been in touch before, e-mail me before adding me to your contacts.

--
Free domains: http://www.eu.org/ or mail dns-manager@???