Add new disk linux

Adding a New Disk Drive to an Ubuntu 20.04 System

One of the first problems encountered by users and system administrators these days is that systems tend to run out of disk space to store data. Fortunately disk space is now one of the cheapest IT commodities. In the next two chapters we will look at the steps necessary to configure Ubuntu to use the space provided via the installation of a new physical or virtual disk drive.

1.1 Mounted File Systems or Logical Volumes

There are two ways to configure a new disk drive on an Ubuntu system. One very simple method is to create one or more Linux partitions on the new drive, create Linux file systems on those partitions and then mount them at specific mount points so that they can be accessed. This approach will be covered in this chapter.

Another approach is to add the new space to an existing volume group or create a new volume group. When Ubuntu is installed with the logical volume management option selected a volume group is created and named vgubuntu. Within this volume group are two logical volumes named root and swap_1 that are used to store the / and swap partitions respectively. By configuring the new disk as part of a volume group we are able to increase the disk space available to the existing logical volumes. Using this approach we are able, therefore, to increase the size of the /home file system by allocating some or all of the space on the new disk to the home volume. This topic will be discussed in detail in “Adding a New Disk to an Ubuntu Volume Group and Logical Volume”.

1.2 Finding the New Hard Drive

This tutorial assumes that a new physical or virtual hard drive has been installed on the system and is visible to the operating system. Once added, the new drive should automatically be detected by the operating system. Typically, the disk drives in a system are assigned device names beginning hd or sd followed by a letter to indicate the device number. For example, the first device might be /dev/sda, the second /dev/sdb and so on.

The following is output from a typical system with only one disk drive connected to a SATA controller:

Источник

How to Add a New Disk to an Existing Linux Server

As system administrators, we would have got requirements wherein we need to configure raw hard disks to the existing servers as part of upgrading server capacity or sometimes disk replacement in case of disk failure.

Читайте также:  Win iso to usb linux

In this article, I will take you through the steps by which we can add the new raw hard disk to an existing Linux server such as RHEL/CentOS or Debian/Ubuntu.

Important: Please note that the purpose of this article is to show only how to create a new partition and doesn’t include partition extension or any other switches.

I am using fdisk utility to do this configuration.

I have added a hard disk of 20GB capacity to be mounted as a /data partition.

fdisk is a command line utility to view and manage hard disks and partitions on Linux systems.

This will list the current partitions and configurations.

Find Linux Partition Details

After attaching the hard disk of 20GB capacity, the fdisk -l will give the below output.

Find New Partition Details

New disk added is shown as /dev/xvdc . If we are adding physical disk it will show as /dev/sda based of the disk type. Here I used a virtual disk.

To partition a particular hard disk, for example /dev/xvdc.

Commonly used fdisk commands.

  • n – Create partition
  • p – print partition table
  • d – delete a partition
  • q – exit without saving the changes
  • w – write the changes and exit.

Here since we are creating a partition use n option.

Create New Partition in Linux

Create either primary/extended partitions. By default we can have upto 4 primary partitions.

Create Primary Partition

Give the partition number as desired. Recommended to go for the default value 1 .

Assign a Partition Number

Give the value of the first sector. If it is a new disk, always select default value. If you are creating a second partition on the same disk, we need to add 1 to the last sector of the previous partition.

Assign Sector to Partition

Give the value of the last sector or the partition size. Always recommended to give the size of the partition. Always prefix + to avoid value out of range error.

Assign Partition Size

Save the changes and exit.

Save Partition Changes

Now format the disk with mkfs command.

Format New Partition

Once formatting has been completed, now mount the partition as shown below.

Make an entry in /etc/fstab file for permanent mount at boot time.

/dev/xvdc1 /data ext4 defaults 0 0
Conclusion

Now you know how to partition a raw disk using fdisk command and mount the same.

We need to be extra cautious while working with the partitions especially when you are editing the configured disks. Please share your feedback and suggestions.

Источник

Добавление жесткого диска в Linux через консоль

Добавление жесткого диска в Linux через консоль

Добавление жесткого диска в Linux — операция достаточно легкая, хотя и кажется на первый взгляд достаточно тяжелой. Ниже предоставлена подробная инструкция того, как добавить жесткий диск в операционных системах семейства Linux.

Все действия проводились на компьютере под управлением операционной системы Debian 8.4, однако они должны подойти и к другим дистрибьютивам Linux.

Читайте также:  Erwin data modeler linux

Идентифицируем жесткий диск

Начнем с того, что найдем под каким именем скрывается жесткий диск в системе. Для этого используем команду ls:

/dev/sda /dev/sda2 /dev/sdb1 /dev/sdc /dev/sda1 /dev/sdb /dev/sdb2 /dev/sdd

Для понимания стоит отметить, что /dev/sda /dev/sdb/ и т. д. (без цифр) — это сами жесткие диски, а вот /dev/sda1, /dev/sda2 — это разделы на жестких дисках.

Создание файловой системы

Если жесткий диск новый, то на нем не должно быть никакой файловой системы. Нам остается лишь получить информацию по этому жесткому диску с помощью утилиты fdisk. Вводим:

