Add a partition that can be loaded automatically at reboot

This is the output from running sudo fdisk -l on my system:

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 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: 0x000858bf

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1       59334   476595200   83  Linux
/dev/sda2           59334       60802    11789313    5  Extended
/dev/sda5           59334       60802    11789312   82  Linux swap / Solaris

Disk /dev/sdb: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 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: 0x00000000

Disk /dev/sdb doesn't contain a valid partition table

Disk /dev/sdc: 16.0 GB, 16026435072 bytes
254 heads, 63 sectors/track, 1956 cylinders
Units = cylinders of 16002 * 512 = 8193024 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1        1955    15641929    c  W95 FAT32 (LBA)


First of all your /dev/sdb isn’t partitioned. I am assuming this is the disk you want to mount.

WARNING THIS WILL DESTROY ANY DATA ON YOUR TARGET DISK

run sudo fdisk /dev/sdb

then type o press enter # creates a new table

then type n press enter # creates a new partition

then type p press enter # makes a primary partition.

then type 1 press enter # creates it as the 1st partition

finally type w #this will right any changes to disk.

 

Okay now you have a partition, now you need a filesystem.

run sudo mkfs.ext4 /dev/sdb1

Now you can add it o fstab

You need to add it to /etc/fstab use your favourite text editor

Be careful with this file as it can quite easily cause you system to not boot.

Add a line for the drive, the format would look like this.

This assumes the partition is formated as ext3

#device        mountpoint             fstype    options  dump   fsck

/dev/sdb1    /home/yourname/mydata    ext3    defaults    0    1

Then on the next reboot it will auto mount.


The fstab file lets the system know which drives to mount (or how to mount them, at least).

sudo edit /etc/fstab

then add a line like this one:

/dev/sdb1      /mydata   ext4   defaults   0   0

Of course, replace the values to suit your actual locations:

  • /dev/sdb1 should be the device and partition for the disk you want to mount.
  • /mydata is the place where you want to mount it.
  • ext4 is the type of filesystem it’s using. If you’re not sure, issue the mount command without arguments when the drive is mounted (even if you mounted it manually), it will tell you the filesystem type. (in 12.04 you may simply type auto which determines the filesystem for you at launch)
  • The other values (defaults 0 0) are OK like I show them.

If you want to learn more, you can read man fstab.

source:  askubuntu.com/questions/154180/how-to-mount-a-new-drive-on-startup