2020年1月10日 星期五

raspberry pi 備份 縮小分割區

1. 備份整塊區塊. sd card.
    windows : Win32DiskImager
    Linux : sudo dd bs=4M if=/dev/mmcblok0 | zip backup-raspbian.zip -
          看狀態改用 : sudo dd bs=4M if=/dev/mmcblok0 status=progress | zip backup-raspbian.zip -
          解壓 unzip backup-raspbian.zip backup-raspbian.img
2. fdisk -l backup-raspbian.img
    記下要掛載修改的start address. 通常是last partition.
    假設主要Linux : start : 8192 磁區 在第一個partition. 每個sector 512byte
3. 掛載loop
    sudo losetup /dev/loop10 backup-raspbian.img -o $((512*8192))
4. 用gparted resize
    sudo gparted /dev/loop10
    點resize 不要縮到有資料的地方
    記下最後resize 的size.  假設是5447008K
5. 重新掛整個img 在loop上
    sudo losetup --detach /dev/loop10
    sudo losetup /dev/loop10 backup-raspbian.img
6. fdisk /dev/loop10
      Command (m for help): d
      Selected partition 1
      Partition 1 has been deleted.

      Command (m for help): n
      Partition type
         p   primary (0 primary, 0 extended, 4 free)
         e   extended (container for logical partitions)
      Select (default p): p
      Partition number (1-4, default 1):
      First sector (2048-62333951, default 2048): 8192
      Last sector, +sectors or +size{K,M,G,T,P} (8192-62333951, default 62333951): +5447008K

      Created a new partition 1 of type 'Linux' and of size 5.2 GiB.
      Partition #1 contains a ext4 signature.

      Do you want to remove the signature? [Y]es/[N]o: N

      Command (m for help): w

     出現 Re-reading the partition table failed.: Invalid argument
        使用 partprobe 指令

7. truncate
    sudo losetup --detach /dev/loop10
    fdisk -l backup-raspbian.img
      記下最後磁區的end . 假設是 10901503
    truncate -s $((512*(10901503+1))) backup-raspbian.img


https://blog.cavedu.com/2018/03/22/raspberry-pi-
%E4%B8%8D%E5%86%8D%E5%82%99%E4%BB%BD%E6%95%B4%E5%BC%B5sd%E5%8D%A1%EF%BC%8C%E7%B8%AE%E5%B0%8Fraspberrypi%E5%82%99%E4%BB%BD%E5%AE%B9%E9%87%8F/

2020年1月9日 星期四

clean raspberry pi packages


https://gist.github.com/rdmarsh/5070295


淨水器水管

第一道 : K33
  5微米PP不織布濾心 PP 5u
 3個月 / 
第二道 : K33
   K33 顆粒椰殼活性碳
  6個月/3500加侖 (13230L)
第三道 : K33
  1微米PP不織布濾心 PP 1u
  9個月
第四道
  RO 
  36個月
第五道 ST33
  小條 顆粒椰殼活性碳
  12個月/ 2500加侖 (9450L)


size ?



https://www.mobile01.com/topicdetail.php?f=729&t=5125983

https://www.aquawin.com.tw/cht/category/cartridge-filters.htm
https://kknews.cc/zh-tw/home/g2k6zy.html
https://gaujiuh.qdm.tw/%E6%89%BE%E6%BF%BE%E5%BF%83/T33-filter

raspbian 更新debian發行版

更新前建議先備份

command :
  apt-get update
  apt-get upgrade -y
  apt-get dist-upgrade
  rpi-update

modify file :
  /etc/apt/source.list
    deb http://mirrordirector.raspbian.org/raspbian/ jessie main contrib non-free rpi

  /etc/apt/source.list
    deb http://mirrordirector.raspbian.org/raspbian/ stretch main contrib non-free rpi

  一次修改進一版. 跨兩版可能會發生問題.

更新完後下command :
  apt-get update
  apt-get upgrade -y


版本名稱可參考
  https://www.debian.org/releases/index.zh-tw.html