[Android Software/Hacking General [Developers Only]] Leoisright:
Here is a guide to help you with dual booting Windows 7/Ubuntu 12.04 with a SSD as boot drive and HDD as the secondary drive.

To view this tutorial or download click here:http://www.mediafire.com/view/?6jbie3c4dc7cp1t

First partitions. Using my current disks as examples. 1) 128gb SSD and 1) 750gb HDD.

Boot computer using live DVD/USB and open Gparted in your applications. Or open terminal and enter gparted.

The SSD should be /dev/sda and HDD should be /dev/sdb. On your SSD create three partitions.

1) 50gb format as ntfs and then label “windows_7”

2) 15gb and format as ext4 and choose “/”

3) The rest format as ext4 and choose “/home”

For the HDD, you will need to decide if you mainly run Windows or Linux. If you don't need your linux folder more than Windows, I would suggest just formating the entire HDD as “ntfs” and label “windows”. Other wise split up the drive as you see fit. If you are going to symlink common folders used in both systems, I then suggest using more room for windows.

Now comes the fun part. Accept your changes and reboot your device with the windows install disk either in the dvd drive or in the usb port. Reboot and choose to boot drive where your windows disk is located. Follow the prompts to install windows. After the system is installed, do not do any updates just yet. We are going to move “User” to the HDD and as a result saving much needed space on your SSD leaving only system and programs on there. To move /users to HDD follow this handy guide on a clean installed Windows.

1. Once setup and at the desktop, don't bother doing any customisation, but start up Computer	Management via Control Panel\System and Security\Administrative Tools.

2. Local Users And Groups\Users, select Administrator and enable the account.

3. Reboot.

4. Logon as Administrator, no password, go into normal User Account management and delete	the account created during setup and any and all files.

5. Startup Regedit and navigate to	HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList

6. Change the ProfilesDirectory from %SystemDrive%\Users to for example D:\Users.

7. Close down regedit and reboot.

8. Logon as Administrator and create a user account.

9. Logoff and logon using new account and let system create profile, which is now on your D:	drive which of course now the default location for all your personal files.

10. Start up Computer Management via Control Panel\System and Security\Administrative	Tools.

11. Local Users And Groups\Users, select Administrator and disable the account. Leaving this enabled is a big security risk !!!

The benefit to this is the Downloads/Music/Videos/My Documents/Documents folders will all be relocated back to ur HDD saving valuable space on your SSD. We will then symlink those same folders to /home in linux later saving even more space yet having a common place to use the folders to be cross platform compatible.

Next, finish installing and setting up Windows 7. It's a good idea to fully update Windows at this point. After that is complete you will then need to reboot computer with your Ubuntu 12.04 USB or DVD in the appropriate drive and select the correct bootable device. Then in the selection menu, choose to run linux from live DVD/USB.

This is a key part here. When it comes time to select which installation method you want, you will want to choose install Ubuntu next to Windows for dualboot system. Also, in the drop down box for where grub (boot loader) is to be installed, do NOT choose the same as windows loader as it will write over top and you wont be able to boot in to windows. Choose /dev/dba/ in the very root of your ssd. Then Linux will set up the “/” and “/home” in the partitions you made earlier.

After it installs, it will ask you to restart the machine and remove any media from the drives. Do so to let it finish rebooting.

Next up is Grub. Instead of choosing Ubuntu, choose Windows to verify that it still works and then open up computer and then D:/ and verify that D:/Users is located there. If so, reboot and choose Ubuntu and verify the installation took fine. If it doesn't boot Windows, you'll need to re-install windows and probably Ubuntu. This can be a pain in the butt but you will be rewarded later with a very nice setup.

After a successful boot to both systems you should be in Ubuntu to configure it to auto-mount “windows” at each boot.

Tweak Linux to support trim for ssd and other useful modifications

Add discard next to the proper drive in /etc/fstab file. Open a command-line (terminal) and

type:

sudo gedit /etc/fstab

Results will be similar to the following:

# /etc/fstab: static file system information.

#

# Use 'blkid' to print the universally unique identifier for a

# device; this may be used with UUID= as a more robust way to name devices

# that works even if disks are added and removed. See fstab(5).

#

