Raspberry Pi OS の Lite で　xfce4　そして　wifi bluetooth　/はわずか2.4GB

##これで作ったラズパイ４の起動は わずか３０秒です、以下をご覧ください

[ここがその動画です]
https://www.youtube.com/watch?v=rQdvVaH6WpM

raspberry pi は　ubuntuも動きますが　しかしこれでは　2020/12/07の時点では　**raspisitill つまり　ラズパイカメラ が作動しません**
このため　 **Raspberry Pi OS　に帰還**しました。

![11.jpg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/211097/76b72ae4-3a53-fe11-b225-0bfb05c29de6.jpeg)

マイクロSDカード無しで　USBつけ　ngffで動かしてます
で

```
# hdparm -t /dev/sda2
/dev/sda2:
 Timing buffered disk reads: 858 MB in  3.00 seconds = 285.73 MB/sec
```
と　普通の機械式ハードディスクより　２倍以上でずっと速い！

![22.jpg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/211097/3da94890-ae34-c332-88a1-ccb414f4e2d0.jpeg)


![1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/211097/6a5ca3b0-c15f-b465-902d-93920f131fcf.png)

をつかいます　**４３２MBとちっこい**
![11.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/211097/b0f542c0-974e-f73a-acca-b4d1646be935.png)

ケンシロウ

![1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/211097/091760e4-a8c5-080f-65a1-24ec4d608154.png)


```
座頭市　https://www.youtube.com/watch?v=fGkvCLFdIH0
おれたちゃご法度の裏街道を歩く渡世なんだぞ
世の中の嫌われもんだ

法律は　知ったこたあねえ
欲しいものは盗る
裏から手をまわす
仁義、義理もねえ
いつやられるかもしれねえ
いやな　渡世だなあ

地獄へ行くのか　地獄へ行くのか　もう、目が空きてえなあ（市）

```


## あれれ、起動したらCUIじゃねえか
##　GUIへの道をさぐります

```



-------------

install openssh-server aptitude


```

$ ssh pi@192.168.17.17
とsshで入って（パスワードはraspberry)

##1)時を掛ける少女
suして
apt install  openntpd
touch /var/lib/openntpd/db/ntpd.drift
systemctl enable openntpd
systemctl start openntpd

##2)なんたって　xfce4
apt install  xorg
apt install  xfce4
echo 'startxfce4' > /home/pi/.xinitrc

apt install sddm　
sddm --example-config > /etc/sddm.conf　
systemctl enable sddm　



##3)ここまででGUIができて以下になってますがな

![11.jpg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/211097/79938b76-bb5e-970c-b676-6989e7bf3327.jpeg)


##4) 気張って日本語環境構築と　クロミウムをいれへんか

##4a)まずは　日本語の読み
apt install fonts-ipafont-gothic

##4b)んでから　日本語の書き
apt install fcitx-mozc ghostscript

cat /home/pi/.xprofile
export XMODIFIERS=@im=fcitx
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx

chown -R pi /home/pi


##5)uxterm 見にくいんで
apt install xfce4-terminal


##6) 日本語入力のためのお約束ごと
$ fcitx-config-gtk3

##7)なにはなくとも　クローム
apt install chromium-browser


以上で
![ee.jpg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/211097/03c96340-3192-0d89-7069-01adc9cfa73e.jpeg)

と日本語OKなGUI化けできまたねん

##8)あとは /をUSBハードディスクにおきます

|具体的な/をUSBハードディスクに置く方法は直下です
|:---
|https://qiita.com/tyokai/items/f6bce628d38425eb8adf

