MSYS2 瘦身小攻略

轉自:https://blog.csdn.net/goldenhawking/article/details/55105635?utm_medium=distribute.pc_relevant_right.none-task-blog-BlogCommendFromMachineLearnPai2-2.nonecase&depth_1-utm_source=distribute.pc_relevant_right.none-task-blog-BlogCommendFromMachineLearnPai2-2.nonecase

MSYS2, 喫硬盤的大神

MSYS2,集成了 x86 x64兩個開發環境,且可以使用 pacman 進行包管理,可謂方便的很!可是,這個東東也有一個很不好的地方,就是實在太佔硬盤。儘管下載的軟件包一般最大也就幾百兆,但這可是高壓縮格式的,一旦展開,會像乾燥劑喝了水一樣泵長起來。以我的MSYS2文件夾爲例子,安裝了常用工具如 qt、boost、opencv、 fftw、Openscenegraph等後,已經35GB了。可憐我的C盤啊!

初步瘦身

初步瘦身有兩個辦法:
1. 刪除pacman的下載包,位置在 var\cache\pacman\pkg
2. 刪除不必要的軟件包,比如 Qt 的靜態版本。

搬家

如果不安裝到C盤,有木有辦法呢?那就重新安到E盤吧。我的D是光驅,於是,化了一天時間,挪到了D盤。注意了,這裏有個解釋,就是msys2的環境一旦安裝後,是路徑綁定的,他的 dll 都經過了patch。如果你把文件夾拷貝到別的位置,那是不行的,除非重新全部patch。由於我的網速快,就偷懶直接下載安裝了。

如何快速部署多臺機器

太高興拉!壓縮一下,給小組的機器全部都安裝上吧!(⊙o⊙)…傻了,有的機器E盤是光驅。還有的機器,壓根就一個C盤,這可如何是好!而且,無論怎樣拷貝,35GB的體積都是太大了。無奈,如何是好?

junction, windows下的 ln-s

還好,對於熟悉運維的我來說,解決這個問題比較好辦。
首先,對與文件夾綁定,不怕,有微軟親爹生的鏈接器 junction!
這個工具其實就是linux下用爛的ln -s, 他的介紹如下:

Introduction

Windows 2000 and higher supports directory symbolic links, where a directory serves as a symbolic link to another directory on the computer. For example, if the directory D:\SYMLINK specified C:\WINNT\SYSTEM32 as its target, then an application accessing D:\SYMLINK\DRIVERS would in reality be accessing C:\WINNT\SYSTEM32\DRIVERS. Directory symbolic links are known as NTFS junctions in Windows. Unfortunately, Windows comes with no tools for creating junctions—you have to purchase the Win2K Resource Kit, which comes with the linkd program for creating junctions. I therefore decided to write my own junction-creating tool: Junction. Junction not only allows you to create NTFS junctions, it allows you to see if files or directories are actually reparse points. Reparse points are the mechanism on which NTFS junctions are based, and they are used by Windows' Remote Storage Service (RSS), as well as volume mount points.

Please read this Microsoft KB article for tips on using junctions.

Notethat Windows does not support junctions to directories on remote shares.

If you want to view reparse information, the usage for Junction is the following:


Using Junction

Use junction to list junctions:

Usage: [-s]

-s    Recurse subdirectories

Examples:

To determine if a file is a junction, specify the file name:

junction c:\test

To list junctions beneath a directory, include the –s switch:

junction -s c:\

To create a junction c:\Program-Files for "c:\Program Files":

C:\>md Program-Files

C:\>junction c:\Program-Files "c:\Program Files"

To delete a junction, use the –d switch:

junction -d c:\Program-Files
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38

有了這工具,隨便把家搬到哪裏,都可以連接到一個位置,那就是 C:\msys64 (或c:\msys32)

NTFS壓縮文件夾

在以前,我使用winMount進行壓縮、掛載。它曾經是一款很不錯的軟件,可以把帶有壓縮的文件掛載爲虛擬磁盤。儘管中文版的已經停止開發了,但是百度一下還是可以找到支持win7以上版本的安裝包。使用winMount 建立一個壓縮盤,把msys文件夾全部拷入,而後掛載爲Z:\,使用 junction 進行連接,即可完成部署。
現在,直接利用NTFS磁盤的文件夾壓縮,實現相同功能。方法是:
1. 在安裝前,新建文件夾,改名爲msys64之類的名字;
2. 右鍵單擊文件夾,選擇屬性、高級,把壓縮勾上;
3. 拷貝文件到該文件夾
4. 使用junction進行鏈接。
設置壓縮文件夾

有了這些手段,MSYS2就更舒心如意啦!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章