我已经安装了 ubuntu 服务器,并在其中成功运行了我的 Web 服务器。虽然我想知道我的系统硬盘空间是 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