Linux partition for server

I currently have a Raid 5 filesystem with 10TB storage.

How should I set up my partition scheme?

I am looking to ensure that I don’t have problems in future and that storage size can be easily expanded. Can you suggest a partition scheme giving specific percentage of storage to partitions like / , /boot , /var , /etc ?

3 Answers 3

Before you decide on partitioning schemes it might help to actually understand the reasons for splitting various parts of the linux.

Firstly multiple partitions are ‘safer’ since if one filesystem is damaged, the others should be alright. This won’t save you from a disk failure. Backups would, as might the parity scheme in your raid level.

Secondly it was a way to use multiple drives of different styles before LVM — this is moot for you

In short, the multi partition scheme is sort of a relic of older times, continued for legacy reasons. If you need to ask why, you’re better off with a single partition.

In the modern context the smart partitioning method would be to use a single large partition (and a second one, optionally for swap, swap files would be an option). Use LVM so you can add disks if you can if you think you may need to add space. A single large partition means things will handle themselves as long as there’s enough space, and you can backup /etc/ /user/local and /home, and use that and a list of installed packages should a bare metal recovery be needed.

Источник

10 Ubuntu Server Partitioning Best Practices

CLIMB

Partitioning your Ubuntu server correctly can be the difference between a well-running server and one that is constantly crashing. Here are 10 best practices to follow.

Ubuntu Server is a popular Linux distribution used by many organizations for their server needs. It is a powerful and reliable operating system that can be used for a variety of tasks. However, it is important to understand the best practices for partitioning Ubuntu Server in order to ensure optimal performance and security.

In this article, we will discuss 10 Ubuntu Server partitioning best practices that you should consider when setting up your server. We will cover topics such as partition size, file system type, and partition layout. By following these best practices, you can ensure that your Ubuntu Server is properly configured and secure.

1. Use LVM

LVM stands for Logical Volume Manager, and it allows you to create logical partitions on your hard drive. This means that instead of having a single partition with all of your data, you can have multiple partitions that are each dedicated to specific tasks or applications.

Читайте также:  Linux one folder back

Using LVM also makes it easier to manage your disk space. You can easily resize existing partitions without having to delete them and start over. Additionally, if you need more storage space, you can add additional physical disks and then use LVM to combine them into one large virtual disk. This is much simpler than manually creating new partitions every time you need more space.

2. Separate /var/log from /var

The /var directory is used to store files that are constantly changing, such as log files. If these files are stored in the same partition as other system files, it can cause performance issues due to disk fragmentation and I/O contention. By separating /var/log from /var, you ensure that your log files have their own dedicated space on the disk, which helps improve overall system performance.

3. Separate /tmp from /var

The /tmp directory is used for temporary files, and it can quickly become filled with large amounts of data. This can cause performance issues on the server if not managed properly. On the other hand, the /var directory contains system logs and other important information that should be kept separate from the temporary files in /tmp.

By separating these two directories, you can ensure that your server runs more efficiently and that any potential problems are easier to diagnose. Additionally, this will help keep your system secure by preventing malicious code from being stored in the /tmp directory.

4. Separate /usr from /

The /usr directory contains all of the user-installed applications, libraries, and other files. This means that if something goes wrong with the root partition (/) then it won’t affect the /usr partition. By separating these two partitions, you can ensure that any problems with the root partition will not cause your installed applications to become inaccessible or corrupted.

Additionally, by having a separate /usr partition, you can easily upgrade your system without worrying about losing any of your installed applications. This is because when you upgrade Ubuntu, only the root partition is affected, leaving the /usr partition untouched.

5. Separate /home from /

The / directory is where the operating system and its applications are installed. This means that any changes to the OS or application files can cause instability in the server, which could lead to data loss or other issues. By separating /home from /, you ensure that user data remains safe even if there are problems with the OS or applications.

Additionally, it’s a good idea to create separate partitions for log files, temporary files, and backups. This helps keep your server organized and makes it easier to manage. It also ensures that important data isn’t lost due to disk space constraints.

6. Separate /boot from /

The /boot partition contains the Linux kernel and other essential files needed to boot the system. If this partition is corrupted, it can cause serious problems with the server’s ability to boot up properly. By separating /boot from /, you are protecting these important files from any potential corruption that could occur in the root directory.

Additionally, if you ever need to upgrade your kernel or make changes to the boot configuration, having a separate /boot partition makes it much easier to do so without affecting the rest of the system.

Читайте также:  Drivers intel hd graphics 4000 linux

7. Separate swap space from root partition

Swap space is used to store data that would otherwise be stored in RAM, but can’t fit due to memory constraints. This means that if the root partition runs out of space, it will start using swap space as well, which can lead to performance issues and even system crashes. By separating swap space from the root partition, you ensure that your system has enough room for both RAM and swap space, so that it can run smoothly without any problems.

8. Create a separate partition for backups

Having a separate partition for backups ensures that your data is stored in an isolated environment, which helps protect it from any malicious activity or system failure. Additionally, having a dedicated backup partition allows you to easily restore files and settings if something goes wrong with the main operating system partition.

Finally, creating a separate partition for backups also makes it easier to manage disk space. By keeping all of your backups on one partition, you can quickly identify how much storage space is being used by backups and adjust accordingly.

9. Do not use bind mounts

