08 April 2009

How to Mount Windows Partition from Linux

I have dual boot in my laptop with Windows XP and my favorite Ubuntu. Windows XP is factory default. Two years back, I installed Fedora and after trying the recent version of Ubuntu, I wanted to install Ubuntu and it has become my favorite in no time. I simply like it. Since I backed up some important Ebooks and documents into Windows partition, I wanted to access those both from Windows XP and Ubuntu. After doing some searching in Internet, I found a mechanism to mount windows partition to Linux.

First, you need to identify the number of Windows partition and locate the partition that you want to mount. "df -k" will help you to identify all the partition/disk in your system. Then, use the "mount" command to mount. For example, here is the sequence of steps to be followed. Run "sudo fdisk -l" and identify windows partition and then mount it using script given after fdisk output.

lnarasim@lnarasim-laptop:~/scripts$ sudo fdisk -l

Disk /dev/sda: 78.5 GB, 78518522880 bytes
255 heads, 63 sectors/track, 9546 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xd0f4738c

Device Boot Start End Blocks Id System
/dev/sda1 * 1 1958 15727603+ 7 HPFS/NTFS
/dev/sda2 1959 9546 60950610 f W95 Ext'd (LBA)
/dev/sda5 1959 4569 20972826 7 HPFS/NTFS
/dev/sda6 4570 4736 1341396 7 HPFS/NTFS
/dev/sda7 4737 4985 2000061 82 Linux swap / Solaris
/dev/sda8 4986 9546 36636201 83 Linux

lnarasim@lnarasim-laptop:~/scripts$ cat win_mount.bash
#! /bin/bash

sudo mkdir -p /media/c
sudo mkdir -p /media/d

sudo mount -t ntfs -o nls=utf8,umask=0222 /dev/sda5 /media/c
sudo mount -t ntfs -o nls=utf8,umask=0222 /dev/sda6 /media/d

I have also come up with a simple shell script to do that. If you want, you can also add this in startup scripts so that Windows partition is mounted automatically after startup. With simple use of Linux commands, we are able to access Windows partition.

No comments: