Maintaining a local git repository on a portable disk image file or partition
Posted December 12, 2010 at 11:04 by wyldckat
Tags git, keep history, no internet, openfoam, without internet
Here's the scenario: You need the latest OpenFOAM 1.7.x git version, but your Linux machine is stranded on a deserted lab without access to the internet or to any other machine that does have access to the internet. The only machine with internet access that you have access to, is on some other place in the world and on top of that, uses Windows for an operating system. But that certain Windows machine is yours and/or you have administrative powers over it!
What can you do? Install VMplayer or VirtualBox in it, create a Virtual Machine and install Ubuntu or some other Linux distribution on that VM!
How? Search the internet
I'm here just to explain how to have a portable git repository of OpenFOAM ![Cool](https://www.cfd-online.com/Forums/images/smilies/cool.gif)
Oh and don't forget to install git in that virtual machine! In Ubuntu, run this to install it:
OK, so you've got a working Linux (virtual or real) machine, with internet connection and git is installed. You also have a portable USB pen or harddrive, but it's formatted in NTFS of FAT32, which are Windows friendly, but not POSIX friendly. Now, you have two possible scenarios:
Therefore, I'm going to explain the second scenario.
_____________________________
Preparing and using the single ext3/4 file filesystem
Reference for this section: http://www.pendrivelinux.com/how-to-create-a-larger-casper-rw-loop-file/
This step-by-step list can be done in any folder you want, but only in Linux (and perhaps in Solaris). I'm going to assume you will do these steps directly within the Virtual Machine, so you won't go back and forth with the USB pen/drive.
You can do these steps directly in your USB pen/drive or create the file inside the Virtual Machine's disk and then copy or send it to your real machine.
So here goes:
Setting up the portable git repository
Now that you have the portable ext3/4 filesystem (may it be a single file or a partition in the portable drive), mount it on the virtual machine with Linux that has internet access. The folder where it is mounted for this tutorial will be:
So here goes:
Bruno
What can you do? Install VMplayer or VirtualBox in it, create a Virtual Machine and install Ubuntu or some other Linux distribution on that VM!
How? Search the internet
![Big Grin](https://www.cfd-online.com/Forums/images/smilies/biggrin.gif)
![Cool](https://www.cfd-online.com/Forums/images/smilies/cool.gif)
Oh and don't forget to install git in that virtual machine! In Ubuntu, run this to install it:
Code:
sudo apt-get install git-core
OK, so you've got a working Linux (virtual or real) machine, with internet connection and git is installed. You also have a portable USB pen or harddrive, but it's formatted in NTFS of FAT32, which are Windows friendly, but not POSIX friendly. Now, you have two possible scenarios:
- The USB pen/drive is yours and you don't mind reducing the NTFS/FAT32 partition and add a new ext3 or ext4 partition to it. For this, I suggest you use GParted; don't know how? Search the internet! "tutorial gparted" is a good search phrase.
Advantage with this scenario: you an ext3/4 partition dedicated for transporting an OpenFOAM git and or any other files you may need; mounting the partition should be easy. - The USB pen/drive is (not) yours and you can't change the partitions. In this case, you can create an ext3 or ext4 file system packed inside a single file! Isn't Linux great?
Advantage: this single-file ext3/4 filesystem can be copied to anywhere and to any filesystem. Even easily up/downloadable! NOTE: FAT32 has a limit of 2GB per file, so if you need a filesystem bigger than this to carry around, it's best to simply create a separate partition.
Therefore, I'm going to explain the second scenario.
_____________________________
Preparing and using the single ext3/4 file filesystem
Reference for this section: http://www.pendrivelinux.com/how-to-create-a-larger-casper-rw-loop-file/
This step-by-step list can be done in any folder you want, but only in Linux (and perhaps in Solaris). I'm going to assume you will do these steps directly within the Virtual Machine, so you won't go back and forth with the USB pen/drive.
You can do these steps directly in your USB pen/drive or create the file inside the Virtual Machine's disk and then copy or send it to your real machine.
So here goes:
- Let's create the file "ext4file" where the filesystem will be stored, with a size of 512MB (which should be enough, at least for now):Code:
dd if=/dev/zero of=ext4file bs=1M count=512
- Now we format that file as an ext4 filesystem:Code:
mkfs.ext4 -F ext4file
- Next we can create the folder "$HOME/efmnt" where the file will be mounted and mount the file onto it:Code:
mkdir $HOME/efmnt sudo mount ext4file $HOME/efmnt -o loop,user,owner
Code:su - mount /path/to/my/ext4file /home/my_user_name/efmnt -o loop,user,owner exit
- Do the things you want to do in the new portable file system, such as git clone and wget and all that. I'll explain later on another step-by-step list.
- Now we unmount the folder we mounted before, so we can take the file (or drive) somewhere else. In Ubuntu, run:Code:
sudo umount /path/to/my/ext4file
Code:su -c 'umount /path/to/my/ext4file'
- And finally, you can take your file to your other internetless machine, and mount/unmount as in points 3 and 5.
- To add more 256MB to your filesystem (be sure that the file is unmounted):Code:
dd if=/dev/zero bs=1M count=256 >> /path/to/ext4file
- Expand the filesystem inside the file:Code:
resize2fs /path/to/ext4file
Setting up the portable git repository
Now that you have the portable ext3/4 filesystem (may it be a single file or a partition in the portable drive), mount it on the virtual machine with Linux that has internet access. The folder where it is mounted for this tutorial will be:
Code:
/home/my_user_name/efmnt
- Go to the folder, clone the repository from github and get the ThirdParty package while I'm at it:Code:
cd /home/my_user_name/efmnt git clone git://github.com/OpenCFD/OpenFOAM-1.7.x.git wget http://downloads.sourceforge.net/foam/ThirdParty-1.7.1.gtgz?use_mirror=mesh
Code:git clone git://repo.or.cz/r/OpenFOAM-1.7.x.git
Code:git clone http://repo.or.cz/r/OpenFOAM-1.7.x.git
- Next time you need to update the repository on your portable repository (and while in your virtual machine), run:Code:
cd /home/my_user_name/efmnt git pull
- Unmount the folder, unmount/safely remove your portable drive and take it to your internetless Linux machine.
- Mount the file into a folder just as you did in the Virtual Machine. I'm going to assume it's the same exact folder.
- Now, for a new installation in your personal home folder, run:Code:
cd ~ mkdir OpenFOAM cd OpenFOAM git clone /home/my_user_name/efmnt/OpenFOAM-1.7.x tar -xzf /home/my_user_name/efmnt/ThirdParty-1.7.1.gtgz
- Unmount the file and (safely remove) the portable drive.
- Next time you bring your portable drive over with an update, don't forget to mount first and then simply run:Code:
cd ~/OpenFOAM/OpenFOAM-1.7.x git pull ./Allwmake > make.log 2>&1
You can unmount the file/folder when the "git pull" has finished.
- official git tutorial
- Mark Olsen's blog: Getting started with OpenFOAM and git
Bruno
Total Comments 0