The Switch to Linux: Accessing a Second (Windows) Hard Drive
15 October 2009
Some time ago, I decided to make the switch to Ubuntu Linux. I intend to provide a log of what I've learned along the way. It will not be in any particular order. I'm writing these things as I have the time, which is sometimes well after the fact.
Today, I'm going to talk about how I set up my Linux box so that I could get access to the Windows partitions on the two hard drives. Bit of background. The system I'm working from is an older Gateway 700GR (bought in 2003). It came originally with a 250 GB SATA. I've since upgraded that to two 750 GB SATA drives. Plus, I've added a 2TB (terabyte) external drive. After loading Ubuntu Linux, I still wanted to get access to my Windows files. I'll go through the steps here that I took to do so. I'm not going to explain every part of the process. Frankly, I can't. Others can explain it better than I. I'm simply going to provide enough details so that you can duplicate my steps and, perhaps, do the same thing on your computer. Let's get started.
The steps I took were as follows:
- Determining my username.
- Determining the partition descriptors.
- Creating a new mount point directory.
- Editing the /etc/fstab file.
Step #1: Determining Your Username. Open a terminal (Applications -> Accessories -> Terminal). Look at the command prompt that first comes up. It will say something such as:
some_name@my_computer:~$
The part that you are interested in is the part that says some_name. That's your username. You'll need to remember it or write it down. And note that it's all lowercase. (No caps for you!) From here on out, where you see "some_name", that's the part that you want to put in your own username.
Step #2: Determining the Partition Descriptors. To determine the partition information, you're going to use the fdisk command. Just so that you are aware, this command can be dangerous if not used properly. Therefore, I suggest you type in the commands exactly as shown here and everything will be groovy. Again, from the terminal, type the following:
sudo fdisk -l
You'll get a short body of text which should appear as follows:
some_name@my_computer:~$ sudo fdisk -l
[sudo] password for some_name:
Disk /dev/sda: 750.1 GB, 750156374016 bytes
255 heads, 63 sectors/track, 91201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xb8ea731b
Device Boot Start End Blocks Id System
/dev/sda1 * 1 65289 524433861 7 HPFS/NTFS
/dev/sda2 65290 91201 208138140 5 Extended
/dev/sda5 65290 90450 202105701 83 Linux
/dev/sda6 90451 91201 6032376 82 Linux swap / Solaris
Disk /dev/sdb: 750.1 GB, 750156374016 bytes
255 heads, 63 sectors/track, 91201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xf2239b7e
Device Boot Start End Blocks Id System
/dev/sdb1 2 91201 732564000 f W95 Ext'd (LBA)
/dev/sdb5 2 91201 732563968+ 7 HPFS/NTFS
Disk /dev/sdc: 2000.3 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x0ddd37a3
Device Boot Start End Blocks Id System
/dev/sdc1 1 243201 1953512001 7 HPFS/NTFS
some_name@my_computer:~$
The parts of this that you are interested in are the lines that say "HPFS/NTFS" under the "System" column. Now, look at the beginning of those lines. Those are the partition descriptors that you will need. There are three here, one for each of the internal 750 GB drives and the external 2 TB drive. The partitions for my system were /dev/sda1, /dev/sdb5, and /dev/sdc1.
Step #3: Creating a New Directory. Now you're going to create a directory which will be the mount point for your file system. I can't explain exactly what a mount point is. I simply think of it as the connection between the Linux filesystem and the partiton where all of the files on the hard drive reside. To make it work, you need to have a directory that will be the mount point. You can either use a current directory or (even better) you can make a directory specifically for the mount point. For our purposes, we're going to make a directory specifically for our mount point. We're going to put it under another directory called /media. First, change to the media directory.
some_name@my_computer:~$ cd /media
some_name@my_computer:/media$
Next, add the new mount point directory. For simplicity's sake, I recommend just using the partition point as the directory name. For example, for the first directory, I made a directory called "sda1". The command appeared as follows:
some_name@my_computer:/media$ sudo mkdir sda1
some_name@my_computer:/media$
I repeated this for all three of the hard drives.
some_name@my_computer:/media$ sudo mkdir sdb5
some_name@my_computer:/media$ sudo mkdir sdc1
You can check that you created the directories properly using the ls command. I'm going to also use the -al switches so that I also get the permissions.
some_name@my_computer:/media$ ls -al
total 40
drwxr-xr-x 7 root root 4096 2009-10-15 07:45 .
drwxr-xr-x 21 root root 4096 2009-10-15 07:45 ..
lrwxrwxrwx 1 root root 6 2009-09-20 12:41 cdrom -> cdrom0
drwxr-xr-x 2 root root 4096 2009-09-20 12:41 cdrom0
drwxr-xr-x 2 root root 4096 2009-09-20 12:41 cdrom1
-rw-r--r-- 1 root root 0 2009-10-15 07:45 .hal-mtab
drwxrwxrwx 1 gary gary 8192 2009-10-15 00:01 sda1
drwxrwxrwx 1 gary gary 8192 2009-10-15 00:01 sdb5
drwxrwxrwx 1 gary gary 8192 2009-10-15 00:05 sdc1
some_name@my_computer:/media$
This shows that I created the three directories, sda1, sdb5, and sdc1, properly.
Step #4: Editing the /etc/fstab File. The final step is editing a file called fstab. It's located in a directory called /etc. Start by changing to the /etc directory.
some_name@my_computer:/media$ cd /etc
some_name@my_computer:/etc$
Open the fstab file for editing, as shown below.
some_name@my_computer:/etc$ sudo gedit fstab
This should open the text editor and you'll see something such as this:
# /etc/fstab: static file system information.
#
# Use 'vol_id --uuid' 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 defaults 0 0
# / was on /dev/sda5 during installation
UUID=efbb3714-82a8-4112-8e48-eb85c039942d / ext3 relatime,errors=remount-ro 0 1
# swap was on /dev/sda6 during installation
UUID=d181a584-8169-403e-a63b-79160813ec7b none swap sw 0 0
/dev/scd0 /media/cdrom0 udf,iso9660 user,noauto,exec,utf8 0 0
You'll need to add one line for each of the partitions you want to mount. I'll add the first line so that you can see what you need to type.
/dev/sda1 /media/sda1 ntfs nls=iso8859-1,gid=some_name,uid=some_name 0 0
The first part is the device partition. The second part is the new directory (starting from the root directory, which is the first "/") you just created. The third part is the format for the Windows partition, which in this case is "ntfs". The fourth part is where I'm a little fuzzy. All I know is that it's what I entered and it works for me. Your mileage may vary. The last two digits are for the dump utility (the first digit) and whether the partition should be periodically checked with fcsk (the second digit).
I'll finish the fstab file with the lines for the other two partitions. Here's how the entire file appeared when I finished.
# /etc/fstab: static file system information.
#
# Use 'vol_id --uuid' 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 defaults 0 0
# / was on /dev/sda5 during installation
UUID=efbb3714-82a8-4112-8e48-eb85c039942d / ext3 relatime,errors=remount-ro 0 1
# swap was on /dev/sda6 during installation
UUID=d181a584-8169-403e-a63b-79160813ec7b none swap sw 0 0
/dev/scd0 /media/cdrom0 udf,iso9660 user,noauto,exec,utf8 0 0
/dev/sda1 /media/sda1 ntfs nls=iso8859-1,gid=some_name,uid=some_name 0 0
/dev/sdb5 /media/sdb5 ntfs nls=iso8859-1,gid=some_name,uid=some_name 0 0
/dev/sdc1 /media/sdc1 ntfs nls=iso8859-1,gid=some_name,uid=some_name 0 0
All that is left to do is to re-start your system. When it is finished re-booting, the partitions should be available. To check, go back to the terminal and use the cd command, along with the directories they are mounted to, to try to access your new partitions. If that works, double-check it by using the ls command. Below is an example.
some_name@my_computer:~$ cd /media/sda1
some_name@my_computer:/media/sda1$ ls -al
total 4190673
drwxrwxrwx 1 gary gary 8192 2009-10-15 00:01 .
drwxr-xr-x 7 root root 4096 2009-10-15 07:45 ..
-rwxrwxrwx 1 gary gary 511 2008-06-18 21:50 artpdbg.log
drwxrwxrwx 1 gary gary 0 2008-06-10 18:34 ATI
-rwxrwxrwx 1 gary gary 0 2004-02-04 20:56 AUTOEXEC.BAT
-rwxrwxrwx 1 gary gary 211 2009-03-05 13:37 boot.ini
drwxrwxrwx 1 gary gary 0 2004-02-04 22:21 bundle
drwxrwxrwx 1 gary gary 0 2008-06-18 20:26 C_DILLA
drwxrwxrwx 1 gary gary 16384 2009-10-14 23:58 Config.Msi
-rwxrwxrwx 1 gary gary 0 2004-02-04 20:56 CONFIG.SYS
drwxrwxrwx 1 gary gary 16384 2009-08-24 17:11 dff24b2f3d4805a7bf2c697ee540b965
drwxrwxrwx 1 gary gary 4096 2004-02-04 20:59 Documents and Settings
drwxrwxrwx 1 gary gary 4096 2004-02-05 18:12 Drivers
drwxrwxrwx 1 gary gary 4096 2008-05-11 13:21 Galleries
drwxrwxrwx 1 gary gary 4096 2009-03-26 22:11 GALXHOFO
-rwxrwxrwx 1 gary gary 2145251328 2009-10-15 07:29 hiberfil.sys
-rwxrwxrwx 1 gary gary 0 2004-02-04 20:56 IO.SYS
-rwxrwxrwx 1 gary gary 863 2004-02-04 21:54 IPH.PH
-rwxrwxrwx 1 gary gary 0 2004-02-04 20:56 MSDOS.SYS
drwxrwxrwx 1 gary gary 0 2004-02-04 21:54 My Music
drwxrwxrwx 1 gary gary 0 2008-12-28 18:43 MyWorks
-rwxrwxrwx 1 gary gary 47564 2008-05-08 21:16 NTDETECT.COM
-rwxrwxrwx 1 gary gary 250048 2008-07-26 15:37 ntldr
drwxrwxrwx 1 gary gary 0 2008-05-08 19:44 NVIDIA
drwxrwxrwx 1 gary gary 0 2009-01-01 17:52 OpenCandy
-rwxrwxrwx 1 gary gary 2145386496 2009-10-15 07:29 pagefile.sys
drwxrwxrwx 1 gary gary 4096 2008-05-11 17:19 POWERCD
drwxrwxrwx 1 gary gary 28672 2009-10-11 10:55 Program Files
drwxrwxrwx 1 gary gary 4096 2008-05-10 15:10 RECYCLER
drwxrwxrwx 1 gary gary 0 2009-05-08 20:34 Rio
drwxrwxrwx 1 gary gary 4096 2009-05-08 20:32 RioDrivers
drwxrwxrwx 1 gary gary 4096 2009-08-30 19:27 Seagate temp
drwxrwxrwx 1 gary gary 4096 2008-05-08 21:30 System Volume Information
drwxrwxrwx 1 gary gary 0 2009-08-31 23:07 temp
drwxrwxrwx 1 gary gary 192512 2009-10-15 07:34 WINDOWS
some_name@my_computer:/media/sda1$
If it didn't work, well, that's where you'll have to look elsewhere. For now. As I better understand how Linux works, I'll post more information especially on trouble-shooting.
If it did work, I recommend that you either put a link to it or add it as a bookmark using the Ubuntu GUI. That will make it even easier to access. And there you have it. Good luck.