Jump to content

The Linux User's Guide to Installing Mods on the Enhanced Editions


Recommended Posts

The Linux User's Guide to Installing Mods on the Enhanced Editions
Installing mods for the Linux versions of Beamdog's Enhanced Editions is a bit of a trashfire. The problem starts from the fact that Linux is a case-sensitive OS. In other words, foo.txt and FOO.txt are two different files. On Windows and macOS, which are case-insensitive, these are the same file. Before the EE's, Linux gamers could just use the tolower tool that comes with Weidu. This method still works for installing mods on EE versions... until you try to start the game. It crashes because it is looking for a number of mixed case filenames that are no longer there. Sigh.
There have been a number of solutions that work to varying degrees using bash scripts that do the job of tolower AND keep track of the filenames so they can be restored later, or create a crap ton of mix-case symlinks to tolowered game files. However there always seems to be some situation that derails these methods.
Fortunately, I found a post on Pocket Plane by Koteko that forms the base for a pretty solid solution that I would like to flesh out and improve here. I have been using this method myself to test K4thos's Enhanced Edition Trilogy mod, which has a very intensive install process. So far it's been rock solid. (mostly)
Here's the summary of what we're going to do:
Part I - Creating a Virtual Disk to store the games and modding tools
1. Create a disk image.
2. Put an NTFS filesystem on it.
3. Mount it with Tuxera's ntfs-3g fuse driver in CASE SENSITIVE mode.
4. Move EE games to the mounted image.
5. Replace the emptied game folders with symlinks to the games on the mounted image.
6. Edit /etc/fstab so the image gets mounted on boot.
Part II - Install Weidu and other mod Tools
1. Create a directory in our modbox for tools
2. Add the tools directory to your $Path
3. Install Weidu
4. Install modmerge
5. Unpack Siege of Dragonspear
6. Finish
Part III - How-To's, Caveats, and PAQ's (Preemptively Answered Questions)
1. Installing Mods
2. Quickly Converting Line Endings
3. Chitin.key, Backslashes, and You
4. Re-mounting as Case-Sensitive
5. Some Notes for Steam Users
6. PAQ: "Why not just make /mnt/modbox a Steam Library?"
7. PAQ: "ciopfs can do this too..." or "dd is better..." or "truncate is better..."
8. PAQ: "Why not just use a REAL OS?"
When we're done, you'll have your EE games in a place where you can install weidu mods without having to screw around with filename or symlinks AND run the game.
Ready? Let's do it!
Part I - Creating a Virtual Disk to store the games and modding tools
1. Create a disk image.
We're going to make a 30G image. That should be enough room for vanilla copies of BG:EE, BG2:EE, and IWD:EE with some extra room for mods. We are naming our image file "ee_modbox.img"
fallocate -l 30G ee_modbox.img
2. Put an NTFS filesystem on it.
You'll need ntfs-3g on your system. Install it using whatever method suits your distro.
mkntfs -F ee_modbox.img
You may get some stern warnings. I believe they only matter if we were going to boot a windows installation from the image... which we aren't. So ignore them.
3. Mount it in CASE SENSITIVE mode.
After mkntfs has done its thing, create or pick a directory somewhere as the mountpoint for the image. Depending on your distro, you'll either need to be root or use "sudo". I'm going to use /mnt/modbox for this example. We are going to temporarily mount this in case-sensitive mode for the copy job. We might not have to, but its more of a precaution from Steam sometimes getting grouchy later on.
ntfs-3g ee_modbox.img /mnt/modbox
4. Move EE games to the mounted image.
Create a new directory for each of the games you will be moving. use something short and lowercase.
mkdir /mnt/modbox/{bgee,bg2ee,iwdee}
Now move your game files to these directories. If you are using Steam, which I am in the examples below, make sure it is not running. The game files will be located in the SteamApps/common directory of wherever your Steam Library is located. By default, this would be ~/.local/share/Steam/SteamApps/common, but you can look in Steam's "Download" settings to find out for sure.
mv ~/.local/share/Steam/SteamApps/common/Baldur\'s\ Gate\ Enhanced\ Edition/* /mnt/modbox/bgee
mv ~/.local/share/Steam/SteamApps/common/Baldur\'s\ Gate\ II\ Enhanced\ Edition/* /mnt/modbox/bg2ee
mv ~/.local/share/Steam/SteamApps/common/Icewind\ Dale\ Enhanced\ Edition/* /mnt/modbox/iwdee
5. Replace the emptied game folders with symlinks to the games on the mounted image.
rmdir ~/.local/share/Steam/SteamApps/common/Baldur\'s\ Gate\ Enhanced\ Edition
rmdir ~/.local/share/Steam/SteamApps/common/Baldur\'s\ Gate\ II\ Enhanced\ Edition
rmdir ~/.local/share/Steam/SteamApps/common/Icewind\ Dale\ Enhanced\ Edition


ln -s /mnt/modbox/bgee ~/.local/share/Steam/SteamApps/common/Baldur\'s\ Gate\ Enhanced\ Edition
ln -s /mnt/modbox/bg2ee ~/.local/share/Steam/SteamApps/common/Baldur\'s\ Gate\ II\ Enhanced\ Edition
ln -s /mnt/modbox/iwdee ~/.local/share/Steam/SteamApps/common/Icewind\ Dale\ Enhanced\ Edition
Test that the games run before proceeding.
6. Edit /etc/fstab so the image gets mounted on boot.
Edit your /etc/fstab in your text editor of choice and add this line:
/path/to/ee_modbox.img    /mnt/modbox lowntfs-3g    windows_names,ignore_case,umask=007,uid=your_user_name       0       0
Be sure to change "your_user_name".
Save, reboot, and check to see that the virtual drive was mounted and that the games work.
Part II - Install Weidu and other mod Tools
1. Create a directory in your modbox for tools
mkdir /mnt/modbox/tools
2. Add the tools directory to your $Path
PATH=$PATH:/mnt/modbox/tools
export PATH
Put the above in your ~/.bash.rc so it persists across reboots.
3. Install Weidu
Download Weidu for Linux from: http://www.weidu.org/~thebigg/. Extract the contents for your architecture from the archive to your tools directory. You can exclude tolower ;-).
4. Install modmerge
You only need this if you have BG:EE and SoD. Download Scott Brook's "modmerge" tool for your architecture from: https://github.com/ScottBrooks/modmerge/releases and extract it to the tools directory.
5. Unpack Siege of Dragonspear
From a terminal, cd into your bgee directory and run:
modmerge
Answer "y" and wait for the process to complete.
6. Finish
That's it! You now have a handy environment that will allow you to easily install mods AND play the games without screwing around with renaming files or symlinks. Read on for some guidance on installing mods and potential caveats.
Part III - How-To's, Caveats, and PAQ's (Preemptively Answered Questions)
1. Installing Mods
Download a mod and extract it. There is usually a directory named after the mod that contains its resources. The mod directory itself goes into the game's directory, not the contents of the mod directory. To install the mod, open a terminal, cd into the game's directory, and run:
weinstall name_of_mod
If the mod is not arranged as described, or if for some reason the method above doesn't work, look for a .tp2 file and run:
weidu name_of_mod.tp2
IMPORTANT: Installation order of mods matters! However, this is not a guide about installation order. Look around the various IE modding sites where there are resources, such as Big World Project, that can give you much better guidance in this area than I can.
2. Quickly Converting Line Endings
Speaking of Big World Project, if you are planning on doing a Mega Mod install, chances are you are going to be installing the Big World Fixpack. This unique mod works differently than other ones. You first have to extract all your mods, but NOT install them. Then you run the BWFP and it looks through those extracted mods and modifies them to fix cross-mod incompatibilities... except it won't for us because text files in the Linux world use one type of line ending, and Windows uses another, so BWFP won't be able to find any of the search strings it's looking for. dos2unix to the rescue! Just to be safe, extract all of your mods, including BWFP, to an empty directory rather than your game folder. cd into the directory with your mods and run the following one-liner:
find ./ -type f -print0 | xargs -0 dos2unix --

This line will save you from having to run dos2linux yourself a couple hundred times. I wish I could take credit for this, but someone way smarter posted it on stack overflow. Note: You may have to install dos2unix from you friendly neighborhood package repository.

3. Chitin.key, Backslashes, and You
There's one other issue unique to Linux (and macOS) that we haven't entirely dealt with. Mods that recompile the chitin.key file with additional paths will use backslashes as path separators (because windows). Argent77 has written some code for his DLCbuilder tool that replaces the wrongslashes with rightslashes. I have packaged it into a separate mod which can be downloaded below. You ONLY need this if you aren't using DLCbuilder or K4thos's Enhanced Edition Trilogy, which has this built into the installation process as well. It should probably be the last mod in terms of install order. This is a temporary workaround until Weidu gets updated to handle this scenario. If you know of other solutions, please inform me and I will update this guide.
UPDATE: While doing my own mega install, I noticed that this tool is a bit more necessary than I thought. EET does it's chitin.key fix at the end of the "core" phase, before you've installed all of your other mods. Some of those other mods changed chitin.key and added more backslashes, and thus prevented the game from launching until I ran this fix. So depending on your mod loadout, you will definitely want to give this a run at the end of your install.
4. Re-mounting as Case-Sensitive
At some point, you might want to mount your modbox in case-sensitive mode. To do this, first unmount the virtual disk:
umount /mnt/modbox
and mount it again like this:
ntfs-3g ee_modbox.img /mnt/modbox
5. Some Notes for Steam Users
There is always the lurking danger of an update coming out and Steam hosing your carefully crafted mod loadout. And there is no way to turn off the Great God Auto Update. But there are a few things you can do to decrease the risk. First is to do a periodic backup of your game folder. I personally use backintime which lets me take snapshots of my game folders over the course of a large install. Next, you can set the game to update only when you run it, so you at least have a chance to catch a news item somewhere that a game updated. Last, you can go into steam settings and set a particular time to allow auto updates. Set it to a time when Steam will not be running. I suppose you might change the directory permissions for the game folders, but I have not experimented with the implications of this. Please feel free to share your ideas.
One last thing, don't use the "verify game files" in Steam's properties for the game. See below.
6. PAQ: "Why not just make /mnt/modbox a Steam Library?"
I know, it totally makes sense. I tried it that way first. It did not go well. I foolishly decided to verify the game's files in steam, and it wanted to perpetually re-download the game. Please feel free to experiment and let me know how it goes.
7. PAQ: "ciopfs can do this too..."
There have been other posts here and there about getting around the case-sensitivity issue with ciopfs. I tried it that way, too. I found it weird, confusing and counter intuitive for this particular use-case. YMMV.
8. PAQ: "You should use dd/truncate instead, because..."
You are absolutely welcome to use whatever tool suits your technical ideology. Freedom is a beautiful thing. I chose to use fallocate because the command was easy to remember. That's all.
9. PAQ: "Why don't you just use Windows?"
Please don't. I'm trying to help my fellow penguins reach the mod nirvana that other OS users enjoy, and that's good for everyone!
Edited by corvias
Link to comment

Just two notes:

- the rms should be rmdirs

- the first mkdir line will likely confuse copy-pasters, so I suggest you either write all three explicitly or use brace expansion

- Good call.

- LOL. I had it that way originally, but I thought I would get complaints about the opposite. Plus I screwed up the command in the first place.

Link to comment

Hi!

 

I know that this is an older thread, but after several attempts, I simply cannot install EET using the method in OP, because something goes wrong with mount it seems:

 

-----------------

[...]

Extending game scripts ...
Copying and patching 2 files ...
Copying and patching 1 file ...
Copying and patching 6 files ...
Copying and patching 1 file ...
Copying 1 file ...
ERROR: error copying [baldursGateII]
ERROR: COPY ~BaldursGateII~ ~BaldursGateII~ FAILED: cannot open target
Stopping installation because of error.
Stopping installation because of error.
Stopping installation because of error.
Stopping installation because of error.
Stopping installation because of error.

ERROR Installing [EET core - resource importation], rolling back to previous state
ERROR: Sys_error("Transport endpoint is not connected")
ERROR: problem parsing TP file [eet/eet.tp2]: Sys_error("Transport endpoint is not connected")

FATAL ERROR: Sys_error("Transport endpoint is not connected")
Fatal error: exception Sys_error("Transport endpoint is not connected")

----------------------

After this the mounted ntfs image becomes unreachable until I reboot.

If I retry the install after reboot, I get the following error:

----------------------

[EET/temp/patch/baf/BDNOREST.baf] PARSE ERROR at line 44 column 1-57
Near Text: )
unknown object SPECIFIC specifier [CULTIST_NEUTRAL]

 

[EET/temp/patch/baf/BDNOREST.baf] ERROR at line 44 column 1-57
Near Text: )
Parsing.Parse_error
ERROR: parsing [EET/temp/patch/baf/BDNOREST.baf]: Parsing.Parse_error

 

--------------------

 

Does anyone have an idea what could be wrong?

 

Cheers!

Link to comment

icon_share.png emilio

I have the same error in EET v1.0RC11.1

The file system crashes with what I think is an memory allocation error and the mount point becomes unavailable, hence the "Transport endpoint is not connected".

 

Edit: The game is corrupt after this error.

 

 

 

For Ubuntu (Debian too, I think) users: EET's Lua is also build against libreadline6 which is not supported on Ubuntu 18.04. (Ubuntu messed up compatibility between LTS releases here. Crude fix is to install the 16.04 version https://packages.ubuntu.com/xenial/libreadline6)

Edited by Incantatar
Link to comment

There seems to be a segfault in glibc, dmesg tells me:

mount.lowntfs-3[13796]: segfault at 559900000000 ip 00007f9d4c4eac01 sp 00007fff65d2acd0 error 4 in libc-2.27.so[7f9d4c453000+1e7000]

It happens on 18.04 and 19.04, but not on 16.04.

I found some posts around the net about segfaults in glibc 2.27, like https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=893320, but nothing helpful.

 

libreadline should be fixed by now BTW.

 

Edited by andy-held
Link to comment

Enabling case-insensitive file operations on Linux (kernel 5.2 or later)

With the release of the Linux 5.2 kernel it is possible to set selected directories into case-insensitive mode. This mode is called "casefolding" in documents and man pages. With this mode enabled, all file name comparison operations will ignore the letter case. Files like test.txt, TEST.TXT and Test.txt will be treated as one and the same file. This feature is (currently) only available for the ext4 filesystem.

Perform these steps to enable casefolding:

  1. Format the partition: Make sure you have formatted the partition with casefolding enabled. This can be done by specifying the option "-O casefold" to the mke2fs or mkfs.ext4 command. Example:
    mkfs.ext4 -O casefold /dev/sda1

    It is also possible to enable casefolding on existing ext4 partitions with the tune2fs command. Make sure that the partition is unmounted and perform the following command:

    tune2fs -O casefold /dev/sda1

     

  2. Mount the partition: The distribution should take care of it automatically if you choose to format the home or root partition. It might be safer (and less work) to create a new partition and bind it to a mount point inside your home folder (e.g. $HOME/games/ie_games).
     

  3. Folder preparations: Make sure the folder you want to put into case-insensitive mode is empty (i.e. it should contain no files or folders, including "lost+found"). You can temporarily move any files and folders somewhere else if needed. After completing step 4 you can move everything back.
     
  4. Enable casefolding: Call "chattr +F path_name" to enable casefolding, where "path_name" is the path to the folder you want to set into case-insensitive mode. The folder must be empty for the operation to succeed. Example:
    chattr +F $HOME/games/ie_games
    This command will enable casefolding for all files and folders inside the "ie_games" folder.
     
  5. (Optional) Check whether casefolding has been successfully activated, with the "lsattr" command. Example:
    lsattr $HOME/games

    The folder entry for "ie_games" should list the "F" attribute.
     

And you're done! :thumbsup:

You can now install or restore your IE game installations. With casefolding enabled WeiDU will find any file or directory regardless of case, just like on Windows or macOS platforms.

CAUTION: Don't enable the "casefold" option on your system or boot partition. Boot managers like GRUB don't support this filesystem option (yet) and refuse to boot the system.

 

IMPORTANT
Make sure that all directories in the path to the game folder are lower-cased, or WeiDU won't find files specified by absolute paths. This is relevant for installing EET or other mods that require access to files outside the game installation.

Casefolding is only enabled for the directory specified in step 4. So any parent folder in the path containing upper- or mixed-case letters will trigger errors, since WeiDU automatically to-lowers pathnames before they are applied to the file operation. For example, "/home/username/Games" should be renamed to "/home/username/games".

 

OPTIONAL BUT RECOMMENDED
EE games may also look for files in their respective user folder, which contains saved games, portraits, screenshots or the baldur.lua. These folders can be found in $HOME/.local/share and are called "Baldur's Gate - Enhanced Edition", "Icewind Dale - Enhanced Edition", etc.. To turn on casefolding, simply repeat steps 3 and 4 for each folder. Alternatively you can create these folders manually somewhere inside your "ie_games" path and add symlinks for each one in $HOME/.local/share.

I wouldn't recommend enabling casefolding for the whole $HOME/.local/share folder, since it contains configuration data for all kinds of applications, which may also intentionally store files or folders of same name but different case.

Edited by argent77
Clarified instructions
Link to comment

Never heard of casefolding, sounds cool. I'll look into testing that some time! 

I prefered not to use NTFS and instead use JFS with OS/2 compatibility mode turned on making it case-insensitive. I've never had an issue with needing it to be case-sensitive like step 3 indicates may be an issue, but I've not done extensive testing. If anyone else prefers this option, simply install jfsutils instead of ntfs-3g replace the ntfs commands in steps 2 and 3 with:

mkfs.jfs -O ee_modbox.img
mount ee_modbox.img /mnt/modbox/

and the fstab line in step 6 with 

/path/to/ee_modbox.img   /mnt/modbox      jfs             rw,relatime     0 0

Like I said, I've not encountered any problems using it this way, but you might. On the down side, unlike the ntfs filesystem there is no way to mount it case-sensitive if that's actually ever needed. On the plus side (depending on how you feel about kernel mode fs vs fuse..), JFS is implement in the kernel and doesn't require fuse.

Options are great, and this is the one I use.

Link to comment
Guest Nirow

Thanks @argent77, the casefolding method did it for me.

I tried a ntfs partition before and was getting an error "Transport endpoint is not connected", everytime during scs installation. Smaller mods like npcproject or tweaks worked though.

But now I can install scs AND I don't have to use ntfs! 🥳

Link to comment

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...