# <file system> <mount point> <type> <options> <dump> <pass>

proc /proc proc nodev,noexec,nosuid 0 0

# / was on /dev/sda5 during installation

UUID=7219b425-9d8d-41e4-a957-e26b1e8ead4c / ext4 errors=remount-ro 0 1

# /home was on /dev/sda3 during installation

UUID=35030494-3d2d-4d4a-a605-32d91e7a6d12 /home ext4 defaults 0 2

The ones highlighted in red should be changed to add discard infront of errors= and

defaults. You can also add noatime if you want to. So it should look like this after the edit.

# / was on /dev/sda5 during installation

UUID=7219b425-9d8d-41e4-a957-e26b1e8ead4c / ext4 discard,noatime,errors=remount-ro 0 1

# /home was on /dev/sda3 during installation

UUID=35030494-3d2d-4d4a-a605-32d91e7a6d12 /home ext4 discard,noatime,defaults 0 2

Open Terminal and type:

sudo blkid

Output should be something like this.

/dev/sda1: LABEL="Windows_7" UUID="48AC1276AC125EAE" TYPE="ntfs"

/dev/sda3: UUID="35030494-3d2d-4d4a-a605-32d91e7a6d12" TYPE="ext4"

/dev/sda5: UUID="7219b425-9d8d-41e4-a957-e26b1e8ead4c" TYPE="ext4"

/dev/sdb1: LABEL="windows" UUID="1D3B46DD6CFD93D5" TYPE="ntfs"

/dev/zram0: UUID="4dc3b795-0931-484e-b809-0946253ab710" TYPE="swap"

Cut and paste the output information to a plain txt document for future use. Next you will want to type the following in terminal:

sudo gedit /etc/fstab

Next add this to the fstab at the bottom.

# Mount at boot

UUID=1D3B46DD6CFD93D5 /media/windows ntfs-3g defaults,rw,owner,uid=1000,gid=100

This will auto mount your windows hdd if you have the user folder moved to the hdd. Leaving the ssd mainly for system files, programs, and with linux would be “/” and	“/home”. You will see a very responsive system then.

Before you close, add the following to at the bottom of your FSTAB.

tmpfs /tmp	tmpfs defaults,noatime,mode=177 0 0

tmpfs /var/log tmpfs defaults,noatime,mode=1777 0 0

tmpfs /var/tmp tmpfs defaults,noatime,mode=1777 0 0

tmpfs /tmp tmpfs nodev,nosuid,size=7G 0 0

Your finished /etc/fstab should look similar to the following.

# /etc/fstab: static file system information.

#

# Use 'blkid' to print the universally unique identifier for a

# device; this may be used with UUID= as a more robust way to name devices

# that works even if disks are added and removed. See fstab(5).

#

# <file system> <mount point> <type> <options> <dump> <pass>

proc /proc proc nodev,noexec,nosuid 0 0

# / was on /dev/sda5 during installation

UUID=7219b425-9d8d-41e4-a957-e26b1e8ead4c / ext4 defaults,discard,noatime,errors=remount-ro 0 1

# /home was on /dev/sda3 during installation

UUID=35030494-3d2d-4d4a-a605-32d91e7a6d12 /home ext4 defaults,discard,noatime,defaults 0 2

# Mount hdd at boot

UUID=1D3B46DD6CFD93D5 /media/windows ntfs-3g defaults,rw,owner,uid=1000,gid=100

tmpfs /tmp tmpfs defaults,noatime,mode=177 0 0

tmpfs /var/log tmpfs defaults,noatime,mode=1777 0 0

tmpfs /var/tmp tmpfs defaults,noatime,mode=1777 0 0

tmpfs /tmp tmpfs nodev,nosuid,size=7G 0 0

Hit save then exit /etc/fstab. Then reboot your machine to test the auto-mount of windows.

Next, lets stop the syslog services and clean out your current temp and log directories. We'll also mount the new RAM disks and restart the syslog service. Note: the name of the syslog service will change from distribution to distribution.

sudo /etc/init.d/rsyslog stop

