2015-12-03

Ubuntu Snappy 学习心得 (1)

前言

第一次在 CSDN 开个博客,写点自己学习的东西。
首先就先写个 Ubuntu Snappy 的专题,我知道英文的网站以及 Ubuntu 官方网站已经有很多文章介绍了,我尽量翻译并结合自己的心得写一些,也为一些不太懂英文的同学有个借鉴的地方。我也不怎么喜欢码字,所以写的不一定很多,有些东西可能就是简单说说,有问题的欢迎留言。写太多了,我写着累,看官们看着更累。那么废话不多说了,先说说 Snappy

什么是 Snappy

http://www.ubuntu.com/cloud/snappy

特点

简单说就是用于物联网的 Ubuntu 操作系统。特点是原子性的升级,支持升级失败回滾到之前的版本。感觉设计还是比较先进的。特点大致如下:
  • 操作系统和应用程序完全隔离
  • 事务性的,image-based 增量更新,应用程序可回滾
  • 文件只读(不清楚这段什么意思,以后弄清楚再补充)
  • 支持签名 (signatures) 和手印 (fingerprint) (以后清楚再补充)
  • 增量管理,保证只下更新的部分
Snappy 因为这些特点,特别适合于在 IoT (Internet of Things) 物联网上使用。可以安装在机器人,汽车,商用/家用 交换机/路由器,无人机等各个领域里。

Snappy 架构

看得出底层是 Ubuntu core, 就是最小的 Ubuntu 操作系统,上面是构架,再上就是应用了

Snappy 安装

https://developer.ubuntu.com/en/snappy/start/
这里有详尽的安装方法,简单说就是可以安装到你的 Rasberry PI 上,Beaglebone 的板子上,可以在云计算里,还可以在物理机及虚拟机上安装。这里,我用的是 KVM 虚拟机,使用 libvirt + virt-manager 进行管理,挺方便的。如果就在本机上试,也可以用 vagrant + virtualbox 进行实验,这个也很方便,推荐。

Snappy 的简单之旅

https://developer.ubuntu.com/en/snappy/start/using-snappy/
安装完了之后登录进去,首先看看系统信息
$ snappy info 
release: ubuntu-core/15.04/stable
architecture: amd64
frameworks:
apps: 

这是最基本的系统,还没有安装应用程序。
显示已安装的组件:

$ snappy list -v
Name Date Version Developer 
ubuntu-core 2015-11-13 10 ubuntu* 
docker 2015-11-30 1.6.2.005 canonical* 
hello-world 2015-11-30 1.0.18 canonical* 
webdm 2015-11-13 0.9.4 canonical* 
generic-amd64 2015-11-13 1.4 canonical*

搜索,安装软件:

$ snappy search docker
Name Version Summary 
matrix.mectors 0.0.11 matrix 
go-ether.mectors 0.0.3 go-ether 
docker 1.6.2.005 Docker


$ sudo snappy install docker
Installing docker
Starting download of docker
8.36 MB / 8.36 MB [========================================] 100.00 % 1016.85 KB/s 
Done
Starting download of icon for package
21.58 KB / 21.58 KB [======================================>_] 100.00 % 72.56 KB/s 
Done
Name Date Version Developer 
ubuntu-core 2015-11-13 10 ubuntu 
docker 2015-12-02 1.6.2.005 canonical 
hello-world 2015-11-30 1.0.18 canonical 
webdm 2015-11-13 0.9.4 canonical 
generic-amd64 2015-11-13 1.4 canonical 

Snappy Help

$ snappy --help
Usage:
  snappy [OPTIONS] 

Help Options:
  -h, --help  Show this help message

Available commands:
  activate            Activate a package
  booted              internal
  build               Builds a snap package (aliases: bu)
  config              Set configuration for an installed package.
  console             Run snappy console interface
  deactivate          Deactivate a package
  firstboot           internal
  grub-migrate        internal
  hw-assign           Assign a hardware device to a package
  hw-info             List assigned hardware device for a package
  hw-unassign         Unassign a hardware device to a package
  info                Display a summary of key attributes of the snappy system.
  install             Install a snap package
  internal-run-hooks  internal
  internal-unpack     internal
  list                List active components installed on a snappy system (aliases: li)
  login               Log into the store
  man                 produces manpage
  purge               Remove all the data from the listed packages
  remove              Remove a snapp part
  rollback            Rollback to a previous version of a package
  search              Search for packages to install (aliases: se)
  service             Query and modify snappy services
  set                 Set properties of system or package
  update              Update all installed parts
  versions            (deprecated) please use "list"