```
A)
$ cat /etc/fstab 
proc            /proc           proc    defaults          0       0
PARTUUID=de8ce30b-01  /boot           vfat    defaults          0       2
/dev/sda1             /               ext4    defaults,noatime  0       1

/dev/sda2	     swap 	      swap    defaults,noatime  0       1



-------
B)
cat /boot/cmdline.txt
console=serial0,115200 console=tty1 root=/dev/sda1 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait

--------

ｃ）参考だけど
# fdisk -l
Disk /dev/ram0: 4 MiB, 4194304 bytes, 8192 
Disk /dev/ram1: 4 MiB, 4194304 bytes, 8192 
Disk /dev/ram2: 4 MiB, 4194304 bytes, 8192 
Disk /dev/ram3: 4 MiB, 4194304 bytes, 8192 
Disk /dev/ram4: 4 MiB, 4194304 bytes, 8192 
Disk /dev/ram5: 4 MiB, 4194304 bytes, 8192 
Disk /dev/ram6: 4 MiB, 4194304 bytes, 8192 
Disk /dev/ram7: 4 MiB, 4194304 bytes, 8192 
Disk /dev/ram8: 4 MiB, 4194304 bytes, 8192 
Disk /dev/ram9: 4 MiB, 4194304 bytes, 8192 
Disk /dev/ram10: 4 MiB, 4194304 bytes, 8192 
Disk /dev/ram11: 4 MiB, 4194304 bytes, 8192 
Disk /dev/ram12: 4 MiB, 4194304 bytes, 8192 
Disk /dev/ram13: 4 MiB, 4194304 bytes, 8192 
Disk /dev/ram14: 4 MiB, 4194304 bytes, 8192 
Disk /dev/ram15: 4 MiB, 4194304 bytes, 8192 

Disk /dev/mmcblk0: 3.7 GiB, 4005560320 bytes, 7823360 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
Disklabel type: dos
Disk identifier: 0xde8ce30b
Device         Boot Start    End Sectors  Size Id Type
/dev/mmcblk0p1       8192 532479  524288  256M  c W95 FAT32 (LBA)

Disk /dev/sda: 14.9 GiB, 16013942784 bytes, 31277232 sectors
Disk model: Generic         
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 5A070DD5-9D18-334A-A467-2DA59A061CE4

Device       Start      End  Sectors  Size Type
/dev/sda1  4196352 31277198 27080847 12.9G Linux filesystem
/dev/sda2     2048  4196351  4194304    2G Linux swap


```

##スワップ問題)
systemctl stop dphys-swapfile
systemctl disable dphys-swapfile


##自動ログイン)
apt istall sddm

```
head /etc/sddm.conf
[Autologin]
# Whether sddm should automatically log back into sessions when they exit
Relogin=false

# Name of session file for autologin session (if empty try last logged in)
Session=

# Username for autologin session
User=pi
```


なお自動ログインをlightdm出やりたい時は

```
./comment-out.bat /etc/lightdm/lightdm.conf
[LightDM]

[Seat:*]
autologin-user = pi
autologin-session = xfce
[XDMCPServer]
[VNCServer]

```

ですね

##)日本に
```
sudo raspi-config から
Localisation  options でいろいろ設定

# ls -l /etc/localtime 
lrwxrwxrwx 1 root root 30 Jun 29 17:47 /etc/localtime -> /usr/share/zoneinfo/Asia/Tokyo

```


##速度はどんだけ
# hdparm -t /dev/sda1
/dev/sda1:
 Timing buffered disk reads: 758 MB in  3.01 seconds = **252.23 MB/sec**


##空きが一杯　わずか２．４Gしか　使ってへん
$ df
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/root       13262188 2410044  10158740  20% /
devtmpfs          860896       0    860896   0% /dev
tmpfs             992992       0    992992   0% /dev/shm
tmpfs             992992    9028    983964   1% /run
tmpfs               5120       4      5116   1% /run/lock
tmpfs             992992       0    992992   0% /sys/fs/cgroup
/dev/mmcblk0p1    258095   52231    205864  21% /boot
tmpfs             198596       8    198588   1% /run/user/1000

##)音はTVからでてます


い）wifi接続

```
これは　https://signal-flag-z.blogspot.com/2019/05/raspberrypi-dhcpcd-networkmanager.html　で解決

つまり

apt install network-manager network-manager-gnome

systemctl stop dhcpcd.service
systemctl disable dhcpcd.service

systemctl enable NetworkManager.service
systemctl start NetworkManager.service

その後再起動
```

これにて
![1.jpg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/211097/68935dc9-3eae-71d6-ef22-6ad05a91fefe.jpeg)



ろ）bluetooth
bluezはすでに入ってる
で　
apt install blueman
pi-bluetooth　もすでに入ってる、インストの必要なし

これでbluetooth イアフォン　OK

![2.jpg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/211097/b6abb4b0-fde9-0dd4-1f94-e7d7c2cc2d5e.jpeg)



## おもろいなー　ラズパイ

|種田山頭火
|:---
|どうしやうもないわたしが歩いてゐる
|西行
|願はくは　花の下にて　春死なむ　そのきさらぎの　望月のころ


## raspberry pi 3B でもやってみました
しかし　なぜかsddm はうまくいかないので　lightdm です。