sudo rm -rf /tmp/*

sudo rm -rf /var/log/*

sudo rm -rf /var/tmp/*

sudo mount -a

sudo /etc/init.d/rsyslog start

To symlink important folders from windows to /home saving much is recommended so you can share files between system. In Linux /home/user folder, delete the following folders.

Documents

My Documents

Downloads

Videos

Music

Open terminal and enter the following to symlink windows folders over to linux thus using a centralized spot for both system.

ln -s /media/windows/Users/(USERNAME)/Documents /home/(username)

ln -s /media/windows/Users/(USERNAME)/”My Documents” /home/(username)

ln -s /media/windows/Users/(USERNAME)/Downloads /home/(username)

ln -s /media/windows/Users/(USERNAME)/Videos /home/(username)

ln -s /media/windows/Users/(USERNAME)/Music /home/(username)

*Make sure when putting in username, the first one is username for windows while the second one is the username for linux.

Time to edit the sysctl.conf for some added tweaks for internet boosts and other good things.

Hit cntrl+alt+T to open terminal and enter:

sudo gedit /etc/sysctl.conf

Add the following to the bottom of the conf file. (cut and paste should be fine)

# Tweaks for faster broadband…

net.core.rmem_default = 524288

net.core.rmem_max = 16777216

net.core.wmem_default = 524288

net.core.wmem_max = 16777216

net.ipv4.tcp_wmem = 4096 87380 16777216

net.ipv4.tcp_rmem = 4096 87380 16777216

net.ipv4.tcp_mem = 524288 524288 524288

net.ipv4.tcp_rfc1337 = 1

net.ipv4.ip_no_pmtu_disc = 0

net.ipv4.tcp_sack = 0

net.ipv4.tcp_fack = 1

net.ipv4.tcp_window_scaling = 1

net.ipv4.tcp_workaround_signed_windows=1

net.ipv4.tcp_timestamps = 1

net.ipv4.tcp_ecn = 0

net.ipv4.route.flush = 1

net.ipv4.tcp_low_latency=1

net.ipv4.ip_no_pmtu_disc=0

net.ipv4.tcp_mtu_probing=1

net.ipv4.tcp_frto=2

net.ipv4.tcp_frto_response=2

## don't cache ssthresh from previous connection

net.ipv4.tcp_no_metrics_save = 1

net.ipv4.tcp_moderate_rcvbuf = 1

## recommended to increase this for 1000 BT or higher

net.core.netdev_max_backlog = 2500

##enable window scaling

net.ipv4.tcp_window_scaling = 1

##improve desktop reactions

vm.swappiness=10

vm.vfs_cache_pressure=1000

vm.dirty_background_ratio=10

vm.dirty_ratio=30

Save and Exit.

Another one if you are using a ssd drive for main activity, check your scheduler.

Open terminal and enter the following.

cat /sys/block/sdX/queue/scheduler

*where X is the letter for the SSD device.

The readout should be the following.

noop deadline [cfq]

Note: Only switch the scheduler to noop or deadline for SSDs. Keeping the cfq scheduler for all other physical HDDs is highly recommended.

To change this, using the system virtual filesystem is preferred when the system has severy physical storage devices (for example an SSD and an HDD). Add the following line in /etc/rc.local:

echo noop > /sys/block/sdX/queue/scheduler

where X is the letter for the SSD device.

Because of the potential for udev to assign different /dev/ nodes to drives before and after a kernel update, users must take care that the noop scheduler is applied to the correct device upon boot. One way to do this is by using the SSD's device ID to determine its /dev/ node. To do this automatically, use the following snippet instead of the line above and add it to /etc/rc.local:

SSD=(ata-OCZ-ONYX_XA1Y7CE3709UG79OTHVM ata-SAMSUNG_SSD_830_Series_S0VTNYABA01063)

declare -i i=0

while [ "${SSD[$i]}" != "" ]; do

NODE=`ls -l /dev/disk/by-id/${SSD[$i]} | awk '{ print $NF }' | sed -e 's/[/\.]//g'`

echo noop > /sys/block/$NODE/queue/scheduler

i=i+1

done

where SSD is a Bash array containing the device IDs of all SSD devices. Device IDs are listed in /dev/disk/by-id/ as symbolic links pointing to their corresponding /dev/ nodes. To view the links listed with their targets, issue the following command:

ls -l /dev/disk/by-id/

Swap Space on SSDs

One can place a swap partition on an SSD. Note that most modern desktops with an excess of 2 Gigs of memory rarely use swap at all. The notable exception is systems which make use of the hibernate feature. The following is recommended tweak for SSDs using a swap partition that will reduce the "swapiness" of the system thus avoiding writes to swap. In the /etc/sysctl.conf you can Maximize performance by changing the values below:

vm.swappiness=1

vm.vfs_cache_pressure=50

Example of a machine with 8 GB of physical memory:

tmpfs /tmp tmpfs nodev,nosuid,size=7G 0 0

Configuring your system to compile Android Open Source Code.

Java-Oracle 7:

This isn't yet supported with Android compiling that I know of. If you have this listed you will need to uninstall this and re-install java6 JDK/JRE.

Open Terminal and first type in the following.

sudo apt-get install git-core gnupg flex bison gperf build-essential \ zip curl libc6-dev libncurses5-dev:i386	x11proto-core-dev \ libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-dev:i386 \ g++-multilib mingw32 openjdk-6-jdk tofrodos python-markdown \ libxml2-utils xsltproc zlib1g-dev:i386

Then type "sudo gedit /usr/include/linux/usb/ch9.h" and on line 592 replace

return __le16_to_cpu(epd->wMaxPacketSize);

with:

# return le16_to_cpu(epd->wMaxPacketSize);

return __le16_to_cpu(epd->wMaxPacketSize);

Installing required packages *ubuntu 12.04 (this is taken from source.android.com/source/initializing.html)

Building on Ubuntu 12.04 is currently only experimentally supported and is not guaranteed to work on branches other than master. Open terminal and cut and paste the following:

sudo apt-get install git-core gnupg flex bison gperf build-essential \ zip curl libc6-dev libncurses5-dev:i386	x11proto-core-dev \ libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-dev:i386 \ g++-multilib mingw32 openjdk-6-jdk tofrodos python-markdown \ libxml2-utils xsltproc zlib1g-dev:i386

Setting up ccache

You can optionally tell the build to use the ccache compilation tool. Ccache acts as a compiler cache that can be used to speed-up rebuilds. This works very well if you do "make clean" often, or if you frequently switch between different build products.

Put the following in your .bashrc or equivalent.

export USE_CCACHE=1

By default the cache will be stored in ~/.ccache. If your home directory is on NFS or some other non-local filesystem, you will want to specify the directory in your .bashrc as well.

export CCACHE_DIR=<path-to-your-cache-directory>

How To Decrease Boot Times

**Full credit to PinGuy for suggesting this. Original thread found HERE

If you are finding it is booting slower then it used to there are a couple of things you can do.

The first is to run this command:

Code:

sudo rm /var/lib/ureadahead/pack

Then reboot twice. First time to generate a new ureadahead. Then the second time you boot it, it should be a lot faster. You can read up more about ureadahead here. You can also run BootUp-Manager:

Code:

su-to-root -X -c bum

And Turn off anything that starts at boot you don't want running.

**( I don't take credit for making any of these mods or the brains behind them. I only wanted to sit down and do a lot of research to make my system run very good. After talking to a few developers, they were interested in this and encouraged me to start a tutorial on this setup)

I have a pretty powerful laptop. i7, 16gb RAM, fully loaded with a SSD and a HDD. After using these tweaks, it's possible to boot Ubuntu in about 6.5 seconds from Grub and 8.5-9 for Windows. What most excites me is the ability to share folders between the two systems allowing me to save a tremendous amount of storage space and the ability to use them in both systems.

This is going to be a work in progress thread and urge others to PM tips and tweaks so they can be added on so we all can run our systems the best possible. Also, if you see any errors, please point them out so it can be adjusted. Feel free to PM me if you spot any problems.

Resources:

Download Ubuntu 12.04 LTS Here

https://wiki.archlinux.org/index.php/Solid_State_Drives;

http://www.cyberciti.biz/faq/howto-delete-remove-software-using-apt-get-command/;

http://xdaforums.com/showthread.php?t=1604076

http://source.android.com/source/index.html

For Git setup and SSH keys to commit to git.

http://help.github.com/linux-set-up-git/