Zum Inhalt springen

Attach an additional disk

Diese Seite ist noch nicht in deiner Sprache verfügbar. Englische Seite aufrufen

To attach an additional disk to an instance, you first need to create and attach a volume. Once this is done, perform the following steps:

  1. List all block devices and find the new disk. In this case, the device name is vdb.

    Terminal window
    user@testVM:~$ lsblk
    NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
    vda 252:0 0 64G 0 disk
    ├─vda1 252:1 0 63.9G 0 part /
    ├─vda14 252:14 0 4M 0 part
    └─vda15 252:15 0 106M 0 part /boot/efi
    vdb 252:32 0 100G 0 disk
  2. Create the partition on the additional disk using the commands below (/dev/vdb):

    Terminal window
    user@testVM:~$ sudo fdisk /dev/vdb. #start fdisk on the partition
    Command (m for help): n. #create a new partition
    Partition type
    p primary (0 primary, 0 extended, 4 free)
    e extended (container for logical partitions)
    Select (default p): p #select primary
    Partition number (1-4, default 1):
    First sector (2048-209715199, default 2048):
    Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-209715199, default 209715199):
    Created a new partition 1 of type 'Linux' and of size 100 GiB.
    Command (m for help): w #write changes to partition table
    The partition table has been altered.
    Calling ioctl() to re-read partition table.
    Syncing disks.

    Verify that the new partition has been created:

    Terminal window
    user@testVM:~$ lsblk
    NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
    vda 252:0 0 64G 0 disk
    ├─vda1 252:1 0 63.9G 0 part /
    ├─vda14 252:14 0 4M 0 part
    └─vda15 252:15 0 106M 0 part /boot/efi
    vdb 252:32 0 100G 0 disk
    └─vdb1 252:33 0 100G 0 part
  3. Format the new partition, e.g. using the ext4 file system.

    Terminal window
    sudo mkfs.ext4 /dev/vdb1
  4. Create a folder and mount the partition.

    Terminal window
    sudo mkdir /mnt/mymountpoint
    sudo mount /dev/sdb1/ /mnt/mymountpoint
  1. Retrieve the UUID of the new volume.

    Terminal window
    user@testVM:~$ sudo blkid
    /dev/vda1: LABEL="cloudimg-rootfs" UUID="1a1bd84e-9ac2-4024-8eea-33d95eb361ec" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="bb97197b-5a20-4022-998f-422bd8f318ce"
    /dev/vdb1: UUID="c82f02d5-d79f-43d9-840c-42a02bacb539" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="b78958f9-01"
  2. Add the mountpoint to /etc/fstab.
    bash UUID=c82f02d5-d79f-43d9-840c-42a02bacb539 /mnt/mymountpoint ext4 defaults 0 0