分类目录归档:raspberry

树莓派安装gitlab 及 https设置

最新的树莓派4B最大支持8G内存,相对于树莓派派3的2G内存,已经足够gitlab的运行。安装搭建gitlab的环境可以使用源码编译,或参考官网上的安装步骤。但最方便的还是使用docker进行安装。官方的docker镜像没有ARM64的镜像,但提供了一个非官方的链接,使用其提供的镜像可以方便的安装gitlab。

安装方法

1.安装docker镜镜像
相应的安装方法网上很多,不进行累述。

2.pull gitlab镜像

继续阅读

Raspberry Pi 安装 FreshRss阅读器

一。使用到的程序

nginx

php7.0

mysql

FreshRss

二 安装步骤

php7.0安装

1.编辑安装源

$ sudo vi /etc/apt/sources.list

在默认源下添加

deb http://mirrordirector.raspbian.org/raspbian/ stretch main contrib non-free rpi

2.设置默认从jessie 安装 新软件从 stretch安装

$ sudo vi /etc/apt/preferences

添加

Package: *

Pin: release n=jessie

Pin-Priority: 600

3.安装

sudo apt-get update

udo apt-get installt stretch php7.0 php7.0-curl php7.0-gd php7.0-fpm php7.0-cli php7.0-opcache php7.0-mbstring php7.0xml php7.0-zip

4.设置

sudo vi /etc/php/7.0/fpm/pool.d/www.conf

确认

user = www-data

group = www-data

nginx/mysql安装 略

配置

1.注意nginx的运行账户与php-frm一致

2.nignx php设置

location ~ \.php$ {
# Choose either a socket or TCP/IP address
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
# fastcgi_pass 127.0.0.1:9000;

fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
}

3.新建一个数据库给FreshRss使用

FreshRss安装

1.下载源

cd /var/www

sudo git clone https://github.com/FreshRSS/FreshRSS.git

2.修改权限

sudo chown -R www-data:www-data /var/www/freshrss

3.浏览器进入主目录,根据提示设置就可以了

 

Raspberry Pi 时间同步及windows 安装 ntp服务器的方法

参考链接

http://www.cnblogs.com/mybook/archive/2012/11/06/2757597.html

一.

Option 1 – sudo raspi-config, select change_timezone

Option 2 – sudo dpkg-reconfigure tzdata, Select the right country/timezone

使用上述方法可以设置时区

二.

pi@raspberrypi:~$ date
Sun Feb 24 14:38:41 CST 2013

使用上述方法查看当前时间

三.

pi@raspberrypi:~$ ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
*192.168.1.20 LOCAL(0) 13 u 8 64 3 0.304 1.632 1.407

使用上述方法查看当前ntp连接状态

四.

/etc/ntp.conf

文件中设置了ntp服务器的地址

# pool.ntp.org maps to about 1000 low-stratum NTP servers. Your server will
# pick a different set every time it starts up. Please consider joining the
# pool:
server 0.debian.pool.ntp.org iburst
server 1.debian.pool.ntp.org iburst
server 2.debian.pool.ntp.org iburst
server 3.debian.pool.ntp.org iburst

局域网添加IP地址

五.

windows安装ntp-4.2.8p8-win32-setup.exe https://www.meinbergglobal.com/english/sw/ntp.htm

六.

局域网使用LOCAL时间设置方法如下

七.

Edit NTP Configuration

# restrict default noquery nopeer nomodify notrap
restrict default limited kod nomodify notrap nopeer noquery
# restrict -6 default noquery nopeer nomodify notrap
restrict -6 default limited kod nomodify notrap nopeer noquery

后重启ntp

符:

NTP:ntpq -p参数解释

remote:NTP主机的IP或者是主机名(ntp.conf文件中配置的server和peer主机)
如果有『 * 』代表目前正在作用当中的上层 NTP
如果是『 + 』代表也有连上线,而且可作为下一个提供时间更新的候选者。

refid:参考的上一层 NTP 主机的地址
st:st的值表示的是远程主机的层级(NTP采用分层同步方式,一般第n+1级与第n级时钟源进行同步。NTP最多支持16层同步,即0-15层。多于16层将无法同步。
如果远程主机是当前主机的NTP Server的话,一般情况下本级主机的层级是st+1)。
t:The type of the peer (local, unicast, multicast or broadcast) when the last packet was received
l local (such as a GPS clock)
u unicast (this is the common type) (单播,即NTP client向NTP server发送NTP请求,NTP server回复的模式)
m multicast (多播,可跨子网。)
b broadcast (广播,不可跨子网。NTP server定时向广播地址发送NTP包,NTP client通过广播地址获取NTP包,同步本地时钟)
– netaddr (usually 0) when:自上次时钟同步以来经过了多少秒(当when=poll时,进行一次时钟同步,同时when被清零,从头开始计时。通过when可以知道上一次同步时间
(当前时间- when)和下一次同步时间(当前时间+poll-when))
pool:时钟同步间隔(ntp服务刚启动时,缺省的最小同步间隔是64(minpoll=6)秒,然后依次增加,128, 256, ……, 1024。缺省的最大值是1024(maxpoll=10)秒。
这两个值分别可以通过minpoll和maxpoll参数修改。)
reach:八进制数,表示最近8次时钟同步包接收情况(1表示接收成功,0表示接收失败。每接收一个包左移一位。对于一个运行较长时间的NTP client而言,
这个值应该是377->11,111,111,即最近8次包接收均成功;否则表示有丢包情况发生)
NTP刚启动后Reach变化:

