Migrate ubuntu to another disk

  1. connect new disk {diskB}
  2. use `fdisk -l` to find current disks info
  3. format {diskB} with `GPT` partition format.
  4. partition {diskB} to have exact partitions as old disk: 
    • / (the root) fileSystem: ex4
    • /boot (for booting files including `grub`) fileSystem: ex2, flags: boot, esp
    • fileSystem: unformatted, mount point: none, flags: bios_grub
  5. mount /boot of {diskB} to point /mnt and install grub
    • > $ sudo grub-install –target=i386-pc –root-directory=/mnt –recheck –debug /dev/sdb
    • mv /mnt/boot/* /mnt/
  6. use `mount {source path} {dest. path, like /mnt}` to mount new partitions and copy all files from the corresponding folders from old disk: cp -rf -a {source path} {dest. path}
    • /bin 系统可执行文件
    • /etc 系统核心配置文件
    • /opt 用户程序文件
    • /root root用户主目录
    • /sbin 系统可执行文件
    • /usr 程序安装目录
    • /var 系统运行目录
    • /boot
  7. create essential empty directories in {diskB}
    • /dev 主要存放与设备(包括外设)有关的文件
    • /proc 正在运行的内核信息映射
    • /sys 硬件设备的驱动程序信息
  8. modify etc/fstab file to mount new /, /boot/ in {diskB} and old disk
    • use `blkid` to check current partitions uuid
    • change fstab:
      • UUID={diskB’s `/` partition uuid}             /           ext4    errors=remount-ro     0       1
      • UUID={diskB’s `/boot` partition uuid}     /boot    ext4    defaults                      0       2
  9. update-grub (if still not work, try to grub-install /dev/{diskB}
  10. reboot!

grub rescue mode if grub directory is not found at booting:

use `ls (hd0,1~9)/{any files like ./grub ./lost+found}` to check what your boot index is.

grub rescue>root=(hd0,{diskB’s boot partition index, `2` for example.})

grub rescue>prefix=/boot/grub

grub rescue>set root=(hd0,2)

grub rescue>set prefix=(hd0,2)/boot/grub

grub rescue>insmod normal

grub rescue>normal // auto enter `normal` mode

// normal mode /////////

grub>linux /vmlinuz-xxx-xxx root=/dev/{diskB} ro

grub>initrd /initrd.img-xxx-xxx

grub>boot

Android WebView缓存策略详解

WebView中存在着两种缓存:网页数据缓存(存储打开过的页面及资源)、H5缓存(即appcache)。

H5 缓存

1、缓存构成
根据setAppCachePath(String appCachePath)提供的路径,在H5使用缓存过程中生成的缓存文件。

2、缓存模式
无模式选择,通过setAppCacheEnabled(boolean flag)设置是否打开。默认关闭,即,H5的缓存无法使用。

3、清除缓存
找到调用setAppCachePath(String appCachePath)设置缓存的路径,把它下面的文件全部删除就OK了。

开发过程中遇到使用特定的网址自动登录,界面本身加载成功,但是登录状态失败,通过 chrome 的 debug 调试:chrome://inspect/#devices 查看发现与普通chrome浏览器的网络请求状态基本没有明显差别,基本 JS 都加载成功,区别只是登录成功状态的信息获取根本就没有请求

一开始往二次跳转的思路上面去解决,后面发现根本就没有过二次跳转的 shouldOverrideUrlLoading 方法,那也就是说明根本不是多次跳转的问题,于是往缓存上面着手,最后经过查找 webview 默认不会开启 H5 的缓存,需要主动打开,于是尝试开启

settings.setAppCacheEnabled(true);
settings.setAllowFileAccess(true);
settings.setAppCachePath(new File(context.getFilesDir(), "XXXX").getAbsolutePath());
settings.setDatabaseEnabled(true);
settings.setDomStorageEnabled(true);

开启过后登录状态正常展示。

转载:https://blog.csdn.net/a345017062/article/details/8573689