Wie kann man unter Linux ein Volume mit mehr als 2 TB an eine VM auf CODE-DE anhängen?

Im Beispiel verbinden wir uns mit der virtuellen Maschine namens test-vol4gb als eouser über ssh. Zunächst können wir sehen, dass keine zusätzlichen Volumes angeschlossen sind.

[eouser@test-vol4gb ~]$ lsblk

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 253:0 0 16G 0 disk
└─vda1 253:1 0 16G 0 part /

Wenn das Volume noch nicht vorhanden ist, muss es erstellt werden. Gehen Sie zu Horizon, „Volumes”, drücken Sie „Volume generieren”. Vergeben Sie einen passenden Namen, wählen die Größe und den Festplattentyp (entweder HDD-Standard oder SSD).

../_images/volattach1.png
../_images/volattach2.png

Wählen Sie nun im Volume-Menü „Anhänge verwalten“ und fügen Sie das Volume an die gewünschte Instanz an. Es wird darin als Blockgerät sichtbar, z.B. /dev/vdb

../_images/volattach3.png

Sie wird darin als Blockgerät sichtbar, wie /dev/vdb oder /dev/sdb (je nachdem, welchen Festplattentyp wir wählen), z. B:

../_images/volattach4.png

Wenn der Datenträger noch nicht benutzt, sondern neu erstellt wurde, muss er zunächst partitioniert und formatiert werden, z. B:

[eouser@test-vol4gb ~]$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 253:0 0 16G 0 disk
└─vda1 253:1 0 16G 0 part /
vdb 253:16 0 4G 0 disk
check is gdisk is installed:
[eouser@test-vol4gb ~]$ gdisk
-bash: gdisk: command not found
install gdisk (Centos):
[eouser@test-vol4gb ~]$ sudo yum check-update
[eouser@test-vol4gb ~]$ sudo yum install -y gdisk
Loaded plugins: fastestmirror
...
Installed:
gdisk.x86_64 0:0.8.6-5.el7

Dependency Installed:
libicu.x86_64 0:50.1.2-15.el7

Complete!

[eouser@test-vol4gb ~]$ sudo gdisk /dev/vdb

GPT fdisk (gdisk) version 0.8.6

Partition table scan:
MBR: not present
BSD: not present
APM: not present
GPT: not present

Creating new GPT entries.

Command (? for help): n
Partition number (1-128, default 1):
First sector (34-8388574, default = 2048) or {+-}size{KMGTP}:
Last sector (2048-8388574, default = 8388574) or {+-}size{KMGTP}:
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300):
Changed type of partition to 'Linux filesystem'

Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): Y
OK; writing new GUID partition table (GPT) to /dev/vdb.
The operation has completed successfully.

[eouser@test-vol4gb ~]$ lsblk

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 253:0 0 16G 0 disk
└─vda1 253:1 0 16G 0 part /
vdb 253:16 0 4G 0 disk
└─vdb1 253:17 0 4G 0 part

[eouser@test-vol4gb ~]$ sudo mkfs.ext4 /dev/vdb1

mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
262144 inodes, 1048315 blocks
52415 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1073741824
32 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736

Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done

Bearbeiten Sie die Datei /etc/fstab mit Ihrem bevorzugten Editor (nano, vim usw.):

[eouser@test-vol4gb ~]$ sudo vim /etc/fstab

und fügen Sie die Zeile:

/dev/sdb1 /my_volume ext4 defaults 0 1

Erstellen Sie den Mountpunkt:

[eouser@test-vol4gb ~]$ sudo mkdir /my_volume

Binden Sie nun das Volume in das System ein:

[eouser@test-vol4gb ~]$ sudo mount /my_volume

[eouser@test-vol4gb ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 16G 2,5G 14G 16% /
devtmpfs 906M 0 906M 0% /dev
tmpfs 920M 0 920M 0% /dev/shm
tmpfs 920M 8,4M 912M 1% /run
tmpfs 920M 0 920M 0% /sys/fs/cgroup
tmpfs 184M 0 184M 0% /run/user/1000
tmpfs 184M 0 184M 0% /run/user/0
/dev/vdb1 3,9G 16M 3,7G 1% /my_volume

Beim nächsten Neustart wird das Volume automatisch gemountet. Volumes können an ein Live-System angehängt werden, ohne dass es neu gestartet werden muss.