如何增加ubuntu伺服器的硬碟空間

如何增加ubuntu伺服器的硬碟空間

我已經安裝了 ubuntu 伺服器並在其中成功運行了我的網頁伺服器。雖然我想知道我的系統硬碟空間有 1TB,其中充滿了我網站上提供的內容。我想在我的主機板上添加一個外部 4TB 硬碟,但問題是如何增加安裝 LAMP 的硬碟空間。我的意思是我想合併分割區,我們可以使用 AOME 分割區管理器與 Windows 來完成這些操作...如果有任何其他替代方案,請告訴我..

答案1

測試一下:

假設您的外部磁碟機是/dev/sdc

建立一個gpt分區的表格和一個分區:

sudo -i
gdisk /dev/sdc

The initial output is a warning if the disk is not a new disk or a disk already using GPT:

GPT fdisk (gdisk) version 0.7.2
Partition table scan:
  MBR: MBR only
  BSD: not present
  APM: not present
  GPT: not present
***************************************************************
Found invalid GPT and valid MBR; converting MBR to GPT format.
THIS OPERATION IS POTENTIALLY DESTRUCTIVE! Exit by typing 'q' if
you don't want to convert your MBR partitions to GPT format!
***************************************************************
Command (? for help):

當在具有現有 MBR 分割區但沒有 GPT 的磁碟上啟動 gdisk 時,程式會顯示一條由星號包圍的訊息,說明將現有分割區轉換為 GPT。

類型 ?您將看到可用命令的清單:

Command (? for help):  ? 
b   back up GPT data to a file
c   change a partition's name
d   delete a partition
i   show detailed information on a partition
l   list known partition types
n   add a new partition
o   create a new empty GUID partition table (GPT)
p   print the partition table
q   quit without saving changes
r   recovery and transformation options (experts only)
s   sort partitions
t   change a partition's type code
v   verify disk
w   write table to disk and exit
x   extra functionality (experts only)
?   print this menu

鍵入 n 新增分割區,鍵入 XXXT 指定分割區大小。

Partition number (1-128, default 1):  1 
First sector (34-15728606, default = 4605952) or {+-}size{KMGTP}: 
Last sector (4605952-15728606, default = 15728606) or {+-}size{KMGTP}: +4T
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): 8300
Changed type of partition to 'Linux filesystem

w 將變更寫入磁碟,而 q 指令退出而不儲存變更:

命令(?尋求幫助):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).
The operation has completed successfully.

由於 gdisk 建立分割區而不是檔案系統,因此您需要格式化每個分割區

mkfs -t ext4 /dev/sdc1

將通常位於 /var/www 中的檔案移至新分割區

mkdir /media/newwww
mount /dev/sdc1 /media/newwww
cp -dpR /var/www/* /media/newwww/
mv /var/www /var/oldwww
mkdir /var/www

取得UUID

blkid /dev/sdc1

      /dev/sdc1: UUID="c676ae51-cb6f-4c0e-b4a9-76850aafa1d6" TYPE="ext4" 

編輯檔案/etc/fstab

nano /etc/fstab

在文件中加入這一行:

UUID=c676ae51-cb6f-4c0e -xxxx-xxxxxxxx /var/www ext4    defaults        0       2

Control + O,儲存檔案。 Control + X,關閉 nano。

umount /media/newwww
mount /dev/sdc1 /var/www

如果一切正常,則刪除舊目錄:

sudo -i
rm /var/oldwww

相關內容