使用 fdisk 建立資料空間

使用 fdisk 建立資料空間

我在 Windows 上的 Hyper-V 中運行 debian 伺服器,我已將 Hyper-V 分割區擴展到 2T,現在我想擴展 Debian 分割區以使用該新空間。新空間將用於視頻,所以我認為最簡單的方法是創建一個新分區並安裝它並將視頻保存在該分區中。我正在從命令列運行,因此我需要一些幫助來創建分區。我有 fdisk 和 parted 安裝。這是目前的情況:

Disk /dev/sda: 2 TiB, 2199023255552 bytes, 4294967296 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
Disklabel type: dos
Disk identifier: 0x8427e4f2

Device     Boot  Start       End   Sectors   Size Id Type
/dev/sda1  *      2048    499711    497664   243M 83 Linux
/dev/sda2       501758 266336255 265834498 126.8G  5 Extended
/dev/sda5       501760 266336255 265834496 126.8G 8e Linux LVM

Partition 2 does not start on physical sector boundary.



Disk /dev/mapper/UniFiServer--vg-root: 124.8 GiB, 133957681152 bytes, 261636096 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


Disk /dev/mapper/UniFiServer--vg-swap_1: 2 GiB, 2147483648 bytes, 4194304 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

我已經取得了一些進展,看來我成功地使用parted來實際擴展/dev/sda2和/dev/sda5,並在Romeo的幫助下,使用pvresize來擴展它們以顯示2T,現在我只需要一些實際幫助創建我可以使用的東西時,lvcreate 命令不起作用:

Disk /dev/sda: 2 TiB, 2199023255552 bytes, 4294967296 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
Disklabel type: dos
Disk identifier: 0x8427e4f2

Device     Boot  Start        End    Sectors  Size Id Type
/dev/sda1  *      2048     499711     497664  243M 83 Linux
/dev/sda2       501758 4294921875 4294420118    2T  5 Extended
/dev/sda5       501760 4294921875 4294420116    2T 8e Linux LVM

Partition 2 does not start on physical sector boundary.




Disk /dev/mapper/UniFiServer--vg-root: 124.8 GiB, 133957681152 bytes, 261636096 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


Disk /dev/mapper/UniFiServer--vg-swap_1: 2 GiB, 2147483648 bytes, 4194304 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

$ sudo vgs
VG             #PV #LV #SN Attr   VSize VFree
UniFiServer-vg   1   2   0 wz--n- 2.00t 1.88t

$ sudo lvcreate -L 1.88t --name videodata UniFiServer--vg
  Volume group "UniFiServer--vg" not found
  Cannot process volume group UniFiServer--vg

答案1

你應該跑步pvresize來延長PV

pvresize /dev/sda5

然後就可以查看VG的新大小

vgs

然後就可以建立新的LV了

lvcreate -L <size of the new volume> --name <name of volume> UniFiServer-vg

然後您應該格式化並安裝這個新磁碟區。並且不要忘記編輯/etcfstab以在每次啟動時安裝它

相關內容