Bind mounts are a type of mount that allows you to mount the same directory or file system in multiple locations. This can be useful for certain applications, but it also has some drawbacks.

The main issue with bind mounts is that they can cause confusion when trying to manage files and directories. For example, if you have two different versions of a file mounted in two different places, it can be difficult to keep track of which version is the most up-to-date. Additionally, changes made to one version may not be reflected in the other, leading to inconsistencies.

For these reasons, it’s best to avoid using bind mounts whenever possible. If you do need to use them, make sure you understand how they work and take extra care to ensure your data remains consistent across all versions.

10. Do not create too many partitions

Having too many partitions can lead to a decrease in performance, as the system has to search through multiple partitions for data. It also increases the complexity of managing your server, as you have to keep track of which partition contains what data. Finally, it can cause confusion when trying to troubleshoot issues, as it’s not always clear which partition is causing the problem.

Therefore, it’s best to create only the necessary partitions and avoid creating unnecessary ones. This will help ensure that your Ubuntu Server runs smoothly and efficiently.

Источник

partitions — разметка диска для Linux сервера

Разметка диска для Linux сервера представляет собой выделение разделов или партиций. Партиция — выделенная часть диска, на которой создается своя файловая система. Партиция или раздел монтируется отдельно в определенную точку файловой системы сервера, в определенный каталог.

На разных партициях могут существовать разные файловые системы. Основное преимущество — разделение по назначению.

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

Могут быть дополнительные разделы. Часто используется LVM — технология позволяющая создавать логические разделы поверх физических дисков. Это даёт гибкость при изменении объема партиций.

Читайте также:  Чем разархивировать zip linux

Назначение дополнительных разделов

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

Также отдельный раздел обычно создают для бэкапов.

Отдельный раздел можно создавать под SWAP, он не монтируется в файловую систему.

Рассмотрим как создаются разделы с помощью утилиты parted, у неё есть аналоги, например fdisk.

Посмотреть список партиций

разметка диска для Linux сервера

Таблица разделов имеет тип GPT. На диске два раздела, один из них содержит BIOS boot и имеет объем 1 Мб.

Второй раздел корневой, он является загрузочным и содержит ядро с загрузчиком.

Что и куда смонтировано можно посмотреть выполнив mount просто или df

монтирование при разметке диска в linux

Раздел /dev/vda2 на взятом для демонстрации сервере смонтирован в корень. Дополнительный раздел выделенный на том же диске мог бы выглядеть так:

При использовании другого диска у него отличалась бы буква в имени, диск бы назывался /dev/vdb или /dev/vdc.

Разница между MBR и GPT

Современные дистрибутивы используют таблицу разделов GUID (globally unique identifiers или GPT) , вместо BIOS в системе UEFI

  • позволяет работать с разделами объемом больше 2TB
  • первые 512 байт содержат MBR (для обратной совместимости)

С MBR процесс разметки диска имеет особенности

primary (содержит файловые системы, до 4 штук)
extended (содержит логические разделы, до 1 штук)
logical (содержит файловые системы, до 15 штук)

Разберем создание таблицы разделов для диска /dev/vdb. Он пуст, не имеет таблицы разделов и не смонтирован в файловой системе.

Создадим таблицу разделов gpt и две партиции.

Разметка диска для Linux — создание таблицы разделов

Для нового пустого диска!

Выполнение тех же команд для системного диска приведет к потере данных. Команды выполняются утилитой parted сразу, без подтверждения.

Переходим в parted для раздела

При необходимости смотрим подсказки по работе с утилитой

Задаём единицы измерения — Мегабайты

Теперь создание таблицы разделов

Тип (msdos для MBR, gpt для GPT)

Снова выводим список партиций

Таблица разделов создана. Переходим к партициям, их будет две.

Первую создадим выполняя команды по одной, вторую сразу в одну команду.

Создание партиций на диске

Можно просмотреть неразмеченное и доступное пространство и в нём создавать разделы нужного размера

Указываем тип файловой системы

Задаём начальный сектор, расстояние от начала диска до начала партиции (утилита выводит подсказки на всех этапах)

Теперь создаём второй раздел, он начнется с 1025 Мб. Создадим его указывая всё в одну строку

mkpart test2 ext4 1025mib 2000mib

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

Просмотрим список получившихся партиций — их должно быть две: /dev/vdb1 и /dev/vdb2

Далее создаем файловую систему на разделе /dev/vdb2

Создаем точку монтирования и монтируем /dev/vdb2

В /mount/2 должен появиться каталог lost+found

Разметка диска для Linux сервера на этом завершена. Аналогично можно создавать другие партиции и монтировать их в каталоги, которые предварительно нужно создавать.

Для всех добавляемых разделов кроме раздела под SWAP нужно задавать правила в /etc/fstab чтобы разделы монтировались после перезагрузки.

Создание extended партиции для диска MBR

Для раздела на диске с таблицей MBR можно использовать тип extended.

Это нужно когда планируется больше 4х разделов. Разделов с типом Primary может быть до четырех. Если планируется больше, то один из них делается extended и на нём выделяются логические разделы.

Номера логических партиций начинаются с 5.

Пример создания раздела (до этапа с mkpart всё также как рассмотрено выше):

Создание логического тома на расширенном (extended)

Отмонтировать разделы возникает необходимость при восстановлении поврежденной файловой системы.

Источник

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