Skip to content

Commit

Permalink
Merge pull request #44 from #13
Browse files Browse the repository at this point in the history
Socios#13
  • Loading branch information
mdheller authored May 31, 2022
2 parents 9645beb + 484700f commit 279753f
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 246 deletions.
32 changes: 0 additions & 32 deletions docs/Booting a VM using MAC Physical Disk - script explanation.md

This file was deleted.

72 changes: 0 additions & 72 deletions docs/Disk partition - script.md

This file was deleted.

2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Socios

This repository contains scripts connected with the SociOS Linux Homebrew installer which can be installed witht he following:
brew tap SociOS-Linux/socios
brew tap SociOS-Linux/socios-setup
brew install socios

## Socios Package
Expand Down
10 changes: 5 additions & 5 deletions docs/booting_VM_w_mac_physical_disk.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Booting a VM using MAC Physical Disk:

1. After all the partitions are done the Virtual Machine is created from the Virtual Box, the user is prompted for the Virtual machine name of their choice. The VM name is created with the date and time information, so even if they provide similar name by mistake a separate VM will get created.
1. The script first searches for the folder VirtualBox/socios, it removes the folder if present, it creates the folder if not. This process occurs in root folder of every mac machine. After all the partitions are done the Virtual Machine is created from the Virtual Box, the VM name is fixed to "Inception".

```
cd ~
if [ -d socios/VirtualBoxVMs ]; then
rm -rf socios/VirtualBoxVMs
if [ -d VirtualBoxVMs/socios ]; then
rm -rf VirtualBoxVMs/socios
fi
mkdir -p socios/VirtualBoxVMs
mkdir -p VirtualBoxVMs/socios
```
- At first, the script check for the required folder in the root. If not present, it created it and provides the permission along with it.