如果最近的一次包接受失败:

delay:表示NTP client从发出NTP请求到接收到NTP服务器回复所经过的时间(毫秒)。
offset:即NTP client的本地时间与NTP服务器时间的差异。也就是NTP client需要调整的时间差异。
disp:表示两次时钟同步之间的offset的差值。
Jitter:Linux 系统时间与 BIOS 硬件时间的差异时间(毫秒)。

树莓派3 安装opencv

1.更新
$ sudo apt-get update
$ sudo apt-get upgrade

2.安装开发工具
$ sudo apt-get install build-essential cmake pkg-config

3.安装Image I/O
$ sudo apt-get install libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev

4.安装video I/O
$ sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
$ sudo apt-get install libxvidcore-dev libx264-dev

5.安装GTK
$ sudo apt-get install libgtk2.0-dev

6.安装gfortran 一个新的矩阵运算框架
$ sudo apt-get install libatlas-base-dev gfortran

7.安装python开发框架
$ sudo apt-get install python2.7-dev python3-dev

二。下载opencv
$ cd ~
$ wget -O opencv.zip https://github.com/Itseez/opencv/archive/3.1.0.zip
$ unzip opencv.zip

$ wget -O opencv_contrib.zip https://github.com/Itseez/opencv_contrib/archive/3.1.0.zip
$ unzip opencv_contrib.zip

三。安装python
1.安装pip
$ wget https://bootstrap.pypa.io/get-pip.py
$ sudo python get-pip.py

2.安装虚拟环境
$ sudo pip install virtualenv virtualenvwrapper
$ sudo rm -rf ~/.cache/pip

3.配置虚拟环境
# virtualenv and virtualenvwrapper
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh

$ echo -e “\n# virtualenv and virtualenvwrapper” >> ~/.profile
$ echo “export WORKON_HOME=$HOME/.virtualenvs” >> ~/.profile
$ echo “source /usr/local/bin/virtualenvwrapper.sh” >> ~/.profile

source ~/.profile

4.建立虚拟环境
mkvirtualenv cv -p python2
python2

mkvirtualenv cv -p python3
python3

以下操作都在虚拟环境中进行
5安装NumPy
pip install numpy

6.编译安装opencv
$ cd ~/opencv-3.1.0/
$ mkdir build
$ cd build
$ cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.1.0/modules \
-D BUILD_EXAMPLES=ON ..

$ make -j4
$ sudo make install
$ sudo ldconfig

for Python 2.7
$ cd ~/.virtualenvs/cv/lib/python2.7/site-packages/
$ ln -s /usr/local/lib/python2.7/site-packages/cv2.so cv2.so

for Python 3.4
$ cd /usr/local/lib/python3.4/site-packages/
$ sudo mv cv2.cpython-34m.so cv2.so
$ cd ~/.virtualenvs/cv/lib/python3.4/site-packages/
$ ln -s /usr/local/lib/python3.4/site-packages/cv2.so cv2.so

7.测试
$ source ~/.profile
$ workon cv
$ python
>>> import cv2
>>> cv2.__version__
‘3.1.0’
>>>

8.删除源码,节省空间
$ rm -rf opencv-3.1.0 opencv_contrib-3.1.0

 

树莓派设置代理/修改源

修改/etc/profile或者 /etc/environment

添加如下内容

export http_proxy=”http://<proxyipaddress>:<proxyport>”
export https_proxy=”http://<proxyipaddress>:<proxyport>”
export no_proxy=”localhost,127.0.0.1,192.168.0.0/16″

如果需要时 sudo来运行命令 例如 sudo apt-get update

使用  sudo -E apt-get update

 

修改源

编辑 /etc/apt/sources.list

修改其中的网址为你需要的网址

具体的镜像网站可以在http://www.raspbian.org/RaspbianMirrors中查找

树莓派 设置固定IP/添加用户/修改密码

备份

pi@raspberry: sudo cp /etc/network/interfaces /etc/network/interfaces.sav

修改

pi@raspberry: sudo vi /etc/network/interfaces

