From fdba081e1501cf1cdfc37145d2dc3acd5bcf9720 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Thu, 28 Mar 2013 15:28:27 +0100 Subject: [PATCH] many small fixed to make it ready for an image --- PrepareRaspbianImage.md | 20 ------- copy_to_final.sh | 15 +++++ filesystem/create_user.sh => create_user.sh | 2 + {filesystem => fs}/etc/rc.local | 4 +- .../home/kitten}/kitten_mount_dst | 0 .../home/kitten}/kitten_mount_src | 0 .../groomer => fs/home/kitten}/kitten_umount | 0 {filesystem => fs}/opt/groomer/constraint.sh | 4 +- .../opt/groomer/constraint_conv.sh | 0 {filesystem => fs}/opt/groomer/functions.sh | 0 {filesystem => fs}/opt/groomer/groomer.sh | 0 {filesystem => fs}/opt/groomer/init.sh | 5 +- {filesystem/opt/groomer => old}/g_function.sh | 0 {filesystem/opt/groomer => old}/sedKillSpace | 0 prepare_rPI.sh | 9 ++- proper_chroot.sh | 15 +++-- resize_img.md | 57 +++++++++---------- 17 files changed, 67 insertions(+), 64 deletions(-) delete mode 100644 PrepareRaspbianImage.md create mode 100755 copy_to_final.sh rename filesystem/create_user.sh => create_user.sh (86%) mode change 100644 => 100755 rename {filesystem => fs}/etc/rc.local (84%) rename {filesystem/opt/groomer => fs/home/kitten}/kitten_mount_dst (100%) rename {filesystem/opt/groomer => fs/home/kitten}/kitten_mount_src (100%) rename {filesystem/opt/groomer => fs/home/kitten}/kitten_umount (100%) rename {filesystem => fs}/opt/groomer/constraint.sh (93%) rename {filesystem => fs}/opt/groomer/constraint_conv.sh (100%) rename {filesystem => fs}/opt/groomer/functions.sh (100%) rename {filesystem => fs}/opt/groomer/groomer.sh (100%) rename {filesystem => fs}/opt/groomer/init.sh (78%) rename {filesystem/opt/groomer => old}/g_function.sh (100%) rename {filesystem/opt/groomer => old}/sedKillSpace (100%) mode change 100644 => 100755 prepare_rPI.sh diff --git a/PrepareRaspbianImage.md b/PrepareRaspbianImage.md deleted file mode 100644 index be5a202..0000000 --- a/PrepareRaspbianImage.md +++ /dev/null @@ -1,20 +0,0 @@ -Prerequisites -============= - -Get the latest image: http://www.raspberrypi.org/downloads (the recommended one) -And write it on the SD Card: -dd bs=4M if=~/2013-02-09-wheezy-raspbian.img of=/dev/mmcblk0 - -Note: I had to unplug/replug the sd card in order to see the second partition. - -On a debian/ubuntu host: -- http://burstcoding.blogspot.com/2012/12/qemu-user-mode-arm-for-raspbian-chroot.html (not tested) -On a gentoo host: -- app-emulation/qemu-user - -Choot -===== - -chroot - - diff --git a/copy_to_final.sh b/copy_to_final.sh new file mode 100755 index 0000000..c5b971c --- /dev/null +++ b/copy_to_final.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +CHROOT_PATH='/mnt/arm_rPi' + +if [ "$(id -u)" != "0" ]; then + echo "This script must be run as root" 1>&2 + exit 1 +fi + +# copy deb +cp deb/*.deb ${CHROOT_PATH}/ + +# prepare fs archive +tar -cvpzf backup.tar.gz -C fs/ . +tar -xzfv backup.tar.gz -C ${CHROOT_PATH}/ diff --git a/filesystem/create_user.sh b/create_user.sh old mode 100644 new mode 100755 similarity index 86% rename from filesystem/create_user.sh rename to create_user.sh index 373b22a..31f5f94 --- a/filesystem/create_user.sh +++ b/create_user.sh @@ -5,3 +5,5 @@ useradd -m kitten echo "Cmnd_Alias GROOMER_CMDS = /home/kitten/kitten_mount_src, \ /home/kitten/kitten_mount_dst, /home/kitten/kitten_umount" >> /etc/sudoers echo "kitten ALL=(ALL) NOPASSWD: GROOMER_CMDS" >> /etc/sudoers + +# /!\ REMOVE SUDO RIGHTS TO USER pi diff --git a/filesystem/etc/rc.local b/fs/etc/rc.local similarity index 84% rename from filesystem/etc/rc.local rename to fs/etc/rc.local index 1fc5435..bd27260 100755 --- a/filesystem/etc/rc.local +++ b/fs/etc/rc.local @@ -17,11 +17,9 @@ if [ "$_IP" ]; then printf "My IP address is %s\n" "$_IP" fi -PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin - if [ -e /dev/sda ]; then if [ -e /dev/sdb ]; then - /opt/groomer/groomer.sh + /opt/groomer/init.sh /sbin/shutdown -h now fi fi diff --git a/filesystem/opt/groomer/kitten_mount_dst b/fs/home/kitten/kitten_mount_dst similarity index 100% rename from filesystem/opt/groomer/kitten_mount_dst rename to fs/home/kitten/kitten_mount_dst diff --git a/filesystem/opt/groomer/kitten_mount_src b/fs/home/kitten/kitten_mount_src similarity index 100% rename from filesystem/opt/groomer/kitten_mount_src rename to fs/home/kitten/kitten_mount_src diff --git a/filesystem/opt/groomer/kitten_umount b/fs/home/kitten/kitten_umount similarity index 100% rename from filesystem/opt/groomer/kitten_umount rename to fs/home/kitten/kitten_umount diff --git a/filesystem/opt/groomer/constraint.sh b/fs/opt/groomer/constraint.sh similarity index 93% rename from filesystem/opt/groomer/constraint.sh rename to fs/opt/groomer/constraint.sh index 6d5a77d..2506d52 100644 --- a/filesystem/opt/groomer/constraint.sh +++ b/fs/opt/groomer/constraint.sh @@ -1,5 +1,5 @@ -DEV_SRC='/dev/sdf' -DEV_DST='/dev/sdg1' +DEV_SRC='/dev/sda' +DEV_DST='/dev/sdb1' # User allowed to do the following commands without password USERNAME='kitten' HOME="/home/${USERNAME}" diff --git a/filesystem/opt/groomer/constraint_conv.sh b/fs/opt/groomer/constraint_conv.sh similarity index 100% rename from filesystem/opt/groomer/constraint_conv.sh rename to fs/opt/groomer/constraint_conv.sh diff --git a/filesystem/opt/groomer/functions.sh b/fs/opt/groomer/functions.sh similarity index 100% rename from filesystem/opt/groomer/functions.sh rename to fs/opt/groomer/functions.sh diff --git a/filesystem/opt/groomer/groomer.sh b/fs/opt/groomer/groomer.sh similarity index 100% rename from filesystem/opt/groomer/groomer.sh rename to fs/opt/groomer/groomer.sh diff --git a/filesystem/opt/groomer/init.sh b/fs/opt/groomer/init.sh similarity index 78% rename from filesystem/opt/groomer/init.sh rename to fs/opt/groomer/init.sh index 8fc6f45..fb95aff 100755 --- a/filesystem/opt/groomer/init.sh +++ b/fs/opt/groomer/init.sh @@ -12,8 +12,7 @@ fi clean(){ echo Done, cleaning. - # Only if running on a rPi - # mount -o remount,rw / + mount -o remount,rw / ${SYNC} # shutdown -h now } @@ -21,7 +20,7 @@ clean(){ trap clean EXIT TERM INT # Remount the root filesystem in RO mode -# mount -o remount,ro / +mount -o remount,ro / su ${USERNAME} -c ./groomer.sh diff --git a/filesystem/opt/groomer/g_function.sh b/old/g_function.sh similarity index 100% rename from filesystem/opt/groomer/g_function.sh rename to old/g_function.sh diff --git a/filesystem/opt/groomer/sedKillSpace b/old/sedKillSpace similarity index 100% rename from filesystem/opt/groomer/sedKillSpace rename to old/sedKillSpace diff --git a/prepare_rPI.sh b/prepare_rPI.sh old mode 100644 new mode 100755 index a78f162..2a0dc4b --- a/prepare_rPI.sh +++ b/prepare_rPI.sh @@ -1,9 +1,12 @@ #!/bin/bash +# change locales to en_US.UTF-8 +dpkg-reconfigure locales + + apt-get update apt-get dist-upgrade apt-get autoremove -apt-get install libreoffice -dpkg -i libpoppler28_0.20.5-3_armhf.deb libpoppler-private-dev_0.20.5-3_armhf.deb \ - pdf2htmlex_0.8-1~git201303011406r3bc73-0ubuntu1_armhf.deb +apt-get install libreoffice libfontforge1 p7zip-full +dpkg -i libpoppler28_0.20.5-3_armhf.deb pdf2htmlex_0.8-1~git201303011406r3bc73-0ubuntu1_armhf.deb diff --git a/proper_chroot.sh b/proper_chroot.sh index 49ee68d..e15c12f 100755 --- a/proper_chroot.sh +++ b/proper_chroot.sh @@ -1,9 +1,18 @@ #!/bin/bash +if [ "$(id -u)" != "0" ]; then + echo "This script must be run as root" 1>&2 + exit 1 +fi +ls /usr/bin/qemu*arm* > /dev/null 2>&1 +if [ ! -e ${?} ]; then + echo "You need qemu user static binaries." 1>&2 + exit 1 +fi + set -e set -x - # If you use a partition... PARTITION_ROOTFS='/dev/mmcblk0p2' PARTITION_BOOT='/dev/mmcblk0p1' @@ -46,9 +55,6 @@ else exit fi -# only needed at first chroot, but it does not hurt. -#resize2fs /dev/loop1 - cp /usr/bin/qemu*arm* ${CHROOT_PATH}/usr/bin/ mount -o bind /dev ${CHROOT_PATH}/dev @@ -59,6 +65,7 @@ mount -o bind /sys ${CHROOT_PATH}/sys mount -o bind /tmp ${CHROOT_PATH}/tmp cp -pf /etc/resolv.conf ${CHROOT_PATH}/etc + mv ${CHROOT_PATH}/etc/ld.so.preload ${CHROOT_PATH}/etc/ld.so.preload_bkp chroot ${CHROOT_PATH} diff --git a/resize_img.md b/resize_img.md index 3a123be..fbd3fc8 100644 --- a/resize_img.md +++ b/resize_img.md @@ -1,26 +1,16 @@ -dd if=/dev/zero bs=1024k count=2048 >> 2013-02-09-wheezy-raspbian.img +Add empty space to the image +============================ -fdisk 2013-02-09-wheezy-raspbian.img -Command (m for help): m -Command action - a toggle a bootable flag - b edit bsd disklabel - c toggle the dos compatibility flag - d delete a partition - l list known partition types - m print this menu - n add a new partition - o create a new empty DOS partition table - p print the partition table - q quit without saving changes - s create a new empty Sun disklabel - t change a partition's system id - u change display/entry units - v verify the partition table - w write table to disk and exit - x extra functionality (experts only) +Add 2Gb -Command (m for help): p +> dd if=/dev/zero bs=1024k count=2048 >> 2013-02-09-wheezy-raspbian.img + +Expend partition size +===================== + +> fdisk 2013-02-09-wheezy-raspbian.img + +Command (m for help): *p* Disk 2013-02-09-wheezy-raspbian.img: 4087 MB, 4087349248 bytes 255 heads, 63 sectors/track, 496 cylinders, total 7983104 sectors @@ -31,24 +21,33 @@ Disk identifier: 0x00014d34 Device Boot Start End Blocks Id System 2013-02-09-wheezy-raspbian.img1 8192 122879 57344 c W95 FAT32 (LBA) -2013-02-09-wheezy-raspbian.img2 122880 3788799 1832960 83 Linux +2013-02-09-wheezy-raspbian.img2 *122880* 3788799 1832960 83 Linux -Command (m for help): d -Partition number (1-4): 2 +Command (m for help): *d* +Partition number (1-4): *2* -Command (m for help): n +Command (m for help): *n* Partition type: p primary (1 primary, 0 extended, 3 free) e extended -Select (default p): p -Partition number (1-4, default 2): 2 -First sector (2048-7983103, default 2048): 122880 +Select (default p): +Partition number (1-4, default 2): +First sector (2048-7983103, default 2048): *122880* Last sector, +sectors or +size{K,M,G} (122880-7983103, default 7983103): Using default value 7983103 -Command (m for help): w +Command (m for help): *w* The partition table has been altered! Syncing disks. +Resize partition +================ + +> df | grep /mnt/arm + +/dev/loop2 3927752 1955672 1794172 53% /mnt/arm_rPi +/dev/loop3 57288 18960 38328 34% /mnt/arm_rPi/boot + +sudo resize2fs /dev/loop2