pi@raspberrypi:~ $ ./comment-out.bat /etc/lightdm/lightdm.conf
[LightDM]
[Seat:*]
autologin-user=pi
autologin-session=xfce
[XDMCPServer]
[VNCServer]

```
pi@raspberrypi:~ $ free
              total        used        free      shared  buff/cache   available
Mem:         948280      196684      500992        7252      250604      677356
Swap:        102396           0      102396


pi@raspberrypi:~ $ df
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/root       15191192 2552940  11989096  18% / **がらがらに空いてる**
devtmpfs          469532       0    469532   0% /dev
tmpfs             474140       0    474140   0% /dev/shm
tmpfs             474140    6488    467652   2% /run
tmpfs               5120       4      5116   1% /run/lock
tmpfs             474140       0    474140   0% /sys/fs/cgroup
/dev/mmcblk0p1    258095   52144    205951  21% /boot
tmpfs              94828      12     94816   1% /run/user/1000



root@raspberrypi:/home/pi# hdparm -t /dev/sda1
/dev/sda1:
 Timing buffered disk reads: 100 MB in  3.03 seconds =  33.04 MB/sec
と遅いのは　USB２．０接続だから諦めるべきだよん


```



## sudo raspi-config
でカメラを導入


wifiは
raspi-config　で　OKです。




１０円玉よりちょっと大きい
![1.jpg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/211097/3e80b019-77a0-e0b1-d619-9de7661e6715.jpeg)
にて
raspistill　-?
でわかるように以下の機能がある

```

"raspistill" Camera App (commit 6e6a2c859a17 Tainted)

Runs camera for specific time, and take JPG capture at end if requested

usage: raspistill [options]

Image parameter commands

-q, --quality	: Set jpeg quality <0 to 100>
-r, --raw	: Add raw bayer data to jpeg metadata
-l, --latest	: Link latest complete image to filename <filename>
-t, --timeout	: Time (in ms) before takes picture and shuts down (if not specified, set to 5s)
-th, --thumb	: Set thumbnail parameters (x:y:quality) or none
-d, --demo	: Run a demo mode (cycle through range of camera options, no capture)
-e, --encoding	: Encoding to use for output file (jpg, bmp, gif, png)
-x, --exif	: EXIF tag to apply to captures (format as 'key=value') or none
-tl, --timelapse	: Timelapse mode. Takes a picture every <t>ms. %d == frame number (Try: -o img_%04d.jpg)
-fp, --fullpreview	: Run the preview using the still capture resolution (may reduce preview fps)
-k, --keypress	: Wait between captures for a ENTER, X then ENTER to exit
-s, --signal	: Wait between captures for a SIGUSR1 or SIGUSR2 from another process
-g, --gl	: Draw preview to texture instead of using video render component
-gc, --glcapture	: Capture the GL frame-buffer instead of the camera image
-bm, --burst	: Enable 'burst capture mode'
-dt, --datetime	: Replace output pattern (%d) with DateTime (MonthDayHourMinSec)
-ts, --timestamp	: Replace output pattern (%d) with unix timestamp (seconds since 1970)
-fs, --framestart	: Starting frame number in output pattern(%d)
-rs, --restart	: JPEG Restart interval (default of 0 for none)

GL parameter commands

-gs, --glscene	: GL scene square,teapot,mirror,yuv,sobel,vcsm_square
-gw, --glwin	: GL window settings <'x,y,w,h'>

Common Settings commands

-?, --help	: This help information
-w, --width	: Set image width <size>
-h, --height	: Set image height <size>
-o, --output	: Output filename <filename> (to write to stdout, use '-o -'). If not specified, no file is saved
-v, --verbose	: Output verbose information during run
-cs, --camselect	: Select camera <number>. Default 0
-md, --mode	: Force sensor mode. 0=auto. See docs for other modes available
-gps, --gpsdexif	: Apply real-time GPS information to output (e.g. EXIF in JPG, annotation in video (requires libgps.so.23)

Preview parameter commands

-p, --preview	: Preview window settings <'x,y,w,h'>
-f, --fullscreen	: Fullscreen preview mode
-op, --opacity	: Preview window opacity (0-255)
-n, --nopreview	: Do not display a preview window
-dn, --dispnum	: Display on which to display the preview window (dispmanx/tvservice numbering)

Image parameter commands

-sh, --sharpness	: Set image sharpness (-100 to 100)
-co, --contrast	: Set image contrast (-100 to 100)
-br, --brightness	: Set image brightness (0 to 100)
-sa, --saturation	: Set image saturation (-100 to 100)
-ISO, --ISO	: Set capture ISO
-vs, --vstab	: Turn on video stabilisation
-ev, --ev	: Set EV compensation - steps of 1/6 stop
-ex, --exposure	: Set exposure mode (see Notes)
-fli, --flicker	: Set flicker avoid mode (see Notes)
-awb, --awb	: Set AWB mode (see Notes)
-ifx, --imxfx	: Set image effect (see Notes)
-cfx, --colfx	: Set colour effect (U:V)
-mm, --metering	: Set metering mode (see Notes)
-rot, --rotation	: Set image rotation (0-359)
-hf, --hflip	: Set horizontal flip
-vf, --vflip	: Set vertical flip
-roi, --roi	: Set region of interest (x,y,w,d as normalised coordinates [0.0-1.0])
-ss, --shutter	: Set shutter speed in microseconds
-awbg, --awbgains	: Set AWB gains - AWB mode must be off
-drc, --drc	: Set DRC Level (see Notes)
-st, --stats	: Force recomputation of statistics on stills capture pass
-a, --annotate	: Enable/Set annotate flags or text
-3d, --stereo	: Select stereoscopic mode
-dec, --decimate	: Half width/height of stereo image
-3dswap, --3dswap	: Swap camera order for stereoscopic
-ae, --annotateex	: Set extra annotation parameters (text size, text colour(hex YUV), bg colour(hex YUV), justify, x, y)
-ag, --analoggain	: Set the analog gain (floating point)
-dg, --digitalgain	: Set the digital gain (floating point)
-set, --settings	: Retrieve camera settings and write to stdout


Notes

Exposure mode options :
off,auto,night,nightpreview,backlight,spotlight,sports,snow,beach,verylong,fixedfps,antishake,fireworks

Flicker avoid mode options :
off,auto,50hz,60hz

AWB mode options :
off,auto,sun,cloud,shade,tungsten,fluorescent,incandescent,flash,horizon,greyworld

Image Effect mode options :
none,negative,solarise,sketch,denoise,emboss,oilpaint,hatch,gpen,pastel,watercolour,film,blur,saturation,colourswap,washedout,posterise,colourpoint,colourbalance,cartoon

Metering Mode options :
average,spot,backlit,matrix

Dynamic Range Compression (DRC) options :
off,low,med,high


```