iface eth0 inet dhcp ->  #iface eth0 inet dhcp

添加

# The loopback interface
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
#your static IP
address 192.168.1.118
#your gateway IP
gateway 192.168.1.1
netmask 255.255.255.0
#your network address “family”
network 192.168.1.0
broadcast 192.168.1.255

重启网络

pi@raspberry:sudo /etc/init.d/networking restart

或者

pi@raspberry:sudo /etc/init.d/networking reload

 

添加用户

useradd –g aft –s /sbin/nologin -d /home/pi/aft ftpuser

修改密码

passwd ftpuser

Raspberry Pi 2 使用 Transmission

一。安装

sudo apt-get install transmission-daemon  

二。修改配置

sudo service transmission-daemon stop  
sudo vi /etc/transmission-daemon/settings.json

添加一下代码到文件中

"download-dir": "/mnt/usbel/Torrents/Completed",
"incomplete-dir": "/mnt/usbel/Torrents/Incomplete",
"incomplete-dir-enabled": true,
"rpc-whitelist": "*.*.*.*",
"rpc-whitelist-enabled": false,

设置目录/设置WEB远程连接

三。修改目录权限

sudo usermod -a -G debian-transmission pi
chgrp debian-transmission /mnt/usbel/Torrents/Incomplete
chgrp debian-transmission /mnt/usbel/Torrents/Completed
chmod 770 /mnt/usbel/Torrents/Incomplete
chmod 770 /mnt/usbel/Torrents/Incomplete

四。web远程连接

浏览器输入 http://RASPI.IP.ADDRESS:9091/

默认用户名:密码

transmission:transmission

[树莓派扩容]Extend root filesystem using CLI parted & resize2fs

by tedsluis » Tue May 28, 2013 6:28 am

I opened this new topic to answer cclauss his question, posted in the “Pidora 18 (Raspberry Pi Fedora Remix) Release” topic:http://www.raspberrypi.org/phpBB3/viewtopic.php?p=358244#p358244:

cclauss wrote:In Pidora, is there a headless mode way to expand the rootfs to take up the entire SD card without doing remote Xwindows into the Pi?

‘Parted’ runs on the command line but I don’t know how to expand the rootfs with it.

You could login using headless mode (headless mode means that you don’t have a display connect and you login with ssh from any other system) and use these steps to expand your root partition and file system on a Raspberry Pi running Pedora (fedora remix):
– backup your system in case of a misstake!
– use “fdisk /dev/mmcblk0” to view your partitions.
– use “parted” to delete the partition and then recreate it but with a larger size. (don’t worry, the data will remain)
– reboot to activate the partition changes.
– use “resize2fs /dev/mmclk0p2” to enlarge the root file system.
– use e2fsck -f /dev/mmcblk0p2 to perform a file system check.
– use “df -h” to check results.

Before you extend your root partition and filesystem you should know how big your rootfs is and how much space is available:

