---
title: "Connect and disconnect a volume from a cloud server"
sidebar_label: "Connect and disconnect a volume"
sidebar_position: 5
description: "How to replace a cloud server boot volume, connect an additional volume to a server, and disconnect it"
---

import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
import MoreVerticalIcon from '@selectel/docux/icons/more-vertical'
import {TabItemLabel} from '@selectel/docux/components'
import Formbricks from '@theme/MDXComponents/Formbricks'

# Connect and disconnect a volume from a cloud server

## Replace a boot volume \{#replace-boot-volume}

You can only replace a networking boot volume on a cloud server with another network volume.

<Tabs queryString="replace-boot-volume">
  <TabItem value="panel" default>
    <TabItemLabel>
      Control panel
    </TabItemLabel>

    1. In the [Control panel](https://my.selectel.ru/vpc/default/images/), on the top menu, click **Products** and select **Cloud Servers**.
    2. Open the server page → **Network Volumes** tab.
    3. Check which volume is the boot volume — in its row you will see the **Bootable** tag.
    4. If the cloud server does not have a boot volume, first [connect the required volume](#attach-network-volume-to-server) — it will automatically become the boot volume.
    5. If the cloud server already has a boot volume, [turn off the server](/cloud-servers/manage/manage-server.mdx#turn-off-server) and [disconnect the boot volume](#detach-network-volume-from-server). First, [connect the required volume](#attach-network-volume-to-server) — it will automatically become the boot volume.
  </TabItem>

  <TabItem value="openstack">
    <TabItemLabel>
      OpenStack CLI
    </TabItemLabel>

    1. In the [Control panel](https://my.selectel.ru/vpc/default/images/), on the top menu, click **Products** and select **Cloud Servers**.

    2. Open the server page → **Network Volumes** tab.

    3. Check which volume is the boot volume — in its row you will see the **Bootable** tag.

    4. [Open the OpenStack CLI](/cloud-servers/tools/openstack-cli/).

    5. If the cloud server does not have a boot volume, first connect the required volume — it will automatically become the boot volume:

       ```bash
       openstack server add volume <server> <volume>
       ```

       Specify:

       * `<server>` — server ID or name. You can view the list using `openstack server list`
       * `<volume>` — volume ID or name. You can view the list using `openstack volume list`

    6. If the cloud server has a boot volume, turn off the cloud server:

       ```bash
       openstack server stop <server>
       ```

    7. Disconnect the boot volume from the server:

       ```bash
       openstack server remove volume <server> <volume>
       ```

    8. First, connect the required volume — it will automatically become the boot volume:

       ```bash
       openstack server add volume <server> <volume>
       ```
  </TabItem>
</Tabs>

## Connect a network volume to the server \{#attach-network-volume-to-server}

Only network volumes can be connected to the cloud server (up to 255 volumes per server).

If the cloud server has no boot volume, the first connected volume will automatically become the boot volume.

The volume to be connected and the cloud server must be located in the same pool segment.

<Tabs queryString="attach-network-volume-to-server">
  <TabItem value="panel" default>
    <TabItemLabel>
      Control panel
    </TabItemLabel>

    1. Make sure the volume is not connected to other servers, and [disconnect it if necessary](#detach-network-volume-from-server).
    2. We recommend [turning off the server](/cloud-servers/manage/manage-server.mdx#turn-off-server). You can connect a volume to a running server, but make sure the operating system has fully booted.
    3. In the [Control panel](https://my.selectel.ru/vpc/default/images/), on the top menu, click **Products** and select **Cloud Servers**.
    4. Go to the **Volumes** section.
    5. In the volume row, in the **Attached to** column click **Attach**.
    6. Select the server to which the volume will be connected. The volume and the server must be located in the same pool segment — [move the volume to another pool segment if necessary](/cloud-servers/volumes/transfer-volume.mdx#transfer-volume-to-another-pool-segment).
    7. Click **Connect**.
    8. If you connected the volume as an additional one, make sure to [prepare it for use](#prepare-additional-volume) — format and mount it.
  </TabItem>

  <TabItem value="openstack">
    <TabItemLabel>
      OpenStack CLI
    </TabItemLabel>

    1. [Open the OpenStack CLI](/cloud-servers/tools/openstack-cli/).

    2. Make sure the volume is not connected to other servers, and disconnect it if necessary:

       ```bash
       openstack server remove volume <server> <volume>
       ```

       Specify:

       * `<server>` — server ID or name. You can view the list using `openstack server list`
       * `<volume>` — volume ID or name. You can view the list using `openstack volume list`

    3. We recommend turning off the server:

       ```bash
       openstack server stop <server>
       ```

       You can connect a volume to a running server, but make sure the operating system has fully booted.

    4. Connect the volume to the server:

       ```bash
       openstack server add volume <server> <volume>
       ```

    5. If you connected the volume as an additional one, make sure to [prepare it for use](#prepare-additional-volume) — format and mount it.
  </TabItem>
</Tabs>

## Prepare an additional volume for use after connection \{#prepare-additional-volume}

If you have connected an additional volume to a cloud server, you must format and mount it; the setup procedure depends on the operating system.

<Tabs queryString="prepare-additional-volume">
  <TabItem value="linux" default>
    <TabItemLabel>
      Linux
    </TabItemLabel>

    1. [Connect to the server](/cloud-servers/manage/connect-to-server.mdx).

    2. Find the name of the additional volume connected to the server:

       ```bash
       lsblk
       ```

       In the response, `sdb` is the additional volume:

       ```bash
       NAME    MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
       sda       8:0    0    8G  0 disk
       ├─sda1    8:1    0    8G  0 part /
       └─sda14   8:14   0    8M  0 part
       sdb       8:16   0    5G  0 disk
       ```

    3. If the connected volume was created from a source (image, snapshot, backup, or another volume), proceed to step 12.

    4. If the volume is empty, run the `parted` utility to create a file system and partitions on the additional volume:

       ```bash
       parted /dev/sdb
       ```

       Here `sdb` is the additional volume.

    5. Create a partition table with GPT layout:

       ```bash
       mklabel gpt
       ```

    6. Create partitions using the `mkpart` utility, specify the start and end of the partition:

       ```bash
       mkpart primary 0 1GB
       mkpart primary 1GB 3GB
       ```

       In the example, the first partition created is 1 GB in size, and the second is 2 GB (sector from 1 GB to 3 GB).

    7. Check the created partition table:

       ```bash
       print
       ```

       The response will show a list of partitions, their start and end sectors, and partition sizes.

    8. Exit the `parted` utility:

       ```bash
       quit
       ```

    9. If a warning appears when exiting `parted` saying `Information: You may need to update /etc/fstab`, copy the IDs of all additional volume partitions (the `PARTUUID` parameter):

       ```bash
       blkid
       ```

       In the response `sdb1` and `sdb2` are volume partitions, `PARTUUID` are partition IDs:

       ```bash
       /dev/sdb2: PARTLABEL="primary" PARTUUID="bd032abc-8f4e-4723-8ffd-a39544e97e36"
       /dev/sdb1: PARTLABEL="primary" PARTUUID="123e46a1-61a4-3a53-77d7-14a02fbc98bc"
       ```

    10. Open the `/etc/fstab` file:

        ```bash
        nano /etc/fstab
        ```

    11. Add the ID of each partition to the file:

        ```bash
        PARTUUID=<block_id_1> /mnt ext4 defaults 0 0
        PARTUUID=<block_id_2> /mnt ext4 defaults 0 0
        ```

        Specify `<block_id_1>` and `<block_id_2>` — IDs of the additional volume partitions copied in step 9.

    12. Format each partition of the volume using the `mkfs` utility (ext4 partition format is used):

        ```bash
        mkfs.ext4 /dev/sdb1
        mkfs.ext4 /dev/sdb2
        ```

        Here `sdb1` and `sdb2` are partitions of the additional volume.

    13. Create a directory for mounting the additional volume and mount each partition to it:

        ```bash
        mkdir -p /mnt
        mount /dev/sdb1 /mnt
        mount /dev/sdb2 /mnt
        ```

        Here `sdb1` and `sdb2` are volume partitions.

    14. Check the result:

        ```bash
        lsblk
        ```

        The response will show the partitions of the additional volume:

        ```bash
        NAME    MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
        sda       8:0    0    8G  0 disk
        ├─sda1    8:1    0    8G  0 part /
        └─sda14   8:14   0    8M  0 part
        sdb       8:16   0     5G  0 disk
        ├─sdb1    8:17   0 953.7M  0 part /mnt
        └─sdb2    8:18   0   1.9G  0 part /mnt
        ```
  </TabItem>

  <TabItem value="windows">
    <TabItemLabel>
      Windows
    </TabItemLabel>

    1. [Connect to the server](/cloud-servers/manage/connect-to-server.mdx).
    2. If the additional volume is empty, use the [Initialize New Disks](https://docs.microsoft.com/ru-ru/windows-server/storage/disk-management/initialize-new-disks) guide from Microsoft documentation.
    3. If the additional volume was created from a source (another volume, image, snapshot, backup), use the [Change a Drive Letter](https://docs.microsoft.com/ru-ru/windows-server/storage/disk-management/change-a-drive-letter) guide from Microsoft documentation.
  </TabItem>
</Tabs>

## Disconnect a network volume from the server \{#detach-network-volume-from-server}

Only a network volume — whether boot or additional — can be disconnected from a cloud server.

<Tabs queryString="detach-network-volume-from-server">
  <TabItem value="panel" default>
    <TabItemLabel>
      Control panel
    </TabItemLabel>

    1. [Turn off the cloud server](/cloud-servers/manage/manage-server.mdx#turn-off-server) to disconnect the boot volume. We also recommend turning off the server for an additional volume. You can disconnect an additional volume from a powered-on server, but ensure that the operating system has fully booted.
    2. In the [Control panel](https://my.selectel.ru/vpc/default/images/), on the top menu, click **Products** and select **Cloud Servers**.
    3. Перейдите in раздел **Диски**.
    4. In the <MoreVerticalIcon /> menu of the volume, select **Disconnect from server**.
    5. Enter the server name.
    6. Click **Disconnect**.
  </TabItem>

  <TabItem value="openstack">
    <TabItemLabel>
      OpenStack CLI
    </TabItemLabel>

    1. [Open the OpenStack CLI](/cloud-servers/tools/openstack-cli/).
    2. If the volume is a boot volume, turn off the cloud server:

       ```bash
       openstack server stop <server>
       ```

       Specify `<server>` — the server ID or name; you can view it using `openstack server list`
    3. If the volume is an additional volume, we also recommend turning off the server. You can disconnect a volume from a powered-on server, but ensure that the operating system has fully booted.
    4. Disconnect the volume from the server:

       ```bash
       openstack server remove volume <server> <volume>
       ```

       Specify `<volume>` — the volume ID or name; you can view the list using `openstack volume list`
  </TabItem>
</Tabs>

<Formbricks />