##監視カメラ　Rpi3

```


$ ./comment-out.bat camera.bat
x=`date +%Y-%m-%d`
h=`date +%H`
mkdir -p /home/pi/kansi-----/$x/$h
y=`date +%M-%S`

raspistill -o /home/pi/kansi-----/$x/$h/$y.jpg 

z7=`date --date '7 day ago' +%Y-%m-%d`
z6=`date --date '6 day ago' +%Y-%m-%d`
z5=`date --date '5 day ago' +%Y-%m-%d`
z4=`date --date '4 day ago' +%Y-%m-%d`
z3=`date --date '3 day ago' +%Y-%m-%d`
z2=`date --date '2 day ago' +%Y-%m-%d`
z1=`date --date '1 day ago' +%Y-%m-%d`
z0=`date +%Y-%m-%d`

mkdir -p /home/pi/kansi-----/$z7
mkdir -p /home/pi/kansi-----/$z6
mkdir -p /home/pi/kansi-----/$z5
mkdir -p /home/pi/kansi-----/$z4
mkdir -p /home/pi/kansi-----/$z3
mkdir -p /home/pi/kansi-----/$z2
mkdir -p /home/pi/kansi-----/$z1
mkdir -p /home/pi/kansi-----/$z0

rm -rf /home/pi/kansi-----/$z7
rm -rf /home/pi/kansi-----/$z6
rm -rf /home/pi/kansi-----/$z5
rm -rf /home/pi/kansi-----/$z4
rm -rf /home/pi/kansi-----/$z3






$ crontab -l 
*/1    * * * *       /home/pi/camera.bat ; sleep 4 ; /home/pi/camera.bat ; sleep 4 ; /home/pi/camera.bat ; sleep 4 ; /home/pi/camera.bat ; sleep 4 ; /home/pi/camera.bat ; sleep 4 ; /home/pi/camera.bat 
にて　１０秒毎の画像をとる



# crontab -l 

@reboot		systemctl restart openntpd
*/30 	*	*	*	*	ntpd -s	
0	12	*	*	*	/sbin/reboot




manjaroLINUXで10秒毎のを　manjaroLINUXにつれてくる
rsync-over-ssh-2-Rpi3.bat 
z7=`date --date '7 day ago' +%Y-%m-%d`
z6=`date --date '6 day ago' +%Y-%m-%d`
z5=`date --date '5 day ago' +%Y-%m-%d`
z4=`date --date '4 day ago' +%Y-%m-%d`
z3=`date --date '3 day ago' +%Y-%m-%d`
z2=`date --date '2 day ago' +%Y-%m-%d`
z1=`date --date '1 day ago' +%Y-%m-%d`
z0=`date +%Y-%m-%d`
echo ' ------- set date --------'
echo 
date +%Y-%m_%d-%H:%M
sleep 5
echo 
echo '-------------------------'
mkdir -p /home/jaro/KANSI---/$z0
rm -rf /home/jaro/KANSI---/z7
rm -rf /home/jaro/KANSI---/z6
rm -rf /home/jaro/KANSI---/z5
rm -rf /home/jaro/KANSI---/z4
rm -rf /home/jaro/KANSI---/z3
rsync -avHx \
-e ssh   pi@192.168.3.12:/home/pi/kansi-----/$z0/ 	/home/jaro/KANSI---/$z0/


```


