Linux下直接写盘操作卡死整个系统UI,如何解决?
PHP中文网
PHP中文网 2017-04-17 11:35:43
0
3
850

我的需求是把一个镜像文件写进TF卡。镜像大小3~4G。我在终端下用命令行操作,具体是这样:

sudo dd if=2013-09-25-wheezy-raspbian.img of=/dev/sdx # sdx根据实际情况

现在出现的问题是:写入镜像一开始还正常,写了一会儿之后系统的所有鼠标、键盘、视频播放等所有用户界面的操作全部、完全卡死。系统平均负载飚到10.0以上。

如果拔掉读卡器,则随着写卡失败,系统立刻恢复顺畅运行。

用了以下办法无效:

  • 不用sudo命令,直接用su命令进入root终端操作
  • nice命令降低dd的优先级
  • pv管道命令把速度卡在15MB/s

我记得当初在Windows下写卡的时候,完全可以把写卡程序扔到后台不管,前台该做什么做什么。

我不相信Linux做不到这一点。特上sf求教:如何解决这个问题?

操作系统:openSUSE 13.1 64bit
桌面环境:XFCE
根文件系统:btrfs
uname -a:Linux pc-776.localdomain 3.11.6-4-desktop #1 SMP PREEMPT Wed Oct 30 18:04:56 UTC 2013 (e6d4a27) x86_64 x86_64 x86_64 GNU/Linux
TF卡:Sandisk Ultra Class10 8GB,普通读卡器,实测有20MB/s写速度
硬件:H67主板,i3三代CPU,4G DDR3 1333内存,500G普通机械硬盘

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(3)
PHPzhong

I have never encountered this situation. When it gets really stuck (or before), use dstat and iotop -o to take a look, mainly the CPU and I/O parts. In addition, when using dd, remember to specify the appropriate bs, such as bs=10M.

Peter_Zhu

@Evian’s tips are extremely useful and perfectly captured the problem. Thank you very much!

The problem lies in iotop, irrelevant processes snapperd top the list:

This process is always requesting IO, which not only causes dd to crash, but also causes the hard disk light to be always on when there is nothing to do.

After checking, I found out that I like to try new things and use an overly pioneering file system like LVM+btrfs. If openSUSE is installed using btrfs, the snapper software will be automatically enabled.

http://forums.opensuse.org/english/get-technical-help-here/pre-release-beta/491728-13-1-rc2-snapperd-high-i-o-cpu-usage.html

@tosiara Before deciding to try btrfs did you not read any official documentation e.g openSUSE 12.3: Chapter 4. Snapshots/Rollback with Snapper

Yes, I know it's for 12.3. In particular see 4.2 where it states:

If you set up the root partition with Btrfs during the installation, Snapper—pre-configured for doing rollbacks of YaST or zypper changes—will automatically be installed.

This is equivalent to the "moonlight box" of the file system. It backs up and cleans the snapshot of the file system every hour... disable the automatic operation of the snapper (I dare not completely uninstall it for the time being) and everything is clean.

伊谢尔伦

It is recommended to try changing the IO scheduler to deadline:
echo deadline > /sys/block/sdX/queue/scheduler
This can be slightly improved by adjusting the IO scheduler.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template