How to deploy files to /boot partition with Yocto - linux

I'm trying to deploy some binary files to /boot in a Yocto image for RPi CM3 but it deploys them to the wrong location.
do_install() {
install -d ${D}/boot/overlays
install -m 0664 ${WORKDIR}/*.dtb ${D}/boot/overlays/
install -m 0664 ${WORKDIR}/*.dtbo ${D}/boot/overlays/
}
The files are deployed to /boot in the / partition of the final image, but not to the /boot partition. So they are not available at boot time.
I already googled and studied the kernel recipes (and classes) of the Poky distribution but I didn't find the mechanism it uses how to ensure that the files are deployed to the boot image (and not to the /boot dir in the root image).
Any help is appreciated :)
Update #1
In my local.conf I did:
IMAGE_BOOT_FILES_append = " \
overlays/3dlab-nano-player.dtbo \
overlays/adau1977-adc.dtbo \
...
"
And in my rpi3-overlays.bb
do_deploy() {
install -d ${DEPLOYDIR}/${PN}
install -m 0664 ${WORKDIR}/*.dtb ${DEPLOYDIR}/${PN}
install -m 0664 ${WORKDIR}/*.dtbo ${DEPLOYDIR}/${PN}
touch ${DEPLOYDIR}/${PN}/${PN}-${PV}.stamp
}
Using this the image builds, but the files stillt don't get deployed in the /boot partition.
Using RPI_KERNEL_DEVICETREE_OVERLAYS I get a build error because the kernel recipe tries to build the dtbo files like dts files.

RPI images are created with sdimage-raspberrypi.wks WIC wks file. It contains:
part /boot --source bootimg-partition ...
so it uses bootimg-partition.py wic plugin to generate /boot partition. It copies every files defined by IMAGE_BOOT_FILES variable.
It seems you want to add some devicetree overlays, so you need to modify machine configuration and more specifically RPI_KERNEL_DEVICETREE_OVERLAYS variable. IMAGE_BOOT_FILES variable is set in rpi-base.inc.
If you don't have any custom machine or custom distro defined, you can add it in local.conf:
RPI_KERNEL_DEVICETREE_OVERLAYS_append = " <deploy-path>/<dto-path>"
You can see here how to add files in deploy directory.

After too many hours of investigation it turned out, that deploying files to other partitions than / is not easily possible. I now went the way of a post-processing script that mounts the final image, deploys the additional files and unmounts it.
# Ensure the first loopback device is free to use
sudo -n losetup -d /dev/loop0 || true
# Create a loopback device for the given image
sudo -n losetup -Pf ../deploy/images/bapi/ba.rootfs.rpi-sdimg
# Mount the loopback device
mkdir -p tmp
sudo -n mount /dev/loop0p1 tmp
# Deploy files
sudo -n cp -n ../../meta-ba-rpi-cm3/recipes-core/rpi3-overlays/files/* tmp/overlays/
sudo -n cp ../../conf/config.txt tmp/config.txt
sudo -n cp ../../conf/cmdline.txt tmp/cmdline.txt
# Unmount the image and free the loopback device
sudo -n umount tmp
sudo -n losetup -d /dev/loop0

Related

How to mount azure file share to existing directory on linux vm

I have an existing directory on an Ubuntu 16.04 LTS virtual machine at /etc/elasticsearch. I also have created a file share in azure. I am able to mount file share to the VM successfully when the mount point is a new directory. However, when I attempt to mount the file share to /etc/elasticsearch, an existing directory that contains data, the existing directory's data gets overwritten completely by the contents of the file share. This causes me to lose the data that previously existed in /etc/elasticsearch, which I obviously do not want. I want the file share to be added in addition to the existing data in /etc/elasticsearch.
Here is what I tried:
if [ ! -d "/etc/smbcredentials" ]; then
sudo mkdir /etc/smbcredentials
fi
if [ ! -f "/etc/smbcredentials/credentials.cred" ]; then
sudo bash -c 'echo "username=username" >> /etc/smbcredentials/credentials.cred'
sudo bash -c 'echo "password=password" >> /etc/smbcredentials/credentials.cred'
fi
sudo chmod 600 /etc/smbcredentials/credentials.cred
sudo bash -c 'echo "//pathtofileshare/analysis /etc/elasticsearch cifs nofail,vers=3.0,credentials=/etc/smbcredentials/credentials.cred,dir_mode=0777,file_mode=0777,serverino" >> /etc/fstab'
sudo mount -t cifs //pathtofileshare/analysis /etc/elasticsearch -o vers=3.0,credentials=/etc/smbcredentials/credentials.cred,dir_mode=0777,file_mode=0777,serverino
Link to file share documentation
Many thanks in advance for any help
I don't believe this is an issue, it just how Linux mount works
http://man7.org/linux/man-pages/man8/mount.8.html
The previous contents (if any) and owner and mode of dir become invisible, and as long as this filesystem remains mounted, the pathname dir refers to the root of the filesystem on device.

How to install wget on LFS system

I am pretty newbie to Linux and started LFS because I needed it for school. So my system is now perfectly running with an internet connection, but I still don't have any packet manager or something. The first binary I would like to have is basically wget, but I really don't know how to do...
Could someone explain to me please ?
I personally used (and would highly recommend) using the existing Linux system (the host) to download the wget package and its dependencies before booting your LFS system for the first time. However, seeing that you're already using your LFS system, if you still have the ability to log using the host, then use it to download wget as if it was one of the sources that you got when building the LFS system.
For me, I used a Linux Mint Host running in VirtualBox to build my LFS. To get wget I just had to re-add the Linux Mint host storage, and download wget and added it to the LFS sources. I then removed the Linux Mint host storage, logged in to my LFS machine, then followed the steps in BLFS.
Note: this is mainly just from parts of lfs and the wget page of blfs.
1. Boot into your host OS.
2. Enter the following commands in the command line to get into chroot(edit depending on your partitions and where you mount lfs):
sudo su -
export LFS=/mnt/lfs
mount -vt ext4 /dev/sda4 $LFS
mount -v --bind /dev $LFS/dev
mount -vt devpts devpts $LFS/dev/pts -o gid=5,mode=620
mount -vt proc proc $LFS/proc
mount -vt sysfs sysfs $LFS/sys
mount -vt tmpfs tmpfs $LFS/run
if [ -h $LFS/dev/shm ]; then
mkdir -pv $LFS/$(readlink $LFS/dev/shm)
fi
chroot "$LFS" /usr/bin/env -i \
HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
PATH=/bin:/usr/bin:/sbin:/usr/sbin \
/bin/bash --login
3. Download wget from http://ftp.gnu.org/gnu/wget/wget-1.19.1.tar.xz and copy it into /mnt/lfs/sources from your host os.
4. Unpack and cd into it with:
tar -xf wget-1.19.1.tar.xz
cd wget-1.19.1
5. Configure and install wget with:
./configure --prefix=/usr \
--sysconfdir=/etc \
--with-ssl=openssl &&
make
make install
6. Delete the wget-1.19.1 folder if you want and your done!

Testing a linux kernel in qemu [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I have just built the 3.13.3 kernel from kernel.org on my ubuntu 12.04 computer. I ran the make menuconfig command and then I did make which built the kernel and the modules. I want to run the kernel in the qemu emulator (qemu-system-x86_64) so I can start testing and building on top of it. Curently I am getting it to run with qemu-system-x86_64 -kernel bzImage however it is not booting properly. What changes should I make in order to make the kernel boot properly?
You need to have a bootable disk first of all. Have you tried booting without -kernel and specifying the disk to boot from ?
If and only if that works, then think about using -kernel as an optimization
to test out new kernels
Making a bootable disk can be a challenge unless you take the easy route and use dd to make a large empty file e.g.
sudo dd if=/dev/zero of=$OUTPUT_DISK bs=4096 count=524288
then boot qemu with the linux iso you downloaded and also tell it to use this disk (-hda) and let the installer set the disk up for you
If making a bootable disk by hand, I've done this a couple of times - not easy, but the following steps may help you. You need to format the disk, create partitions, install grub and then boot
Personally I would take the easy route and install to disk via linux installer
#!/bin/sh
#
# Change these settings
#
INPUT_ISO=mydownloadedlinux.iso
OUTPUT_DISK=mydisk
KERNEL_IMAGE_NAME=linux-kernel
QEMU=qemu-system-x86_64
#
# Stuff you should not need to change
#
TMP_BOOTDISK=/tmp/disk.$$
ISO_MOUNT_DIR=/mnt/iso
#
# Choose DOS or Linux disks
#
PARTITION_TYPE=ext2
MKFS_TYPE=ext2
#
# Mount the ISO
#
sudo mkdir -p $ISO_MOUNT_DIR
sudo umount $ISO_MOUNT_DIR 2>/dev/null
sudo mount -o loop -t iso9660 $INPUT_ISO $ISO_MOUNT_DIR
#
# Make a new disk
#
sudo dd if=/dev/zero of=$OUTPUT_DISK bs=4096 count=524288
LOOP=`sudo losetup -f --show $OUTPUT_DISK`
LOOPDEV=`echo $LOOP | sed 's/.*loop/loop/g'`
echo "Loopback device $LOOP, ($LOOPDEV)"
#
# Make two partitions on the disk
#
sudo parted -s $LOOP mktable msdos \
mkpart primary $PARTITION_TYPE 32K 50% \
mkpart primary $PARTITION_TYPE 50% 95%
#
# Make one bootable
#
sudo parted -s $LOOP set 1 boot on
sudo kpartx -l $LOOP
sudo kpartx -a $LOOP
#
# Make the filesystems
#
sudo mkfs.$MKFS_TYPE /dev/mapper/${LOOPDEV}p1
sudo mkfs.$MKFS_TYPE /dev/mapper/${LOOPDEV}p2
#
# List what we made
#
sudo kpartx -l -v $LOOP
#
# Mount this temporary disk so we can install grub on it
#
sudo mkdir -p $TMP_BOOTDISK
sudo mount /dev/mapper/${LOOPDEV}p1 $TMP_BOOTDISK
sudo grub-install --boot-directory=/$TMP_BOOTDISK $LOOP
#
# Make grub boot config
#
cat >/tmp/grub.cfg <<%%
serial
#terminal_input --append serial_com0
#terminal_output --append serial_com0
configfile /mybootfile
%%
cat >/tmp/mybootfile <<%%
set timeout=5
set default=0
menuentry 'mylinux' {
insmod ext2
set root='(hd0,1)'
linux /$KERNEL_IMAGE_NAME bigphysarea=28000
initrd /rootfs.img.gz
}
%%
#
# Just copy all the files off of the ISO into the mounted temp disk
# This would be the tricky part as you need enough so linux can boot
#
sudo cp -r $ISO_MOUNT_DIR/* $TMP_BOOTDISK
#
# But use our grub files we made above
#
sudo cp /tmp/grub.cfg $TMP_BOOTDISK/grub/grub.cfg
sudo cp /tmp/mybootfile $TMP_BOOTDISK/mybootfile
#
# Show all the files on the temp disk and then unmuont it
#
find $TMP_BOOTDISK
sudo umount $TMP_BOOTDISK
sudo losetup -d $LOOP
#
# Convert the temp disk from raw to vmdk format
#
sudo qemu-img convert $OUTPUT_DISK -O vmdk $OUTPUT_DISK.vmdk
#
# Boot the vmdk
#
sudo $QEMU -boot d -m 4096 \
-enable-kvm \
-drive file=$OUTPUT_DISK.vmdk,if=virtio,media=disk \
-serial telnet:localhost:4444,nowait,server,telnet \
-net nic,model=e1000,vlan=0 -net user \

how to make a .ubi file from .tar.gz

How can i make a .ubi file from a .tar.gz or folder if this is possible at all?
I looked at this (did not help me):
Creating UBI Image
To create the image from a rootfs you've built first you need to create the ubi.ini file, that describes your ubi image. Create a regular text file, ubi.ini, example contents, for more info run ubinize -h:
[ubi_rfs]
mode=ubi
image=ubifs.img
vol_id=0
vol_size=87349248
vol_type=dynamic
vol_name=ubi_rfs
vol_alignment=1
vol_flags=autoresize
Next you'll run the commands that actually build it. Here ubi.ini is the file you just created, ubifs.img is a temp file you can delete once you are done, and your_erootfs.ubi is the name of the rootfs image that will be created.
sudo /usr/sbin/mkfs.ubifs -m 2048 -e 129024 \
-c 677 -r /path/to/rootfs ubifs.img
sudo /usr/sbin/ubinize -o your_erootfs.ubi \
-p 131072 -m 2048 -s 512 -O 512 ubi.ini
Note the part in the mkfs command that says
-r /path/to/rootfs
Un-tar your tar.gz file and use the resulting directory as the destination for -r.

Xen clone vm can't be created

I'm working with Xen 4.0 on a debian Lenny (5.0) .
I wanted to clone a VM , but it seems that i didn't do it well . What i did is the following :
Creating the config file of the new VM and setting it up.
#cd /etc/xen/vms/
#cp original.foo.com.cfg copy.foo.com.cfg
Copying virtual disks
#cd /dev/mapper/
#cp -rv vg--xen-original.foo.com--disk vg--xen-copy.foo.com--disk
#cp -rv vg--xen-original.foo.com--swap vg--xen-copy.foo.com--swap
#chmod g+w vg--xen-copy.foo.com--*
#chown root:disk vg--xen-copy.foo.com--*
Symlinks
#cd /dev/vg-xen/
#ln -s ../mapper/vg--xen-copy.foo.com--disk copy.foo.com-disk
#ln -s ../mapper/vg--xen-copy.foo.com--disk copy.foo.com-disk
Everything is set up, let's create the VM
#xm create /ect/xen/vms/copy.foo.com.cfg
#Using config file "./copy.foo.com.cfg".
#Error: Device 51714 (vbd) could not be connected.
#Device /dev/mapper/vg--copy.foo.com--disk is mounted in a guest domain,
#and so cannot be mounted now.
Could you please help me sort out that issue ?
All i wanted was to duplicate original.foo.com
Thanks
I found the solution.
#lvcreate -L size -n VM_NAME-disk xen-data
#lvcreate -L size -n VM_NAME-swap xen-data
Then a byte by byte copy
#dd if=/dev/mapper/vg-xen-original.foo.com--disk of=/dev/mapper-vg-xen-copy.foo.com--disk
#dd if=/dev/mapper/vg-xen-original.foo.com--swap of=/dev/mapper-vg-xen-copy.foo.com--swap
Et VoiĆ  !!!

Resources