Editing
Adding a second drive
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
'''Danger:''' When working with the file system, it's important you watch what you type. You can make your system inoperable. '''''NodeSpace is not responsible for data loss.''''' Adding a secondary (or tertiary) drive to a system is a common task. This wiki article will walk you through finding your secondary drive and adding a filesystem to it as a mounted filesystem. == Finding the drive == When SSH'd into your server, run the following command <code>ls /dev/sd*</code>. This command will output all detected SATA drives by the <abbr>OS</abbr> and any partitions. You should see /dev/sda /dev/sda1 /dev/sda2 /dev/sdb, etc. Typically if you have a single SATA drive, the secondary drive will be /dev/sdb. /dev/sda1 is the first partition on the disk /dev/sda. Always verify first. Make note of the drive. If you do not see the drive or have a question, open a support ticket. == Partition the drive == Now we need to add partition(s) to the drive. Run the following command as root (or <code>sudo</code> as a regular user): <code>fdisk /dev/sd'''b'''</code> (change the letter to the appropriate drive). <code>fdisk</code> will then prompt you for a command. Check the disk to see if any partitions exist by typing <code>p</code> and enter. If any partitions exist, you'll see them listed, like this: Device Start End Sectors Size Type /dev/sda1 2048 1953525134 1953523087 931.5G Linux filesystem Enter the <code>p</code> command to create a partition. We recommend keeping the defaults for the next options. Partition number (1-4, default 1): 1 First sector (2048-16777215, default 2048): Last sector, +sectors or +size{K,M,G,T,P} (2048-16777215, default 16777215): Created a new partition 1 of type 'Linux' and of size 8 GiB. Command (m for help): Once the partition is created, you can then write it to the disk using the <code>w</code> command. '''Warning!''' If you messed up, this is where you can abort if needed. Pressing enter after <code>w</code> commits the changes to the disk. Command (m for help): w The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks. Now if you re-run <code>ls /dev/sd*</code>, you should see the partition created. == Format the partition == Before you can use the drive, you need to format the partition. Run the following command as root (or <code>sudo</code>): <code>mkfs.ext4 /dev/sdb1</code>. Change the βsdb1β to the partition that you just created. This will format the partition using the ext4 filesystem. == Mount the filesystem == The last step is to mount the filesystem. Run the following commands: user@server:~$ sudo mkdir /media/sdb1 user@server:~$ sudo mount /dev/sdb1 /media/sdb1 user@server:~$ sudo nano -Bw /etc/fstab The second to last command is mounting the filesystem to our /media/sdb1 directory. The last command edits the the fstab file which will automatically mount the drive when the system boots. Add the following to the last line of the file and save: <code>/dev/sdb1 /media/sdb1 ext4 defaults 0 1</code> And now you can use your additional drive.
Summary:
Please note that all contributions to NodeSpace Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
NodeSpace Wiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
Edit source
View history
More
Navigation
Main page
Recent changes
Random page
Official Support
Submit Ticket
Knowledge Base
Documentation
Knowledge Spotlight
Tools
Tools
What links here
Related changes
Special pages
Page information