Mounting Linux Partitions in Ubuntu
First you have to determine what the partition is called and what filesystem it is. One quick way to do it if you know what filesystem you formatted the drive as (Ext3, for example) is to just type the terminal command
Here's how it could come out:
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000eb4baDevice Boot Start End Blocks Id System
/dev/sda1 * 1 524 4208006 83 Linux
/dev/sda2 525 1044 4176900 83 Linux
But let's say I didn't know. Well, one way to find out for sure is to install GParted and find out:
sudo apt-get install gparted gksu
gksudo gparted
You can go to System > Administration > GParted and enter your password to get it started.
Ah, now I can definitely see it's Ext4 for sure. Under Partition I see it's /dev/sda2, and under Filesystem, I see it's Ext4.
If you have a second physical hard drive (not just another partition), you might have to click on the top-right corner to focus on the second hard drive. (Click on the down-pointing arrow to get the drop-down menu.)
So now I'll create a mount point for that partition:
lrwxrwxrwx 1 root root 10 2010-04-26 12:00 20bfd80a-a96b-461c-a63d-c96ff8e95872 -> ../../sda1
lrwxrwxrwx 1 root root 10 2010-04-26 19:19 d1d0cf46-958f-4a12-a604-0ac66040648b -> ../../sda2
sudo nano /etc/fstab
Since we've made changes to the /etc/fstab file, we need to have Ubuntu acknowledge those changes:
sudo chmod -R 755 /storage
*** Yes, I could just use the name of it (/dev/sda2), but UUID is more precise. It's unlikely that I'll unplug my internal drive, plug in a new internal drive, and then plug back in my original internal drive so that the partition names are reassigned. Still, it's safer to use the exact partition identifier in /etc/fstab.
COMMAND LINE PARTITIONING
- software that runs at boot time (e.g., old versions of LILO)
- booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK)
sudo fdisk /dev/sdb
Command (m for help): m
Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only) Command (m for help):
Command action e extended p primary partition (1-4)
Partition number (1-4):
Command (m for help):
The partition table has been altered!
Command Line Formatting
sudo mkfs -t ext3 /dev/sdb1
sudo mkfs -t fat32 /dev/sdb1
Modify Reserved Space (Optional)
sudo tune2fs -m 1 /dev/sdb1
- Using this command does not change any existing data on the drive. You can use it on a drive which already contains data.
Create A Mount Point
sudo mkdir /media/mynewdrive
Mount The Drive
AUTOMATIC MOUNT AT BOOT
gksu gedit /etc/fstab
/dev/sdb1 /media/mynewdrive ext3 defaults 0 2
/dev/sdb1 /media/mynewdrive vfat defaults 0 2
The defaults part may allow you to read, but not write. To write other partition and FAT specific options must be used. If gnome is being used, use the right-click, mount method. Then launch the mount command from terminal, no options. The last entry should be the FAT drive and and look something like:/dev/sda5 on /media/mynewdrive type vfat
(rw,nosuid,nodev,uhelper=hal,shortname=mixed,uid=1000,utf8,umask=077,flush)
- All of the parts between the parenthesis are the mount options and should replace "defaults" in the fstab file. The "2" at the end instructs your system to run a quick file system check on the hard drive at every boot. Changing it to "0" will skip this. Run 'man fstab' for more info here.
sudo chown -R USERNAME:USERNAME /media/mynewdrive
sudo chgrp plugdev /media/mynewdrive sudo chmod g+w /media/mynewdrive sudo chmod +t /media/mynewdrive
MANUALLY MOUNT
sudo mount /dev/sdb1 /media/mynewdrive
sudo umount /media/mynewdriveThat's it