Disk /dev/sdc: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Убедившись в том, что это нужный диск, приступаем. Для начала нужно будет создать новый раздел, для этого опять используем программу fdisk:

Welcome to fdisk (util-linux 2.25.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Command (m for help):
Partition type p primary (0 primary, 0 extended, 4 free) e extended (container for logical partitions)

Если планируется создавать один раздел, или больше (но не более четырех), то выбираем пункт p. У Partition number, First sector и Last sector оставляем все по умолчанию и просто нажимаем Enter. Если все прошло успешно, то появится сообщение примерно следующего содержания:

Created a new partition 1 of type 'Linux' and of size 931.5 GiB.

Теперь нужно сохранить эти изменения — вводим команду w, которая укажет программе fdisk о необходимости выйти, предварительно записав изменения на диск. Если же что-то было сделано не так, то можно выйти без изменений введя команду q. Далее нужно создать файловую систему на жестком диске. Пусть это будет ext4:

Так же может оказаться, что диск уже до этого использовался, и там вполне может быть уже существующая файловая система. В таком случае при форматировании раздела появится следующее сообщение:

/dev/sdc1 contains a ntfs file system Proceed anyway? (y,n)

Если на жестком диске нет никаких нужных данных, и не планируется использование файловой системы NTFS, то нужно ответить y. Осталось смонтировать (добавить) раздел в систему. Допустим это будет папка backup, расположенная в корне. Создаем папку:

/dev/sdc1: UUID="360ca23a-300t-asdd-8c8e-a3xdf46dlpf1" TYPE="ext4"

Находим нужный, и запоминаем его UUID. Теперь открываем /etc/fstab, и добавляем туда следующую строчку:

UUID=360ca23a-300t-asdd-8c8e-a3xdf46dlpf1 /backup ext4 errors=remount-ro 0 1
echo "UUID=360ca23a-300t-asdd-8c8e-a3xdf46dlpf1 /backup ext4 errors=remount-ro 0 1" | sudo tee -a /etc/fstab

Этим мы объясняем системе, что при загрузке следует смонтировать раздел с определенным UUID как папку /backup и файловой системой ext4.
Проверить правильность предыдущих действий можно с помощью команды:

Если никаких ошибок не выявлено, значит все было сделано правильно. Для того, чтобы примонтировать раздел прямо сейчас, можно выполнить следующую команду:

sudo mount -t ext4 /dev/sdc1 /backup

Источник

Читайте также:  Wine alt linux install

How do I add an additional hard drive?

I am going to put an additional (non-USB) hard drive in my system. I already have Ubuntu on my other hard drive so I do not want to install Ubuntu on the additional drive but only use it for storage. How do I add the additional hard drive to my Ubuntu system, e.g. make Ubuntu recognize it and mount it properly?

I thought it would make sense to have a general question for this issue. I tried to find one and asked in chat for one without success. Hint: help.ubuntu.com/community/InstallingANewHardDrive

Good idea! Wish I’d found it before I answered this: askubuntu.com/questions/488213/…. Perhaps they could be merged.

4 Answers 4

1 Partition

The easiest and user-friendly way is probably to use gparted after you have installed your new HDD and boot your machine:

Then you create partitions, by setting their size and type.

  • If a partition table does not exist yet, you likely want to choose the type as gpt for Ubuntu-only machines and msdos (aka MBR) for dual-boot Ubuntu/Windows machines. See this forum post for additional discussion
  • Since your hard drive is additional storage space, you probably want to create one single big partition with the type of ext4
  • After adding the new partition, make sure that the left-most partition column shows a true filepath (i.e. /dev/sdb1 ) rather than a placeholder like «New partition #1». If you see the latter, click «Edit > Apply all operations» from the top-bar to actually execute the new partition. Otherwise, it is just in a pending state and your mount will fail in step 2.3

Screenshot of gparted

gparted is a very easy to use tool, and yet very advanced.

2 Mount

After you are done creating your partitions (most likely it will be just one ext4 data partition, since this is your additional storage drive), you need to permanently mount it.

At this step you already know what names your new partition(-s) have. If not sure, following command will remind you about existing drives and partitions on them:

This will output something like this (intentionally skipped /dev/sda system drive info):

Disk /dev/sda: 250.1 GB, 250059350016 bytes . Disk /dev/sdb: 2000.4 GB, 2000398934016 bytes 255 heads, 63 sectors/track, 243201 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disk identifier: 0x000814e3 Device Boot Start End Blocks Id Syste /dev/sdb1 1 243201 1953512001 83 Linux 

Output states, that your new partition is /dev/sdb1 . Now you need to mount it to utilize it’s precious space. To achieve this, you need to perform three simple steps:

2.1 Create a mount point

2.2 Edit /etc/fstab

Open /etc/fstab file with root permissions:

And add following to the end of the file:

/dev/sdb1 /hdd ext4 defaults 0 0 

2.3 Mount partition

Источник

Оцените статью
Adblock
detector