再通过 snappy 安装个 hello-world 
$ sudo snappy install hello-world

然后再来看 snappy info

$ snappy info
release: ubuntu-core/15.04/stable
architecture: amd64
frameworks: docker.canonical
apps: hello-world.canonical

看到 docker 是构架, hello-world 是应用程序。


构架对系统的影响或者扩展多一些,所以对 framework 的应用也要严一些;应用程序对系统不造成影响,可以直接从安装源或其他 vendor 那获取安装包安装
如果发现了有系统组件有更新,还可以通过 update 命令更新
$ sudo snappy update ubuntu-core

因为我当前的系统是最新的,所以没有更新,看原链接里的例子,ubuntu-core 有更新,那么可以通过更新到最新版本,然后重启系统,这时系统就进行最新的系统了,旧系统还在,如果有什么问题,可以随时通过回滾到老版本

$ sudo snappy rollback ubuntu-core
Setting ubuntu-core to version 3
Name        Date       Version Developer
ubuntu-core 2015-06-11 2       ubuntu!   
Reboot to use the new ubuntu-core.

然后重启系统,系统又退回到老版本了,对于 IoT 设备,是不是很关键而且必须的特性?
今天先写到这里,随着进行深入的学习,我再继续进行更新。敬请期待

2009-02-10

The Linux Pub Quiz

http://www.tuxradar.com/content/linux-pub-quiz

anyone wants to challenge? :)

2008-10-22

Great GNOME.Asia summit

Last Sat and Sun (18, 19 Oct, 2008), We BLUG, Sun and other organizations held GNOME.Asia summit which is awesome. More than 300 people attend such big event. there are many topics that I was very interested in on the schedule. And also, I met many famous people, such as Stormy Peter, Brian Cameron and Willie Walker etc.

I have talked to Willie who works on Accessibility for almost around 20 years. From the talk, I can feel that he is really a nice man, and devote himself into a11y for such a long time, and I understand it's very difficult to keep focusing on one thing, but he did.

Two people I have to mention, Pockey Lam and Emily Chen, without these two girls, we won't have GNOME.Asia summit. Most jobs have done by them including fantastic closing celebration. I'd like to give them my biggest thanks and regards to these girils.

Let me show you some pictures, I think that means more than the words.

(Stomy Peter)
(Brian Cameron)
(Brian Cameron)
(Brian Cameron)
(Li Yuan, atk and at-spi maintainer)
(Willie and me, ok, i admit i'm a bit fat now)
(Willie is giving presentation about orca)(his desktop)(his laptop)(Jon Phillips, giving lightning talk)
more pictures could be found here.

2008-06-23

2008-05-21

BrainShare day

Yesterday, we held BrainShare big conference at JW Marriott Hotel. Many big guys attend meeting, such as Rodge Levy, Maarten Koster etc. It would be nice to hear their tune about our products in order that I could understand more about company and its philosophy Tired but worthy.

2008-05-13

Something to memorized

Yesterday, 2005.05.12, about 14:30 (CST). A BIG earthquake happens in SiChuan province in China. Magnitude 7.8. We (live in Beijing) feel the quake in our building. I feel giddy and my colleagues also. People came to the ground immediately, so did I. What the luck is I'm still alive, and what the sadness is there are more than 10k people died there at now.

Hiding under the desk? No way. The building might be collapsed. What else we can do in such HIGH building except escaping from the fire-fighting access? I could imagine the 911.
This is my first time to experience such feeling. and I feel something inside of me. Life is so strong sometimes and might be fragile either. So what the left is treasure the life of everyday.

Bless the people in the venue could pass those tough days.

2008-05-05

Happy in Novell

These days, I continued to learn packaging, and I pick universal-encoding-detector for practice, which is sharable C library for string encoding detection, written by Alex Lau. It is mainly based off of Mozilla detection algorithm.

Working in Novell makes me relax, self-disciplined, eager to learn. So many people here with so many funs. I am so happy with my job and really enjoy it.