CODE: SELECT ALL
[root@raspi ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root       1.6G  1.5G   53M  97% /
/dev/mmcblk0p1   50M   18M   33M  35% /boot
[root@raspi ~]#

Determine the storage devices:

CODE: SELECT ALL
[root@raspi ~]# ll /dev/mm*
brw-rw---- 1 root disk 179, 0 Jun  3 13:22 /dev/mmcblk0
brw-rw---- 1 root disk 179, 1 Jun  3 13:21 /dev/mmcblk0p1
brw-rw---- 1 root disk 179, 2 Jun  3 13:21 /dev/mmcblk0p2
[root@raspi ~]

Check the partition table:

CODE: SELECT ALL
[root@raspi ~] fdisk /dev/mmcblk0
Welcome to fdisk (util-linux 2.22.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.Command (m for help): p

Disk /dev/mmcblk0: 16.0 GB, 16012804096 bytes, 31275008 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000622ba

Device Boot      Start         End      Blocks   Id  System
/dev/mmcblk0p1   *        2048      104447       51200    c  W95 FAT32 (LBA)
/dev/mmcblk0p2          104448     3494304     1694928+  83  Linux

Command (m for help): q

[root@raspi ~]#

So the SD card has 31275008 (16GB) sectors and the last one in use is 3494304 (1.6GB).
Print the partition table with “parted”:

CODE: SELECT ALL
[root@raspi ~]# parted /dev/mmcblk0
GNU Parted 3.1
Using /dev/mmcblk0
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) unit chs
(parted) print
Model: SD  (sd/mmc)
Disk /dev/mmcblk0: 1946,198,43
Sector size (logical/physical): 512B/512B
BIOS cylinder,head,sector geometry: 1946,255,63.  Each cylinder is 8225kB.
Partition Table: msdos
Disk Flags:
Number  Start     End        Type     File system  Flags
1      0,32,32   6,127,56   primary  fat16        boot, lba
2      6,127,57  217,130,9  primary  ext4
(parted)

So the disk ends at 1946,198,43 cylinder,head,sector and the current root partition ends at 217,130,9.

Note: “fdisk” displays the partition info in 512 bytes blocks and “parted” displays the cylinder,head,sector geometry. Each cylinder is 8225kB.

Now remove the second partition and recreate it larger.

Note: If you have a third swap or other partition that you don’t need any longer, you can remove that one too and use the disk space to extend you.

Removing the partition will only change the partition table and not the data. Creating a new partition will write a new start and end point in the partition table.

Be careful: If you make a misstake, you lose you root partition data:
(Ignore the warning.)

CODE: SELECT ALL
(parted) rm 2
Error: Partition(s) 2 on /dev/mmcblk0 have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use.  As a result, the old partition(s) will
remain in use.  You should reboot now before making further changes.
Ignore/Cancel? i
(parted)

And check whether the partition was removed:

CODE: SELECT ALL
(parted) print
Model: SD  (sd/mmc)
Disk /dev/mmcblk0: 1946,198,43
Sector size (logical/physical): 512B/512B
BIOS cylinder,head,sector geometry: 1946,255,63.  Each cylinder is 8225kB.
Partition Table: msdos
Disk Flags:
Number  Start    End       Type     File system  Flags
1      0,32,32  6,127,56  primary  fat16        boot, lba(parted)

Now the second partition is removed. Do not reboot your system before you have created the new partition! Other wise you lose your root file system.

The new partition must start at the same position where the old root partition did start and it ends where you like. It must have at least the same size as current partition and it may not exceed the end of the disk (in my case 1946,198,43).
(Ignore the warning.)

CODE: SELECT ALL
(parted) mkpart primary 6,127,57  1946,198,43
Error: Partition(s) 2 on /dev/mmcblk0 have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use.  As a result, the old partition(s) will
remain in use.  You should reboot now before making further changes.
Ignore/Cancel? i
(parted)

And check whether the partition was created:

CODE: SELECT ALL
(parted) print
Model: SD  (sd/mmc)
Disk /dev/mmcblk0: 1946,198,43
Sector size (logical/physical): 512B/512B
BIOS cylinder,head,sector geometry: 1946,255,63.  Each cylinder is 8225kB.
Partition Table: msdos
Disk Flags:
Number  Start     End          Type     File system  Flags
1      0,32,32   6,127,56     primary  fat16        boot, lba
2      6,127,57  1946,198,43  primary  ext4(parted) quit
Information: You may need to update /etc/fstab.

[root@raspi ~]#

Be carefull: The kernel is not aware yet of the new partition size. You must reboot your system before you do any thing else.

CODE: SELECT ALL
[root@raspi ~]# reboot

Check the new partition size after the reboot:

CODE: SELECT ALL
[root@raspi ~]# fdisk /dev/mmcblk0
Welcome to fdisk (util-linux 2.22.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.Command (m for help): p

Disk /dev/mmcblk0: 16.0 GB, 16012804096 bytes, 31275008 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000622ba

Device Boot      Start         End      Blocks   Id  System
/dev/mmcblk0p1   *        2048      104447       51200    c  W95 FAT32 (LBA)
/dev/mmcblk0p2          104448    31275007    15585280   83  Linux

Command (m for help): quit
[root@raspi ~]#

Now the partition is larger, but the root file system has still the old size. Re-size the root filesystem:

CODE: SELECT ALL
[root@raspi ~]# resize2fs /dev/mmcblk0p2
resize2fs 1.42.3 (14-May-2012)
Filesystem at /dev/mmcblk0p2 is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 1
The filesystem on /dev/mmcblk0p2 is now 3896320 blocks long.
[root@raspi ~]

The root file system is now extended.
Then check the file system for errors:

CODE: SELECT ALL
[root@raspi ~]# e2fsck -f /dev/mmcblk0p2
e2fsck 1.42.3 (14-May-2012)
/dev/mmcblk0p2 is mounted.
WARNING!!!  The filesystem is mounted.   If you continue you ***WILL***
cause ***SEVERE*** filesystem damage.Do you really want to continue<n>? yes
rootfs: recovering journal
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
Free blocks count wrong (3453563, counted=3453559).
Fix<y>? yes

rootfs: ***** FILE SYSTEM WAS MODIFIED *****
rootfs: ***** REBOOT LINUX *****
rootfs: 63775/952000 files (0.1% non-contiguous), 442761/3896320 blocks
[root@raspi ~]#

The file system is free of errors.
Finaly check the file systems size and the available space:

CODE: SELECT ALL
[root@raspi ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root        15G  1.5G   13G  11% /
/dev/mmcblk0p1   50M   18M   33M  35% /boot
[root@raspi ~]#

It has lots of free space available and it is ready to use.

I hope this helps you.