Debian Tutorials

Debian Tutorials


Step by step tutorials showing you how to install and configure various applications and services on Debian based Linux distros.

October 2024
M T W T F S S
 123456
78910111213
14151617181920
21222324252627
28293031  

Categories


Add a second hard disk

Ástþór IPÁstþór IP
Notice

This tutorial is for older Debian versions and may not work for current versions. Please refer to the links below to find a newer tutorial.

Adding a additional hard disk to your workstation or server is easy and often required. Here’s we’ll step through the process of identifing the newly attached drive, prepare and mount it.

If you have just added a virtual disk to a virtual machine, make sure you restart the virtual machine before mounting the new disk.

1. Figure out the device name for the new device

fdisk -l

This will give you output similar to this:

Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
 
Device Boot Start End Blocks Id System
/dev/sda1 * 1 2517 20217771 83 Linux
/dev/sda2 2518 2610 747022+ 5 Extended
/dev/sda5 2518 2610 746991 82 Linux swap / Solaris
 
Disk /dev/sdb: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
 
Disk /dev/sdb doesn't contain a valid partition table

2. Next we’ll partion the new disk using the following command:

cfdisk /dev/sdb
 
> New -> Primary -> Specify size in MB
> Write
> Quit

3. Format the new disk using the ext3 filessystem

mkfs.ext3 /dev/sdb1

4. Mounting the drive to a new folder

mkdir /disk2
mount -t ext3 /dev/sdb1 /disk2

You can name the folder whatever your want and place it in a subfolder of another mounting point, for example /var/disk2

5. Add the new drive to fstab so that it will automatically mount when we reboot the machine. Add the following line to your fstab file (pico /etc/fstab)

/dev/sdb1 /disk2 ext3 defaults,errors=remount-ro 0 1

Now your new hard disk is mounted and ready to use.

Comments 12
  • rbs
    Posted on

    rbs rbs

    Author

    Nice Site!
    http://google.com


  • Shirley
    Posted on

    Shirley Shirley

    Author

    worked great, better than partition editor gpart


  • Mark
    Posted on

    Mark Mark

    Author

    what if using a usb drive?


  • Larry
    Posted on

    Larry Larry

    Author

    Erm… Isn’t it the Debian Way to mount by ID? How would that go?


  • jessie
    Posted on

    jessie jessie

    Author

    lovely, worked first shot, thank u!


  • Judd-markea
    Posted on

    Judd-markea Judd-markea

    Author

    it works on debian squeeze too… thx very good tuto


  • Dom Proxmox
    Posted on

    Dom Proxmox Dom Proxmox

    Author

    Spot on instructions, many thanks


  • Luiz
    Posted on

    Luiz Luiz

    Author

    Excellent post. Was the one who helped me.
    But I’m trying to automatically mount and is giving the error:
          bash: / dev/sdb1: Permission denied
    How can I solve this?


  • divali
    Posted on

    divali divali

    Author

    Thanks that worked wonders.


  • Nadjib
    Posted on

    Nadjib Nadjib

    Author

    Excellent post, Thanks.


  • Adam Gerson
    Posted on

    Adam Gerson Adam Gerson

    Author

    Very helpful, thanks!


  • Vishaant
    Posted on

    Vishaant Vishaant

    Author

    Will this work for proxmox 3.4? Adding a new harddrive?