Expand All @@ -22,7 +22,7 @@ Please provide the last number you see in the Linux Swap identifier(eg:3 for $wh
3. After the partition numbers are entered in, all the partitions are pointed to the vmdk file that is created for the virtual machine. The Mac physical disk is converted to storage space,swap and boot for Virtual Machine.

```
sudo vboxmanage internalcommands createrawvmdk -filename "/User/username/vmname/linux.vmdk" -rawdisk /dev/disk0 -partitions 4,5,6,7
sudo vboxmanage internalcommands createrawvmdk -filename "/User/username/Inception/Inception.vmdk" -rawdisk /dev/disk0 -partitions 4,5,6,7
```

4. The Mac username is asked from the user for providing necessary permission to the VMDK file and all the partition.
Expand Down
13 changes: 6 additions & 7 deletions docs/disk_partition.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
# Disk partition - script explanation

1. The script first creates a free space with default size of 50 gb if the user's choice is to stick to default settings by giving a "Yes/yes".
1. The script first creates a free space with default size of 150 gb if the user's choice is to stick to default settings by giving a "Yes/yes".

```
default_size=50
default_size=150
```

2. The user can also deny the default settings and can give a "No/no" which lets them decide how much space they need for SociOS.Either choice will create a free space for the sgdisk to do the rest.

```
read -p "Click Yes to use the default disk space for the partition, No to select custom disk space (Yes\No):" choice
case "$choice" in
Yes|yes|"") Input=1;;
No|no) Input=0;;
* ) { echo "Invalid option. Please select the correct option."; exit 1; };;
Yes|yes|y|Y|YES|"") Input=1;;
No|no|n|N|NO|"") Input=0;;
* ) { echo "Invalid option. Please select the correct option."; exit 1; };;
No|no) Input=0;;
esac
```

Expand Down
2 changes: 1 addition & 1 deletion docs/kernel_driver_not_installed_error.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Solution:
- Whether we are trying to set up a Linux VM the error is appearing because this is our Mac’s first time installing any Oracle products (like VirtualBox). You’ll need to give the piece of software explicit permission to access the computer. For this Error, we have found a solution kernel issue.


### Step1: Updating the Security policy in MAC Machine
### Step 1: Updating the Security policy in MAC Machine

- First, navigate to System Preferences by clicking the Apple icon on the top menu bar

Expand Down
55 changes: 37 additions & 18 deletions lib/create_vm.sh
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
#!/bin/bash
cd ~

if [ -d ~/VirtualBoxVMs/socios ]; then
rm -rf ~/VirtualBoxVMs/socios
if [ -d VirtualBoxVMs/socios ]; then
rm -rf VirtualBoxVMs/socios
fi

mkdir -p ~/VirtualBoxVMs/socios/
mkdir -p VirtualBoxVMs/socios

#Updating the folder permission
chmod -R 755 ~/VirtualBoxVMs/socios
chmod -R 755 VirtualBoxVMs/socios

# Destination to save the VDI File
# Destination to save the VDI File
DESTINATION=~/VirtualBoxVMs/socios
ISO=~/VirtualBoxVMs/socios
ISO=~/socios/image

#fetching the whole disk to provide permission for the partitions
parent_identifier="$(diskutil info /dev/$default_disk | grep "Part of Whole" | awk '{print $4}')"
whole_disk=/dev/"$parent_identifier"

# List available Guest OS on MAC Machine
echo "Available Guest OS on MAC Machine "
VBoxManage list ostypes | grep -i Fedora

echo "Enter the VM name: "
read name
MACHINENAME=$name-$(date +%d-%m-%Y_%H-%M-%S)
MACHINENAME=Inception

#Creating virtual machine
echo "Creating a $MACHINENAME virtual machine"
Expand All @@ -35,21 +37,38 @@ VBoxManage modifyvm $MACHINENAME --nic1 nat
vboxmanage modifyvm $MACHINENAME --cpus 4
vboxmanage modifyvm $MACHINENAME --graphicscontroller VMSVGA

diskutil list
space_available=$(diskutil info / | grep "Container Free Space" | awk '{print $4$5}')
echo "You have $space_available of free space in your Mac machine"
read -p "Enter the storage space for your virtual machine in GB in numerals:" gb
size=`expr $gb \* 1024`
diskutil list $whole_disk | grep -E "Linux Swap" | awk '{print $2$3$7}'
read -p "Please provide the last number you see in the Linux Swap identifier(eg:3 for $whole_disk"s3") : " first

diskutil list $whole_disk | grep -E "Bios Boot Partition" | awk '{print $3$4$8}'
read -p "Please provide the last number you see in the Boot partition identifier(eg:4 for $whole_disk"s4") : " sec

diskutil list $whole_disk | grep -E "Linux Filesystem" | awk '{print $2$3$7}'
read -p "Please provide the last number you see in the first Linux filesystem identifier(eg:5 for $whole_disk"s5") : " third
read -p "Please provide the last number you see in the seconnd Linux filesystem identifier(eg:6 for $whole_disk"s6") : " fourth

#diskutil umount /dev/$disk_id
sudo chmod go+rw $whole_disk"s"$first
sudo chmod go+rw $whole_disk"s"$sec
sudo chmod go+rw $whole_disk"s"$third
sudo chmod go+rw $whole_disk"s"$fourth
sudo chmod go+rw $whole_disk

read -p "Enter the name of your mac user: " USER


#Create Disk and connect Debian Iso
echo "Creating Virtual Hard Disk"
VBoxManage createhd --filename $DESTINATION/$MACHINENAME/$MACHINENAME.vdi --size $size --format VDI --variant Standard
vboxmanage internalcommands createrawvmdk -filename $DESTINATION/$MACHINENAME/$MACHINENAME.vmdk -rawdisk $whole_disk -partitions $first,$sec,$third,$fourth

#providing permission for vmdk file
sudo chown $USER $DESTINATION/$MACHINENAME/$MACHINENAME*.vmdk

#Add Storage Controller to Virtual Machine
VBoxManage storagectl $MACHINENAME --name "SATA Controller" --add sata --bootable on
VBoxManage storagectl $MACHINENAME --name "SATA Controller" --add sata --bootable on --hostiocache on

#Attach Virtual Hard Disk to Virtual Storage Controller
VBoxManage storageattach $MACHINENAME --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium $DESTINATION/$MACHINENAME/$MACHINENAME.vdi
VBoxManage storageattach $MACHINENAME --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium $DESTINATION/$MACHINENAME/$MACHINENAME.vmdk

#Add IDE Controller to Virtual Machine (To Later Connect ISO/CD/DVD)
VBoxManage storagectl $MACHINENAME --name "IDE Controller" --add ide --controller PIIX4
Expand All @@ -65,6 +84,6 @@ VBoxManage storageattach $MACHINENAME --storagectl "IDE Controller" --port 1 --d
VBoxManage startvm $MACHINENAME

#Resize the Virtualbox in VM
VBoxManage setextradata "$MACHINENAME" GUI/ScaleFactor 2.0
VBoxManage setextradata "$MACHINENAME" GUI/ScaleFactor 1.0

echo "ISO image booted in Virtualbox.... Start setup process"
8 changes: 4 additions & 4 deletions lib/image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

cd ~

if [ -d VirtualBoxVMs/socios/ ]; then
if [ -d VirtualBoxVMs/build ]; then
echo "Desitination available"

else

mkdir -p ~/VirtualBoxVMs/socios/
mkdir -p ~/VirtualBoxVMs/build

fi

echo "Checking For Fedora ISO Images in Destination."

if find ~/VirtualBoxVMs/socios/ -name Fedora.iso | grep -q 'Fedora'; then
if find ~/VirtualBoxVMs/build -name Fedora.iso | grep -q 'Fedora'; then

echo "Fedora ISO Image Available in Destination. Choose your partition Space."

Expand All @@ -25,7 +25,7 @@ wget --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download

echo "Copying the ISO image file to Socios Destination"

cp /tmp/Fedora.iso ~/VirtualBoxVMs/socios/
cp /tmp/Fedora.iso ~/VirtualBoxVMs/build

rm -rf /tmp/cookies.txt

Expand Down
6 changes: 3 additions & 3 deletions lib/purge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

echo "Do you want Uninstall VirtualBox & GDisk"

read -p "Click Yes to uninstall the Virtualbox & Gdisk, No to exist from the option (Yes\No):" choice
read -p "Click Yes to uninstall the Virtualbox & Gdisk, No to exit from the option (Yes\No):" choice

case "$choice" in
Yes|yes|"") Input=1;;
Expand All @@ -14,8 +14,8 @@ if [ $Input == 1 ]
then
echo "Uninstalling VirtualBox & GDisk"
brew uninstall --cask virtualbox
brew uninstall --cask gdisk
brew uninstall --cask gdisk
else
echo "VirtualBox & GDisk are Available in Destination"
exit
fi
fi
Loading

0 comments on commit 279753f

Please sign in to comment.