##さらに遊びます


HP（192.168.3.7）　も　DELL（192.168.3.17）　も　Rpi3（192.168.3.1２）　もルータにつないでます
HP　は　ストレージは小さい
DELLは　ストレージは大きい

で　Rpi3のファイルを　DELLにつれてきて　Rpi３からみます

あ）　Rpi3のファイルを　DELLにつれてくるために

./comment-out.bat rsync-over-ssh-2-Rpi3.bat 
z7=`date --date '7 day ago' +%Y-%m-%d`
z6=`date --date '6 day ago' +%Y-%m-%d`
z5=`date --date '5 day ago' +%Y-%m-%d`
z4=`date --date '4 day ago' +%Y-%m-%d`
z3=`date --date '3 day ago' +%Y-%m-%d`
z2=`date --date '2 day ago' +%Y-%m-%d`
z1=`date --date '1 day ago' +%Y-%m-%d`
z0=`date +%Y-%m-%d`
echo ' ------- set date --------'
echo 
date +%Y-%m_%d-%H:%M
sleep 5
echo 
echo '-------------------------'
mkdir -p /home/dell/KANSI---/$z0
rm -rf /home/dell/KANSI---/z7
rm -rf /home/dell/KANSI---/z6
rm -rf /home/dell/KANSI---/z5
rm -rf /home/dell/KANSI---/z4
rm -rf /home/dell/KANSI---/z3
rsync -avHx \
-e ssh   pi@192.168.3.12:/home/pi/kansi-----/ 	/home/dell/KANSI---/


い）DELLをHPに　nfsで公開します
./comment-out.bat /etc/exports
/home/dell/KANSI---  	192.168.3.7/32(rw,sync,fsid=0)


なおDELLの防火壁は

 ./comment-out.bat ufw.bat 
rpcinfo -p | grep nfs
 ufw disable
 ufw enable
 ufw default deny
 ufw deny  from 192.168.3.1/32
 ufw allow Deluge
 ufw limit ssh/tcp
 ufw allow from 192.168.3.7/32
 ufw status





う）#crontab -l
@reboot					/usr/sbin/ntpd -s
*/30 	*	*	*	*	/usr/sbin/ntpd -s	
0	12	*	*	*	/sbin/reboot




え）$ crontab -l 
*/1    * * * *       /home/pi/camera.bat ; sleep 4 ; /home/pi/camera.bat ; sleep 4 ; /home/pi/camera.bat ; sleep 4 ; /home/pi/camera.bat ; sleep 4 ; /home/pi/camera.bat ; sleep 4 ; /home/pi/camera.bat




お）HPで　/home/dell/KANSI---をマウントします
./comment-out.bat nfs-2-dell-KANSI---.bat 
umount /NFS--- 
mount -t nfs  192.168.3.17:/home/dell/KANSI---  /NFS---/
ls -ltr /NFS---


するとHPで　gwenview /NFS---　で画像が見れます
なお　Rpi3は　CUIで動かしてます