우분투 서버에서 하드 디스크 공간을 늘리는 방법

우분투 서버에서 하드 디스크 공간을 늘리는 방법

우분투 서버를 설치하고 그 안에서 웹 서버를 성공적으로 실행했습니다. 내 시스템 하드 디스크 공간이 1TB이고 내 웹 사이트에서 사용할 수 있는 콘텐츠가 가득하다는 것을 알고 싶습니다. 그리고 마더보드에 외장 4TB 하드 드라이브를 추가하고 싶은데 LAMP가 설치된 하드 드라이브 공간을 어떻게 늘릴 수 있는지가 문제입니다. 즉, Windows의 AOME Partition Manager를 사용하여 파티션을 병합하고 싶습니다. 다른 대안이 있으면 알려주시기 바랍니다.

답변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, 파일 저장. Ctrl + X를 누르고 나노를 닫습니다.

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

모든 것이 올바르게 작동하면 이전 디렉터리를 삭제합니다.

sudo -i
rm /var/oldwww

관련 정보