原文链接:click here

Introduction

When one has downloaded an ISO file for installing or trying Ubuntu, it is recommended to test that the file is correct and safe to use. The MD5 calculation gives a checksum (called a hash value), which must equal the MD5 value of a correct ISO.

The program md5sum is designed to verify data integrity using the MD5 (Message-Digest algorithm 5) 128-bit cryptographic hash. MD5 hashes used properly can confirm both file integrity and authenticity.

In terms of integrity, an MD5 hash comparison detects changes in files that would cause errors. The possibility of changes (errors) is proportional to the size of the file; the possibility of errors increase as the file becomes larger. It is a very good idea to run an MD5 hash comparison check when you have a file like an operating system install CD that has to be 100% correct.

In terms of security, cryptographic hashes such as MD5 allow for authentication of data obtained from insecure mirrors. The MD5 hash must be signed or come from a secure source (an HTTPS page) of an organization you trust. See the MD5SUMS file for the release you're using under http://releases.ubuntu.com (and optionally the PGPsignatures in the MD5SUMS.gpg file), or refer to the secure UbuntuHashes page for the official list of Ubuntu MD5 hashes.

While security flaws in the MD5 algorithm have been uncovered, MD5 hashes are still useful when you trust the organization that produces them. Moving to more secure hashes like SHA-256 and Whirlpool is under discussion.

md5sum

The official page containing MD5 hashes for Ubuntu, Kubuntu, Edubuntu Xubuntu and Lubuntu is UbuntuHashes. More recent hashes may be available at http://releases.ubuntu.com/ : choose the relevant distribution and click on the MD5SUMS file.

MD5SUM on Linux

Most Linux distributions come with the md5sum utility so installation is usually unnecessary.

Check the iso file

Manual method

First open a terminal and go to the correct directory to check a downloaded iso file:

  • ubuntu@ubuntu-desktop:~$ cd Downloads
  • Linux is case sensitive so "Downloads" is NOT "downloads".

Then run the following command from within the download directory.

  • md5sum ubuntu-11.10-dvd-i386.iso

md5sum should then print out a single line after calculating the hash:

  • 8044d756b7f00b695ab8dce07dce43e5 ubuntu-11.10-dvd-i386.iso

Compare the hash (the alphanumeric string on left) that your machine calculated with the corresponding hash on the UbuntuHashes page.

An easy way to do this is to open the UbuntuHashes page in your browser, then copy the hash your machine calculated from the terminal into the "Find" box in your browser (in Firefox you can open the "Find" box by pressing <Ctrl> <F>).

When both hashes match exactly then the downloaded file is almost certainly intact. If the hashes do not match, then there was a problem with either the download or a problem with the server. You should download the file again from either the same mirror, or from a different mirror if you suspect a server error. If you continuously receive an erroneous file from a server, please be kind and notify the webmaster of that mirror so they can investigate the issue.

Semi-automatic method

Ubuntu distributes the MD5 hashes in a file called MD5SUMS near the bottom of the download page for your releasehttp://releases.ubuntu.com.

First download the MD5SUMS file to the same directory as the iso. Then run the following in a terminal.

  • cd download_directory
    md5sum -c MD5SUMS

md5sum will generate a bunch of warnings. Don't worry: the OK message will be buried somewhere within it!

  • md5sum: ubuntu-8.10-alternate-amd64.iso: No such file or directory
    ubuntu-8.10-alternate-amd64.iso: FAILED open or read
    md5sum: ubuntu-8.10-alternate-i386.iso: No such file or directory
    ubuntu-8.10-alternate-i386.iso: FAILED open or read
    md5sum: ubuntu-8.10-desktop-amd64.iso: No such file or directory
    ubuntu-8.10-desktop-amd64.iso: FAILED open or read
    ubuntu-8.10-desktop-i386.iso: OK
    md5sum: ubuntu-8.10-netbook-remix-i386.img: No such file or directory
    ubuntu-8.10-netbook-remix-i386.img: FAILED open or read
    md5sum: ubuntu-8.10-server-amd64.iso: No such file or directory
    ubuntu-8.10-server-amd64.iso: FAILED open or read
    md5sum: ubuntu-9.04-server-i386.iso: No such file or directory
    ubuntu-8.10-server-i386.iso: FAILED open or read
    md5sum: wubi.exe: No such file or directory
    wubi.exe: FAILED open or read
    md5sum: WARNING: 7 of 8 listed files could not be read

In this case the message we want is on the seventh line.

  • ubuntu-8.10-desktop-i386.iso: OK

Success?

Once you have verified the md5 hash, go ahead and burn the CD. You may want to refer to the BurningIsoHowto page.

Check the CD

So far so good, you have downloaded an iso and verified its integrity. When you boot from the CD you will be given the option to test its integrity. Great, but if the CD is corrupt then you have already wasted time rebooting. You can check the integrity of the CD without rebooting as follows.

Checking the CD directly

You would think you could simply use a command like this to get the MD5 hash of a burned image:

md5sum /dev/cdrom

However this will almost NEVER be the same hash as the iso image that was burned to the disk, because this command includes the empty space at the end of the disk, which changes the hash. So you must check only the part of the disk that was on the iso.

Manual method

First we need to know the size of the iso image. You could open up your favorite graphical file manager such as Nautilus or Dolphin, but since you need to use the command line anyways, you might as well use ls.

ls -l ubuntu-8.10-desktop-i386.iso
-rw-r--r-- 1 jsmith jsmith 732766208 2008-10-28 23:24 ubuntu-8.10-desktop-i386.iso

Now that we know the size of our iso image is 732766208, we can use dd to pipe only 732766208 bytes from our cdrom device into md5sum. Use a block size of 1 and set count to the size of the iso image. Note that this will probably take several minutes, so grab a snack and come back in a while.

dd if=/dev/cdrom bs=1 count=732766208 | md5sum
732766208+0 records in
732766208+0 records out
24ea1163ea6c9f5dae77de8c49ee7c03  -
732766208 bytes (733 MB) copied, 563.666 s, 1.3 MB/s

You could probably speed this up by using a larger block size (bs) and dividing count by the new block size. Since all iso images are multiples of 2048, that is an appropriate block size.

Check the calculated hash (in this case 24ea1163ea6c9f5dae77de8c49ee7c03) against UbuntuHashes as shown for the iso file above. Depending on your system, you may need to change cdrom to cdrom0 (or even cdrom1 if you have two CD drives).

Automated Script

Here is a shell script that will check the md5 hash of a burned disk and compare it to the hash of an iso image. Copy and paste it into your favorite text editor and save it as eg. hashcdrom.sh.

#Compares the checksums of an iso9660 image and a burned disk.
#This script is released into the public domain by it's author.
if [ -n "$BASH" ]; then
shopt -s expand_aliases
fi

if [ -n "$FILE" ]; then
FILE="$FILE"
else
FILE=`basename $0`
fi

if [ -n "$CHECKSUM" ]; then
alias CHECKSUM="$CHECKSUM"
elif which md5deep &> /dev/null; then
alias CHECKSUM='md5deep -e'
else
alias CHECKSUM='md5sum'
fi

if [ -n "$2" ]; then
DISKDEVICE="$2"
else
DISKDEVICE='/dev/cdrom'
fi

if [ -n "$1" ]; then
CSUM1=$(CHECKSUM "$1" | grep --only-matching -m 1 '^[0-9a-f]*')
echo 'checksum for input image:' $CSUM1
SIZE=$(stat -c '%s' "$1");
BLOCKS=$(expr $SIZE / 2048);
CSUM2=$(dd if="$DISKDEVICE" bs=2048 count=$BLOCKS 2> /dev/null | CHECKSUM | grep --only-matching -m 1 '^[0-9a-f]*')
echo 'checksum for output disk:' $CSUM2

if [ "$CSUM1" = "$CSUM2" ]; then
echo 'verification successful!'
else
echo 'verification failed!'
fi

else
echo ''
echo 'Usage:'
echo '  '$FILE' /path/to/iso [/path/to/cd/drive]'
echo ''
fi

Now open a terminal and type

sh /path/to/hashcdrom.sh /path/to/ubuntu-8.10-desktop-i386.iso /dev/mycdromdevice

Note that if your cdrom device is /dev/cdrom, you can omit that parameter.

It should print out something like

checksum for input image: 24ea1163ea6c9f5dae77de8c49ee7c03
checksum for output disk: 24ea1163ea6c9f5dae77de8c49ee7c03
verification successful!

If you verified that the iso image is okay (above), than you need not check the hash against UbuntuHashes.

This script has some nifty features. For example, if md5deep is installed (sudo aptitude install md5deep), it will use it to print out some progress information, such as how many bytes copied. You can also make it use different hashing algorithms such as sha256 and whirlpool by setting the CHECKSUM environment variable to the command you want to use to create the hash:

export CHECKSUM='whirlpooldeep -e'
sh /path/to/hashcdrom.sh /path/to/ubuntu-8.10-desktop-i386.iso /dev/mycdromdevice

This shell script depends on certain features found only in GNU grep, so it probably will not work on systems that do not ship the GNU utilities.

A method using wodim instead of dd

readom dev=/dev/scd0 sectors=0-352113 f=- |md5sum

where 352113 is result of dividing size of iso file in bytes by 2048.

Check the files on the CD

The MD5 hashes for every file on the CD are listed in a file called md5sum.txt. You can use this file to check the integrity of all the files on the CD.

  • cd /media/cdrom
    md5sum -c md5sum.txt | grep -v "OK$"

This will automatically check every file against the MD5 hashes stored in the file and outputs any failures. (Again, you may need to changecdrom, depending on your system). Beware, it can take a long time so don't worry if your terminal seems to have hung; provided the CD drive is still accessing, it is probably still working. It should not output anything if it there were no errors, and an error message if a file failed the check. The grep command option -v "OK$" filters out all of the files that pass the check, because there are usually a lot of them.

Success?

Congratulations, you now have a verified Ubuntu CD. Go ahead and use it (or play frisbee with it if you want).

MD5SUM on Mac OS X

There are three methods of using md5sum on an OS X machine.

Method 1 - The easiest (if MD5 is available) is using the Disk Utility program (Applications > Utilities, or by choosing "Utilities" from the Finder's "Go" menu). Open Disk Utility and wait for it to gather information about your disks. Go to the directory where you downloaded the Ubuntu disk image, and drag it to Disk Utility's dock icon (displays on the left-hand side of Disk Utility, underneath your physical drives). Select the iso file. Go to the "Images" menu and select Checksum > MD5. Be sure to choose "MD5" and NOT "MD5 image checksum" or "CRC-32 image checksum", as they are not the same and will give you different results.

Method 2 - If MD5 is not available in the Images > Checksum menu, open a terminal window (Applications > Utilities > Terminal.app). Type "md5", type a space, drag the iso file into the terminal window (appends command with iso file path), and press Enter. The command line returns the hash number.

Method 3 - You can use the Terminal.app and follow the instructions for MD5SUM on Linux, except use the command "openssl md5" instead of "md5sum".

Each method returns a hash number. Compare the hash number with the corresponding hash on the UbuntuHashes page. When both hashes match exactly, then the downloaded file is almost certainly intact.

If the hashes do not match, then there was a problem with either the download or a problem with the server. You should download the file again from either the same mirror, or from a different mirror if you suspect a server error. If you continuously receive an erroneous file from a server, please notify the webmaster of that mirror so they can investigate the issue.

digest(1) on Solaris

Use the Solaris digest(1) command, specifying the md5 algorithm with the -a flag. For instance:

  • $ digest -a md5 ubuntu-8.10-desktop-i386.iso
    24ea1163ea6c9f5dae77de8c49ee7c03

MD5SUM on Windows

Windows does not come with md5sum. You must download one from another location, preferably one that you trust. There are command line utilities (md5sum.exe) that work similarly to the Unix utility; one public domain version with source is available from Fourmilab, but the version available from Cygwin is probably easier to install and update, and Cygwin is also recommended and trusted as the source for many more Unixy utilities. Once installed, Cygwin's md5sum behaves exactly as described in MD5SUM on Linux above.

There are also graphical tools such as the one used in the walk-through provided below.

  1. Download and install winMD5Sum, a free and open source hash verification program.

  2. Right-click the ISO file.
  3. Click Send To, then winMD5Sum.

  4. Wait for winMD5Sum to load and finish the checksum (this may take a significant amount of time depending on your computer's performance).

  5. Copy the corresponding hash from UbuntuHashes into the bottom text box.

  6. Click "Compare"
  7. A message box will say "MD5 Check Sums are the same" if the hashes are equal.

MD5SUM with "Checksums calculator"

"Checksums calculator” is a free file checksum calculation utility, it can support the most commonly used file checksum algorithm, such as md5, crc32, and sha1, can batch process multiple files. This verification software has some useful features, but it is easy to understand and very easy to use. You can download the application here.

The program while is running under Windows 7 64bit.

MD5SUM on CD

To see if your Ubuntu CD was corrupted when burned to the disk, see the CDIntegrityCheck page, or follow the instructions below.

First mount the CD, if not already mounted:

  • sudo mount /dev/hda /cdrom

Then use the supplied md5sum file on the CD:

  • cd /cdrom
    md5sum -c md5sum.txt | grep -vi 'OK$'

Be patient, it takes some time. If the command outputs any errors, you'll know that either the burn was bad or the .iso is corrupt. Please note that this method does not verify authenticity unless the hash of the iso file is compared to the hash at the secure UbuntuHashes page.

Finally, you can unmount the CD after leaving the folder:

  • cd /
    sudo umount /dev/hda

External Links

  • Wikipedia's Cryptographic Hash Entry

  • Mac-How Everything about Macintosh OS

  • Mac Data Recovery A data recovery program on Mac OS X

VerifyIsoHowto

检查软件下载是否完整 MD5 工具使用 ----- md5sum相关推荐

  1. linux 前端开发软件下载,linux前端开发工具下载_系统之家

    相关软件 软件大小 版本说明 下载地址 Prepros Linux版是专为指定电脑系统所打造的版本,能够让用户快速开发出自己所需的前端页面,从而提升其工作效率,无论是Sass.Haml或TypeScr ...

  2. python中文版软件下载-专业PYTHON开发工具——PyCharm中文汉化版下载(图文)

    PyCharm是一种Python IDE,带有一整套可以帮助用户在使用Python语言开发时提高其效率的工具,比如调试.语法高亮.Project管理.代码跳转.智能提示.自动完成.单元测试.版本控制. ...

  3. matlab软件推广海报,海报制作软件下载-posterlabs海报制作工具下载1.0 官方版-西西软件下载...

    posterlabs海报制作工具是一款专业制作各种海报的软件,内置了各种各样的现成模板,使用非常方便,要使用posterlabs首先要下载一个安卓模拟器,小编在这里推荐靠谱助手! 靠谱助手下载地址 安 ...

  4. php编辑代码软件下载,php中文开发工具-php中文编辑器(中文php编程)下载PC版-西西软件下载...

    php中文编辑器(中文php编程),一款PHP中文编程开发软件,需要将全部文件覆盖到易语言编辑器环境内才能开启,内置了详细的操作说明,安装后用户即可享受到全中文环境下的PHP开发体验,让程序开发设计更 ...

  5. templatespider_v2.2 扒网站工具软件下载(含模版计算工具)

    介绍 将要扒取的网站页面的网址粘贴进去 点击左下方"开始抓取"按钮 等待抓取完毕,自动打开下载好的文件夹 下载链接 http://www.bytepan.com/cbWyWDJF6 ...

  6. [download]-软件下载地址-百度网盘

    软件下载 arm gcc交叉工具链的下载地址: 密码都是:1234 gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu.tar.xz gcc-arm-8.3-20 ...

  7. MATLAB接收机位置解算,GPS-receiver GPS软件接收机代码 完整的捕获 解算定位 (可 8个通道) matlab 240万源代码下载- www.pudn.com...

    文件名称: GPS-receiver下载  收藏√  [ 5  4  3  2  1 ] 开发工具: matlab 文件大小: 148 KB 上传时间: 2015-07-02 下载次数: 0 提 供 ...

  8. 网站服务器日志软件,网站日志分析工具软件-360星图完整单机版

    网站日志分析工具软件-360星图完整单机版 书法字体2018.06.14360星图 360星图是360旗下开发的一款实用的网站日志分析工具软件.利用360星图可以可以快速生成直观的网站日志报告,比起用 ...

  9. 一块金胜维128G M.2 NGFF SSD固态硬盘量产开卡恢复过程分享+INIC-6081开卡软件和PS3111量产工具下载

    一块金胜维128G M.2 NGFF SSD固态硬盘量产开卡恢复过程分享,顺便讲一下INIC-6081开卡软件和PS3111量产工具的下载方法. 这是一块金胜维128G M.2 NGFF SSD固态硬 ...

最新文章

  1. Android7.0多窗口实现原理(二)
  2. linux服务器的日志管理
  3. js平滑滚动到顶部,底部,指定地方
  4. 服务器不响应Ajax,web前端:解决在IE11浏览器下,JQuery的AJAX方法不响应问题
  5. JavaScript 中的原型(总则)
  6. android ViewPager之PagerAdapter中View的重用
  7. java工程师面试如何自我介绍
  8. mysql8 php7_在centos7安装nginx+mysql8+php7(LNMP)
  9. 编程实现背包的递归和非递归两种解法_算法动态规划(七)背包问题4
  10. 三问(why?what?how?)金融领域的机器学习
  11. Linux:mysqldump 用法 数据库导出
  12. 【实践】图推荐算法在EE问题上的应用(附交流视频和PPT下载链接)
  13. 关于虚函数重载遇到的怪问题 -- 为什么经常调用了基类的函数
  14. Python爬虫实战:BeautifulSoup库requests库-抓取链家网广州二手房信息
  15. python博弈论代码_博弈论(示例代码)
  16. 马云称每天都睡不好,担心公司被淘汰;王老吉回应喝凉茶延长寿命丨价值早报
  17. vue 刷新、重新加载app
  18. 企业上云是什么?有什么优点
  19. js模块化(ESModule与CommonJS)
  20. android开发视频资源 电驴10G下载

热门文章

  1. 手机app数据爬取难度等级评估
  2. 浏览器有哪些进程?浏览器进程,渲染进程,网络进程,渲染进程有哪些线程?
  3. latex 大于等于_Latex使用时的小技巧
  4. MOOC《Python语言程序设计》(第15次)Python计算生态概览(第九周)
  5. Android开发(四):在标题栏右上角实现菜单(三个点)
  6. 重置帆软决策系统用户名密码
  7. office的加载项作用
  8. 我的第一个tableau故事
  9. java 祖先_java – 家谱祖先查找算法
  10. 苹果网页显示无法连接服务器失败怎么办啊,苹果手机自带的浏览器显示无法连接互联网是怎么回事啊...